Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions app/shared/src/demo/dataMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
normalizeWorkbenchDataMode,
readWorkbenchDataModeOverride,
resolveWorkbenchDataMode,
workbenchDataModeDisplayLabel,
workbenchDataModeLabel,
writeWorkbenchDataModeOverride,
} from './dataMode';
Expand Down Expand Up @@ -52,60 +51,47 @@ describe('normalizeWorkbenchDataMode', () => {
expect(workbenchDataModeLabel('approved-real')).toBe('approved-real');
});

it('exposes a single shared contract for UI status and data-source boundaries', () => {
it('exposes a single shared contract for runtime and evidence boundaries', () => {
expect(getWorkbenchDataModeContract('mock')).toMatchObject({
mode: 'mock',
statusLabel: 'mock',
displayLabel: 'Mock',
tone: 'amber',
allowsMockData: true,
allowsFixtureData: false,
allowsDemoRuntimeFallback: true,
allowsLocalEdgeAutoFallback: false,
allowsHubData: false,
requiresHubAuthForWeb: false,
requiresLocalEdgeForDesktop: false,
isRealDataMode: false,
isStrictRealMode: false,
});

expect(getWorkbenchDataModeContract('fixture')).toMatchObject({
mode: 'fixture',
statusLabel: 'fixture',
displayLabel: 'Fixture',
tone: 'purple',
allowsMockData: false,
allowsFixtureData: true,
allowsDemoRuntimeFallback: true,
allowsLocalEdgeAutoFallback: false,
allowsHubData: false,
requiresHubAuthForWeb: false,
requiresLocalEdgeForDesktop: false,
isRealDataMode: false,
isStrictRealMode: false,
});

expect(getWorkbenchDataModeContract('approved-real')).toMatchObject({
mode: 'approved-real',
statusLabel: 'approved-real',
displayLabel: 'Approved real',
tone: 'green',
allowsMockData: false,
allowsFixtureData: false,
allowsDemoRuntimeFallback: false,
allowsLocalEdgeAutoFallback: false,
allowsHubData: true,
requiresHubAuthForWeb: true,
requiresLocalEdgeForDesktop: true,
isRealDataMode: true,
isStrictRealMode: true,
});
});

it('keeps transient runtime states out of canonical data-mode labels', () => {
expect(workbenchDataModeLabel('auto')).toBe('auto');
expect(workbenchDataModeDisplayLabel('auto')).toBe('Auto');
expect(workbenchDataModeLabel('demo+edge')).toBe('auto');
expect(workbenchDataModeDisplayLabel('mock (auto fallback)')).toBe('Auto');
expect(workbenchDataModeLabel('mock (auto fallback)')).toBe('auto');
});
});
59 changes: 0 additions & 59 deletions app/shared/src/demo/dataMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,16 @@ export type WorkbenchDataMode =
| 'observed'
| 'approved-real';

export type WorkbenchDataModeTone =
| 'neutral'
| 'amber'
| 'purple'
| 'cyan'
| 'green';

export interface WorkbenchDataModeContract {
mode: WorkbenchDataMode;
statusLabel: WorkbenchDataMode;
displayLabel: 'Auto' | 'Mock' | 'Fixture' | 'Observed' | 'Approved real';
tone: WorkbenchDataModeTone;
title: string;
description: string;
desktopLabel: string;
webLabel: string;
allowsMockData: boolean;
allowsFixtureData: boolean;
allowsDemoRuntimeFallback: boolean;
allowsLocalEdgeAutoFallback: boolean;
allowsHubData: boolean;
requiresHubAuthForWeb: boolean;
requiresLocalEdgeForDesktop: boolean;
isRealDataMode: boolean;
isStrictRealMode: boolean;
}

