Files
nexu-io-open-design/apps/web/tests/components/AssistantMessage.test.tsx
Tom Huang 6be4e56544 feat(workspace): add plan mode and Excalidraw sketch flows (#4862)
* feat(daemon): add 'plan' session mode and update related functionality

- Introduced a new session mode 'plan' alongside existing 'design' and 'chat' modes, allowing for editable document creation.
- Updated various functions and interfaces to accommodate the new session mode, including normalization and usage in commands.
- Enhanced markdown rendering capabilities by integrating micromark and its GFM extension for improved markdown processing.
- Added new input types for question forms, expanding the range of user interactions.
- Updated UI components to reflect changes in session modes and ensure proper handling of next steps based on the current mode.

* feat(chat): integrate SessionModeToggle into ChatComposer and HomeHero

- Added SessionModeToggle component to both ChatComposer and HomeHero for improved session management.
- Updated HomeHero styles to accommodate the new mode switcher layout.
- Adjusted countdown timer in QuestionsPanel to extend the skip countdown from 120 seconds to 10 minutes, enhancing user experience.
- Added tests to ensure the countdown functionality works as expected.

* feat(FileViewer): implement synchronized scrolling for Markdown editor and preview

- Added functionality to synchronize scrolling between the Markdown editor and preview panes.
- Introduced new types and utility functions for managing scroll behavior.
- Enhanced the MarkdownViewer component to handle scroll events and maintain scroll position across different modes.
- Updated the component's state management to accommodate the new scrolling features.

* feat(excalidraw): integrate Excalidraw into the project

- Added @excalidraw/excalidraw as a dependency in package.json.
- Updated vitest configuration to include an alias for Excalidraw.
- Imported Excalidraw CSS in the layout component for styling.
- Modified AssistantMessage component to handle optional projectId.
- Enhanced FileOpsSummary to display delete operations.
- Implemented new Excalidraw scene management in SketchEditor and FileWorkspace components.
- Updated MarkdownViewer to support file mentions and improved file handling.
- Refactored various components to accommodate Excalidraw integration and ensure compatibility with existing features.

* feat(files): improve sketch and file handoff flows

* test: align post-merge expectations

* chore(nix): refresh pnpm deps hash

* fix(workspace): stabilize sketch persistence and ci checks

* fix(workspace): address review blockers in editable files

* fix(workspace): persist cleared sketch scenes

* test(workspace): type sketch editor mock scene

* fix(workspace): serialize sketch autosaves

* fix(workspace): keep sketch save revisions current

* test(e2e): stabilize project workspace smoke flows

* fix(analytics): preserve plan mode for BYOK runs

* test(e2e): stabilize new project rail interactions

* fix(files): stop bash delete parsing at shell operators

* test(e2e): stabilize ui cold-start suites

* fix(viewer): preserve absolute markdown image sources

* feat(workspace): preload sketches and enhance markdown save options

- Added functionality to preload persisted sketches before opening the tab.
- Introduced new MarkdownSaveOptions type to manage save behavior.
- Updated saveMarkdownText to handle options for refreshing files and showing saving state.
- Enhanced FileViewer to maintain focus and selection during metadata refresh.
- Implemented a Toast component for user feedback on save and export actions.

* fix(web): stabilize markdown and sketch editor polish

* fix(web): finish sketch editor merge resolution

* chore(nix): refresh pnpm deps hash

* fix(plan): bypass discovery and stabilize markdown sync

* fix(web): simplify scene retrieval in SketchEditor component

* feat(web): enhance markdown viewer with auto-save functionality

- Implemented passive auto-save status in the MarkdownViewer component, replacing the manual Save button with an auto-save indicator.
- Introduced new hooks and state management for tracking auto-save events and displaying the last saved time.
- Added support for synchronized scrolling between the markdown editor and preview.
- Created a new markdown-scroll-sync module to handle scroll synchronization logic.
- Updated localization files to include new strings for auto-save messages.
- Added a SketchEnginePrewarm component to optimize Excalidraw loading times.

* feat(web): enhance session mode toggle with cost indicators

- Added cost tiers for each session mode in the SessionModeToggle component, providing users with a visual representation of usage costs.
- Introduced a new ModeCostTag component to display cost information alongside session mode labels.
- Updated localization files to include new keys for cost labels and notes.
- Enhanced styling for cost indicators to improve user experience and clarity.
- Refactored EntryShell to open the new project modal instead of creating a blank project directly from the rail.
- Implemented a utility function in markdown-scroll-sync to check for vertical progression in block offsets.

* feat(web): add max height adjustment for session mode description card

- Introduced maxHeight prop to the ModeDescriptionCard component to control the height of the description card based on available space.
- Implemented useLayoutEffect in SessionModeToggle to dynamically calculate and set the maximum height of the description card, ensuring it does not overlap with the project tab bar.
- Updated tests to verify that session modes display their expected usage/cost correctly in the UI.
- Enhanced localization files to include new cost-related strings for various languages.

* feat(web): implement goBack function for improved navigation and update auto-open logic

- Added a new `goBack` function to handle in-app navigation, allowing users to return to the previous route instead of a hardcoded destination.
- Updated the `navigate` function to maintain history state for better back navigation.
- Refactored auto-open logic to prioritize produced artifacts, allowing markdown files to be opened alongside HTML files.
- Updated tests to cover new navigation behavior and artifact selection logic.
- Enhanced localization files to include new descriptions for workspace actions.

* refactor(web): remove create design system functionality and update design files panel actions

- Removed the `onCreateDesignSystem` prop and associated button from the DesignFilesPanel component.
- Updated the empty state actions to include a button for creating a new document via the `onPaste` function.
- Adjusted tests to reflect the removal of the design system creation action and ensure the new document button is functional.
- Enhanced the MarkdownViewer component by adding a placeholder for the text area and removing the header bar for a cleaner interface.
- Updated localization files to include a new placeholder string for the markdown editor.

* fix(web): restore markdown placeholder translations

* refactor(web): streamline MarkdownViewer and enhance localization

- Removed unnecessary state management and reload functionality from the MarkdownViewer component for improved performance.
- Added a placeholder text for the markdown editor in multiple localization files to enhance user guidance.
- Updated styles for the save state indicator in the viewer to improve visual clarity and alignment.
- Adjusted tests to reflect changes in the MarkdownViewer and ensure proper functionality.

* fix(web): adjust SketchEditor button size and remove shortcut hints

- Reduced the icon size in the SketchEditor component from 13 to 12 for better alignment.
- Updated the removeSketchMermaidShortcutHints function to also remove the submit shortcut hints from the dialog, enhancing the user interface by decluttering unnecessary elements.
- Adjusted tests to verify the absence of shortcut hints in the modal after updates.

* fix(web): address plan mode follow-up polish

* fix(web): align ci expectations after merge

* test(e2e): stabilize project workspace helpers

* test(e2e): scale settings visual timeout

* fix(prompts): lock ElevenLabs voice picker choices

* test(e2e): pin project workspace P0 worker

* test(e2e): use rail new project entry

* test(e2e): relax app restoration startup waits

* fix(web): limit markdown pipe escaping to tables

---------

Co-authored-by: open-design-bot[bot] <282769551+open-design-bot[bot]@users.noreply.github.com>
Co-authored-by: Amy <1184569493@qq.com>
2026-07-01 04:38:31 +00:00

712 lines
22 KiB
TypeScript

// @vitest-environment jsdom
/**
* Visibility-gate coverage for the assistant feedback widget. It should
* appear after any successfully completed turn, and stay hidden for
* streaming turns, failed runs, and empty responses.
*/
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { AssistantMessage } from '../../src/components/AssistantMessage';
import type { ChatMessage, ProjectFile } from '../../src/types';
beforeAll(() => {
const store = new Map<string, string>();
Object.defineProperty(window, 'localStorage', {
configurable: true,
value: {
clear: () => store.clear(),
getItem: (key: string) => store.get(key) ?? null,
removeItem: (key: string) => store.delete(key),
setItem: (key: string, value: string) => store.set(key, value),
},
});
});
afterEach(() => {
cleanup();
window.localStorage.clear();
});
beforeEach(() => {
window.localStorage.clear();
});
function baseMessage(overrides: Partial<ChatMessage> = {}): ChatMessage {
return {
id: 'msg-1',
role: 'assistant',
content: 'Done.',
runStatus: 'succeeded',
startedAt: 1700000000,
endedAt: 1700000005,
events: [{ kind: 'text', text: 'Done.' } as ChatMessage['events'][number]],
producedFiles: [],
...overrides,
} as ChatMessage;
}
function producedFile(name: string): ProjectFile {
return {
name,
path: name,
size: 100,
mtime: 1700000005,
kind: 'html',
mime: 'text/html',
} as ProjectFile;
}
describe('AssistantMessage feedback gate', () => {
it('copies the raw assistant markdown from the completion footer', async () => {
const originalClipboard = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
const writeText = vi.fn().mockResolvedValue(undefined);
Object.defineProperty(navigator, 'clipboard', {
configurable: true,
value: {
writeText,
},
});
try {
const message = baseMessage({
content: '**Done.**\n\n- Keep the markdown',
events: [
{
kind: 'text',
text: '**Done.**\n\n- Keep the markdown',
} as ChatMessage['events'][number],
],
});
render(
<AssistantMessage
message={message}
streaming={false}
projectId="proj-1"
/>,
);
fireEvent.click(screen.getByRole('button', { name: 'Copy response markdown' }));
await waitFor(() => {
expect(writeText).toHaveBeenCalledWith(message.content);
});
expect(screen.getByRole('button', { name: 'Copied!' })).toBeTruthy();
} finally {
if (originalClipboard) {
Object.defineProperty(navigator, 'clipboard', originalClipboard);
} else {
delete (navigator as { clipboard?: Clipboard }).clipboard;
}
}
});
it('calls the fork handler from completed assistant turns', () => {
const onForkFromMessage = vi.fn();
render(
<AssistantMessage
message={baseMessage()}
streaming={false}
projectId="proj-1"
onForkFromMessage={onForkFromMessage}
/>,
);
fireEvent.click(screen.getByRole('button', { name: 'Fork from here' }));
expect(onForkFromMessage).toHaveBeenCalledTimes(1);
});
it('reaches Contribute (share to Open Design) through the More -> Share cascade', () => {
const onShare = vi.fn();
render(
<AssistantMessage
message={baseMessage({ producedFiles: [producedFile('landing.html')] })}
streaming={false}
projectId="proj-1"
isLast
onFeedback={vi.fn()}
onShareToOpenDesign={onShare}
/>,
);
// Contribute lives behind the next-step card's More -> Share flyout; the busy
// guard in NextStepActions (and the menu closing on click) prevent a second
// submit, replacing the old always-visible disabled button.
fireEvent.mouseEnter(screen.getByTestId('next-step-toolbox-more'));
fireEvent.mouseEnter(screen.getByTestId('next-step-more-share'));
fireEvent.click(screen.getByTestId('next-step-share-contribute'));
expect(onShare).toHaveBeenCalledTimes(1);
});
it('does not show the fork action while the assistant is streaming', () => {
render(
<AssistantMessage
message={baseMessage({
runStatus: 'running',
endedAt: undefined,
})}
streaming
projectId="proj-1"
onForkFromMessage={vi.fn()}
/>,
);
expect(screen.queryByRole('button', { name: 'Fork from here' })).toBeNull();
});
it('shows the feedback widget after a successful turn that produced files', () => {
render(
<AssistantMessage
message={baseMessage({ producedFiles: [producedFile('index.html')] })}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
expect(screen.getByRole('group', { name: 'Feedback' })).toBeTruthy();
expect(screen.getByRole('button', { name: 'Helpful' })).toBeTruthy();
expect(screen.getByRole('button', { name: 'Not helpful' })).toBeTruthy();
});
it('shows the feedback widget for a successful text-only turn with no producedFiles', () => {
render(
<AssistantMessage
message={baseMessage({ producedFiles: [] })}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
expect(screen.getByRole('group', { name: 'Feedback' })).toBeTruthy();
});
it('hides the feedback widget while the turn is still streaming', () => {
render(
<AssistantMessage
message={baseMessage({
producedFiles: [producedFile('index.html')],
runStatus: 'running',
endedAt: undefined,
})}
streaming
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
expect(screen.queryByRole('group', { name: 'Feedback' })).toBeNull();
});
it('shows the feedback widget when the run failed', () => {
render(
<AssistantMessage
message={baseMessage({
producedFiles: [producedFile('index.html')],
runStatus: 'failed',
})}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
// A failed turn is a settled outcome worth rating — it's exactly the case a
// user most wants to thumbs-down, so the feedback row must be present.
expect(screen.getByRole('group', { name: 'Feedback' })).toBeTruthy();
});
it('hides the feedback widget when the run ended with an empty_response status', () => {
render(
<AssistantMessage
message={baseMessage({
producedFiles: [producedFile('index.html')],
events: [
{ kind: 'status', label: 'empty_response' } as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
expect(screen.queryByRole('group', { name: 'Feedback' })).toBeNull();
});
});
describe('AssistantMessage status badge updates (Bug A)', () => {
// Regression coverage for the model-badge stale-detail bug. ACP agents
// emit two `status: 'model'` events per turn:
// 1. After session/new returns — the agent's initial default model
// (e.g. `swe-1-6-fast` for Devin for Terminal)
// 2. After session/set_config_option (or legacy session/set_model)
// succeeds — the user-selected model (e.g. `claude-opus-4-7-max`)
//
// The previous `buildBlocks` dedupe SKIPPED the second event and the
// badge stayed stuck on the initial default, even though the running
// model and the conversation header were already correct. The fix
// updates the existing block's detail to the latest value so the badge
// tracks the most recent model the daemon reported.
it('renders the most recent detail when multiple status events share a label', () => {
render(
<AssistantMessage
message={baseMessage({
events: [
{ kind: 'status', label: 'model', detail: 'swe-1-6-fast' } as ChatMessage['events'][number],
{ kind: 'status', label: 'model', detail: 'claude-opus-4-7-max' } as ChatMessage['events'][number],
{ kind: 'text', text: 'Done.' } as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
// Latest detail should be rendered in the badge.
expect(screen.getByText('claude-opus-4-7-max')).toBeTruthy();
// The initial default must not be present — if it is, the stale-detail
// bug is back.
expect(screen.queryByText('swe-1-6-fast')).toBeNull();
});
it('still collapses repeated status events with the same label and detail into a single badge', () => {
render(
<AssistantMessage
message={baseMessage({
events: [
{ kind: 'status', label: 'model', detail: 'claude-opus-4-7-max' } as ChatMessage['events'][number],
{ kind: 'status', label: 'model', detail: 'claude-opus-4-7-max' } as ChatMessage['events'][number],
{ kind: 'text', text: 'Done.' } as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
const matches = screen.queryAllByText('claude-opus-4-7-max');
expect(matches.length).toBe(1);
});
it('renders bare URLs in status details as links', () => {
render(
<AssistantMessage
message={baseMessage({
runStatus: 'failed',
events: [
{
kind: 'status',
label: 'error',
detail:
'AMR Cloud reported insufficient balance. Recharge at https://open-design.ai/amr/wallet, then retry.',
} as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
onFeedback={vi.fn()}
/>,
);
const link = screen.getByRole('link', { name: 'https://open-design.ai/amr/wallet' });
expect(link.getAttribute('href')).toBe('https://open-design.ai/amr/wallet');
expect(link.classList.contains('md-link')).toBe(true);
});
});
describe('AssistantMessage thinking blocks', () => {
it('does not render an empty thinking block for whitespace-only thinking deltas', () => {
const { container } = render(
<AssistantMessage
message={baseMessage({
content: '',
events: [
{ kind: 'status', label: 'thinking' } as ChatMessage['events'][number],
{ kind: 'thinking', text: '\n \t' } as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
/>,
);
expect(container.querySelector('.thinking-block')).toBeNull();
});
it('keeps non-empty thinking content visible after leading whitespace deltas', () => {
const { container } = render(
<AssistantMessage
message={baseMessage({
content: '',
events: [
{ kind: 'thinking', text: '\n ' } as ChatMessage['events'][number],
{ kind: 'thinking', text: 'Reading the directory listing.' } as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
/>,
);
expect(container.querySelector('.thinking-block')).toBeTruthy();
expect(screen.getByText('Reading the directory listing.')).toBeTruthy();
});
});
describe('AssistantMessage question forms', () => {
it('renders repeated question forms as one compact Questions banner in chat', () => {
const firstForm = [
'<question-form id="discovery" title="Quick brief — tailored">',
JSON.stringify({
questions: [
{
id: 'audience',
label: 'Who is this for?',
type: 'text',
},
],
}),
'</question-form>',
].join('\n');
const duplicateForm = [
'<question-form id="discovery" title="Quick brief — 30 seconds">',
JSON.stringify({
questions: [
{
id: 'output',
label: 'What are we making?',
type: 'radio',
required: true,
options: ['Slide deck / pitch', 'Dashboard / tool UI'],
},
],
}),
'</question-form>',
].join('\n');
const onOpenQuestions = vi.fn();
render(
<AssistantMessage
message={baseMessage({
events: [
{
kind: 'text',
text: `${firstForm}\n\nFirst answer the tailored brief:\n\n${duplicateForm}`,
} as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
onOpenQuestions={onOpenQuestions}
/>,
);
const banners = screen.getAllByTestId('questions-banner');
expect(banners).toHaveLength(1);
fireEvent.click(banners[0]!);
expect(onOpenQuestions).toHaveBeenCalledWith(expect.objectContaining({
form: expect.objectContaining({ id: 'discovery', title: 'Quick brief — tailored' }),
}));
expect(screen.queryByText('Quick brief — tailored')).toBeNull();
expect(screen.queryByText('Who is this for?')).toBeNull();
expect(screen.queryByText('Quick brief — 30 seconds')).toBeNull();
expect(screen.queryByText('What are we making?')).toBeNull();
});
it('renders an answered question banner as a disabled, non-clickable done state', () => {
const form = [
'<question-form id="discovery" title="Quick brief — tailored">',
JSON.stringify({
questions: [
{
id: 'audience',
label: 'Who is this for?',
type: 'text',
},
],
}),
'</question-form>',
].join('\n');
const onOpenQuestions = vi.fn();
render(
<AssistantMessage
message={baseMessage({
events: [
{
kind: 'text',
text: form,
} as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
nextUserContent={'[form answers for discovery]\n- Who is this for?: Product evaluators'}
onOpenQuestions={onOpenQuestions}
/>,
);
const banner = screen.getByTestId('questions-banner') as HTMLButtonElement;
// Answered: no longer an open affordance — disabled, marked answered, and
// clicking it must not re-open the Questions panel.
expect(banner.disabled).toBe(true);
expect(banner.getAttribute('data-answered')).toBe('true');
expect(banner.textContent).toContain('Questions answered');
fireEvent.click(banner);
expect(onOpenQuestions).not.toHaveBeenCalled();
expect(screen.queryByText('Quick brief — tailored')).toBeNull();
expect(screen.queryByText('Who is this for?')).toBeNull();
expect(screen.queryByText('Product evaluators')).toBeNull();
});
it('keeps an unanswered question banner clickable', () => {
const form = [
'<question-form id="discovery" title="Quick brief — tailored">',
JSON.stringify({
questions: [
{
id: 'audience',
label: 'Who is this for?',
type: 'text',
},
],
}),
'</question-form>',
].join('\n');
const onOpenQuestions = vi.fn();
render(
<AssistantMessage
message={baseMessage({
events: [
{
kind: 'text',
text: form,
} as ChatMessage['events'][number],
],
})}
streaming={false}
projectId="proj-1"
onOpenQuestions={onOpenQuestions}
/>,
);
const banner = screen.getByTestId('questions-banner') as HTMLButtonElement;
expect(banner.disabled).toBe(false);
expect(banner.getAttribute('data-answered')).toBeNull();
fireEvent.click(banner);
expect(onOpenQuestions).toHaveBeenCalledWith(expect.objectContaining({
form: expect.objectContaining({ id: 'discovery', title: 'Quick brief — tailored' }),
}));
});
});
describe('AssistantMessage recovered produced files', () => {
it('shows linked project files from the assistant summary as files this turn', () => {
const content = '已创建计划文档:[browser-war-deck-outline.md](browser-war-deck-outline.md)。';
render(
<AssistantMessage
message={baseMessage({
content,
events: [{ kind: 'text', text: content } as ChatMessage['events'][number]],
producedFiles: [],
})}
streaming={false}
projectId="proj-1"
projectFiles={[
{
name: 'browser-war-deck-outline.md',
path: 'browser-war-deck-outline.md',
size: 4096,
mtime: 1700000005,
kind: 'text',
mime: 'text/markdown',
} as ProjectFile,
]}
/>,
);
expect(screen.getByTestId('file-ops-summary')).toBeTruthy();
expect(screen.getByTestId('file-ops-row-browser-war-deck-outline.md')).toBeTruthy();
expect(screen.getByText(/Write 1/)).toBeTruthy();
});
it('shows project files mentioned as plain filenames in the assistant summary', () => {
const content = '文件列表:\n- browser-war-deck-outline.md';
render(
<AssistantMessage
message={baseMessage({
content,
events: [{ kind: 'text', text: content } as ChatMessage['events'][number]],
producedFiles: [],
})}
streaming={false}
projectId="proj-1"
projectFiles={[
{
name: 'browser-war-deck-outline.md',
path: 'browser-war-deck-outline.md',
size: 4096,
mtime: 1700000004,
kind: 'text',
mime: 'text/markdown',
} as ProjectFile,
]}
/>,
);
expect(screen.getByTestId('file-ops-summary')).toBeTruthy();
expect(screen.getByTestId('file-ops-row-browser-war-deck-outline.md')).toBeTruthy();
});
it('does not recover old reference files as produced files', () => {
const content = '参考 `README.md` 的内容。';
render(
<AssistantMessage
message={baseMessage({
content,
events: [{ kind: 'text', text: content } as ChatMessage['events'][number]],
producedFiles: [],
})}
streaming={false}
projectId="proj-1"
projectFiles={[
{
name: 'README.md',
path: 'README.md',
size: 2048,
mtime: 1699990000,
kind: 'text',
mime: 'text/markdown',
} as ProjectFile,
]}
/>,
);
expect(screen.queryByTestId('file-ops-summary')).toBeNull();
});
it('shows files modified during a sparse completed assistant turn', () => {
render(
<AssistantMessage
message={baseMessage({
content: '',
events: [
{ kind: 'status', label: 'starting', detail: 'Claude' } as ChatMessage['events'][number],
{ kind: 'status', label: 'initializing', detail: 'claude-opus' } as ChatMessage['events'][number],
],
producedFiles: [],
})}
streaming={false}
projectId="proj-1"
projectFiles={[
{
name: 'iphone-device-reveal.mp4',
path: 'iphone-device-reveal.mp4',
size: 2328155,
mtime: 1700000004,
kind: 'video',
mime: 'video/mp4',
} as ProjectFile,
]}
/>,
);
expect(screen.getByText('iphone-device-reveal.mp4')).toBeTruthy();
});
it('does not infer user sketches as turn output files', () => {
render(
<AssistantMessage
message={baseMessage({
content: '',
events: [
{ kind: 'status', label: 'starting', detail: 'Claude' } as ChatMessage['events'][number],
{ kind: 'status', label: 'initializing', detail: 'claude-opus' } as ChatMessage['events'][number],
],
producedFiles: [],
})}
streaming={false}
projectId="proj-1"
projectFiles={[
{
name: 'board.sketch.json',
path: 'board.sketch.json',
size: 2048,
mtime: 1700000004,
kind: 'sketch',
mime: 'application/json',
} as ProjectFile,
]}
/>,
);
expect(screen.queryByText('board.sketch.json')).toBeNull();
});
it('still infers generated svg files classified as sketches', () => {
render(
<AssistantMessage
message={baseMessage({
content: '',
events: [
{ kind: 'status', label: 'starting', detail: 'Claude' } as ChatMessage['events'][number],
{ kind: 'status', label: 'initializing', detail: 'claude-opus' } as ChatMessage['events'][number],
],
producedFiles: [],
})}
streaming={false}
projectId="proj-1"
projectFiles={[
{
name: 'diagram.svg',
path: 'diagram.svg',
size: 2048,
mtime: 1700000004,
kind: 'sketch',
mime: 'image/svg+xml',
} as ProjectFile,
{
name: 'board.sketch.json',
path: 'board.sketch.json',
size: 2048,
mtime: 1700000004,
kind: 'sketch',
mime: 'application/json',
} as ProjectFile,
]}
/>,
);
expect(screen.getByText('diagram.svg')).toBeTruthy();
expect(screen.queryByText('board.sketch.json')).toBeNull();
});
it('keeps explicitly recorded sketch outputs visible', () => {
render(
<AssistantMessage
message={baseMessage({
producedFiles: [
{
name: 'agent-sketch.sketch.json',
path: 'agent-sketch.sketch.json',
size: 2048,
mtime: 1700000004,
kind: 'sketch',
mime: 'application/json',
} as ProjectFile,
],
})}
streaming={false}
projectId="proj-1"
/>,
);
expect(screen.getByText('agent-sketch.sketch.json')).toBeTruthy();
});
});