export const WORKBENCH_DATA_MODE_STORAGE_KEY = 'agenthub.workbench.dataMode';
Expand All @@ -49,97 +34,57 @@ export const WORKBENCH_DATA_MODE_CONTRACTS: Record<WorkbenchDataMode, WorkbenchD
auto: {
mode: 'auto',
statusLabel: 'auto',
displayLabel: 'Auto',
tone: 'neutral',
title: 'Prefer real data, allow development fallback',
description: 'Uses real data when available and fixture data only for explicit development fallback paths.',
desktopLabel: '5173: Tauri real / browser fixture',
webLabel: '5174: authenticated real / anonymous fixture',
allowsMockData: true,
allowsFixtureData: true,
allowsDemoRuntimeFallback: false,
allowsLocalEdgeAutoFallback: true,
allowsHubData: true,
requiresHubAuthForWeb: false,
requiresLocalEdgeForDesktop: false,
isRealDataMode: false,
isStrictRealMode: false,
},
mock: {
mode: 'mock',
statusLabel: 'mock',
displayLabel: 'Mock',
tone: 'amber',
title: 'Pinned mock workbench data',
description: 'Uses local mock data only. Hub and local Edge are not contacted.',
desktopLabel: '5173: demo transcript',
webLabel: '5174: demo transcript',
allowsMockData: true,
allowsFixtureData: false,
allowsDemoRuntimeFallback: true,
allowsLocalEdgeAutoFallback: false,
allowsHubData: false,
requiresHubAuthForWeb: false,
requiresLocalEdgeForDesktop: false,
isRealDataMode: false,
isStrictRealMode: false,
},
fixture: {
mode: 'fixture',
statusLabel: 'fixture',
displayLabel: 'Fixture',
tone: 'purple',
title: 'Pinned shared workbench fixture',
description: 'Uses deterministic fixture data for UI and screenshot verification.',
desktopLabel: '5173: fixture transcript',
webLabel: '5174: fixture transcript',
allowsMockData: false,
allowsFixtureData: true,
allowsDemoRuntimeFallback: true,
allowsLocalEdgeAutoFallback: false,
allowsHubData: false,
requiresHubAuthForWeb: false,
requiresLocalEdgeForDesktop: false,
isRealDataMode: false,
isStrictRealMode: false,
},
observed: {
mode: 'observed',
statusLabel: 'observed',
displayLabel: 'Observed',
tone: 'cyan',
title: 'Hub observed replay only',
description: 'Uses observed Hub sessions, messages, and replayed runtime events. It does not fall back to mock data.',
desktopLabel: '5173: observed Edge snapshot',
webLabel: '5174: observed Hub replay',
allowsMockData: false,
allowsFixtureData: false,
allowsDemoRuntimeFallback: false,
allowsLocalEdgeAutoFallback: false,
allowsHubData: true,
requiresHubAuthForWeb: true,
requiresLocalEdgeForDesktop: true,
isRealDataMode: true,
isStrictRealMode: false,
},
'approved-real': {
mode: 'approved-real',
statusLabel: 'approved-real',
displayLabel: 'Approved real',
tone: 'green',
title: 'Approved real Hub / Edge data only',
description: 'Uses authenticated Hub and Edge data only. Empty or signed-out states stay explicit.',
desktopLabel: '5173: Edge thread data',
webLabel: '5174: Hub session data',
allowsMockData: false,
allowsFixtureData: false,
allowsDemoRuntimeFallback: false,
allowsLocalEdgeAutoFallback: false,
allowsHubData: true,
requiresHubAuthForWeb: true,
requiresLocalEdgeForDesktop: true,
isRealDataMode: true,
isStrictRealMode: true,
},
};

Expand Down Expand Up @@ -188,10 +133,6 @@ export function workbenchDataModeLabel(mode: string | undefined): string {
return getWorkbenchDataModeContract(mode).statusLabel;
}

export function workbenchDataModeDisplayLabel(mode: string | undefined): WorkbenchDataModeContract['displayLabel'] {
return getWorkbenchDataModeContract(mode).displayLabel;
}

export function readWorkbenchDataModeOverride(): WorkbenchDataMode | undefined {
if (typeof window === 'undefined') return undefined;
try {
Expand Down
2 changes: 0 additions & 2 deletions app/shared/src/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ export {
readWorkbenchDataModeOverride,
resolveWorkbenchDataMode,
subscribeWorkbenchDataModeOverride,
workbenchDataModeDisplayLabel,
workbenchDataModeLabel,
writeWorkbenchDataModeOverride,
} from './dataMode';
export type {
WorkbenchDataMode,
WorkbenchDataModeContract,
WorkbenchDataModeTone,
} from './dataMode';

export {
Expand Down
44 changes: 0 additions & 44 deletions app/workbench/src/__tests__/pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
within,
} from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { WORKBENCH_DATA_MODE_STORAGE_KEY } from '@shared/demo';
import { createMockPlatform } from '@shared/platform/createMockPlatform';
import type { TranscriptBlock } from '@shared/transcript/types';
import { AgentHubWorkbench } from '../AgentHubWorkbench';
Expand Down Expand Up @@ -70,49 +69,6 @@ describe('AgentHubWorkbench', () => {
// Verify the project page renders correctly with its heading.
});

it('renders the local data mode setting with mock and real-mode choices', () => {
window.localStorage.removeItem(WORKBENCH_DATA_MODE_STORAGE_KEY);
const platform = createMockPlatform({
surface: 'desktop',
capabilities: { browserPreview: true },
conversations: [{ id: 'builder', title: 'Builder', kind: 'direct' }],
});

render(
<AgentHubWorkbench
agents={agents}
platform={platform}
conversations={platform.seed.conversations}
transcript={transcript}
/>,
);

fireEvent.click(screen.getByRole('button', { name: '设置' }));
fireEvent.click(screen.getByRole('button', { name: '本地开发' }));

expect(screen.getByText('数据模式')).toBeInTheDocument();
expect(screen.getByText('Auto 可开发回退;Mock/Fixture 固定本地数据;Observed/Approved real 不回退。')).toBeInTheDocument();
expect(screen.getAllByRole('button', { name: 'Auto' }).length).toBeGreaterThan(0);
expect(screen.getAllByRole('button', { name: 'Mock' }).length).toBeGreaterThan(0);
expect(screen.getAllByRole('button', { name: 'Fixture' }).length).toBeGreaterThan(0);
expect(screen.getAllByRole('button', { name: 'Observed' }).length).toBeGreaterThan(0);
expect(screen.getAllByRole('button', { name: 'Approved real' }).length).toBeGreaterThan(0);
expect(screen.getByRole('region', { name: '数据模式状态' })).toBeInTheDocument();
expect(screen.getByText('Auto fallback')).toBeInTheDocument();
expect(screen.getByText('Prefer real data, allow development fallback')).toBeInTheDocument();
expect(screen.queryByText('Normal 只走真实数据')).not.toBeInTheDocument();

fireEvent.click(screen.getAllByRole('button', { name: 'Fixture' })[0]!);
expect(window.localStorage.getItem(WORKBENCH_DATA_MODE_STORAGE_KEY)).toBe('fixture');
expect(screen.getByText('Fixture data')).toBeInTheDocument();
expect(screen.getByText('Pinned shared workbench fixture')).toBeInTheDocument();

fireEvent.click(screen.getAllByRole('button', { name: 'Approved real' })[0]!);
expect(window.localStorage.getItem(WORKBENCH_DATA_MODE_STORAGE_KEY)).toBe('approved-real');
expect(screen.getAllByText('Approved real').length).toBeGreaterThan(0);
expect(screen.getByText('Approved real Hub / Edge data only')).toBeInTheDocument();
});

it('opens the account profile popover from the global rail', () => {
const platform = createMockPlatform({
surface: 'desktop',
Expand Down
1 change: 0 additions & 1 deletion app/workbench/src/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ export const WORKBENCH_MOCK_SETTINGS_DEFAULTS = {
deepThinkingDisplay: '摘要',
permissions: { Read: '允许', Write: '需确认', Shell: '需确认', Browser: '允许' },
vitePreviewUrl: 'http://127.0.0.1:5176/desktop/',
dataMode: '自动',
composerSubmitBehavior: 'Enter 发送',
workspacePath: 'D:\\Code\\TokenDance\\tokendance-design',
targetProjectPath: 'D:\\Code\\TokenDance\\AgentHub',
Expand Down
19 changes: 0 additions & 19 deletions app/workbench/src/pages/settings/SettingsPaneHelpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { describe, expect, it } from 'vitest';
import {
STATE_PREVIEW_SPECS,
dataModeStatusDetail,
dataModeStatusLabel,
formatLocalCliItemDescription,
formatLocalCliItemValue,
joinClassNames,
Expand All @@ -12,23 +10,6 @@ import {
} from './SettingsPaneHelpers';

describe('SettingsPaneHelpers', () => {
it('labels data-mode status heads by contract mode', () => {
expect(dataModeStatusLabel('auto')).toBe('Auto fallback');
expect(dataModeStatusLabel('approved-real')).toBe('Approved real');
expect(dataModeStatusLabel('real')).toBe('Approved real');
expect(dataModeStatusLabel('mock')).toBe('Mock data');
expect(dataModeStatusLabel('fixture')).toBe('Fixture data');
expect(dataModeStatusLabel('observed')).toBe('Observed data');
});

it('exposes shared data-mode contract fields for the status panel', () => {
expect(dataModeStatusDetail('mock')).toMatchObject({
mode: 'mock',
displayLabel: 'Mock',
desktopLabel: '5173: demo transcript',
webLabel: '5174: demo transcript',
});
});

it('formats local CLI discovery row description and value', () => {
expect(
Expand Down
15 changes: 1 addition & 14 deletions app/workbench/src/pages/settings/SettingsPaneHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
import type { DesignNavIconName } from '../../designIcons';
import { getWorkbenchDataModeContract } from '@shared/demo';
import type { LocalCliDiscoveryItem } from '@shared/platform';
import type { StatePanelKind } from './types';

/* ═══════════════════════════════════════════════════════════════════════
SettingsPaneHelpers — pure residual slices from SettingsPanes (#686).

Data-mode labels, CLI discovery meta lines, state-panel icon/class
CLI discovery meta lines, state-panel icon/class
packing, and state preview specs. No React / no intentional UX change.
═══════════════════════════════════════════════════════════════════════ */

/** Status-head label for the data-mode contract panel. */
export function dataModeStatusLabel(mode: string): string {
const detail = getWorkbenchDataModeContract(mode);
if (detail.mode === 'auto') return 'Auto fallback';
if (detail.mode === 'approved-real') return 'Approved real';
return `${detail.displayLabel} data`;
}

/** Shared contract fields used by DataModeStatus. */
export function dataModeStatusDetail(mode: string) {
return getWorkbenchDataModeContract(mode);
}

/** CLI discovery row description: version · path. */
export function formatLocalCliItemDescription(item: Pick<LocalCliDiscoveryItem, 'version' | 'path'>): string {
Expand Down
Loading
Loading