From 5f2a15a669d464137cd8d272d57f618cbe9cbd78 Mon Sep 17 00:00:00 2001 From: Nick Morales Date: Tue, 11 Aug 2026 08:42:41 -0700 Subject: [PATCH] fix(desktop): separate system timestamp text --- .../thread/system-message.test.tsx | 74 +++++++++++++++++++ .../assistant-ui/thread/system-message.tsx | 3 + 2 files changed, 77 insertions(+) create mode 100644 apps/desktop/src/components/assistant-ui/thread/system-message.test.tsx diff --git a/apps/desktop/src/components/assistant-ui/thread/system-message.test.tsx b/apps/desktop/src/components/assistant-ui/thread/system-message.test.tsx new file mode 100644 index 0000000000..df2b2219d3 --- /dev/null +++ b/apps/desktop/src/components/assistant-ui/thread/system-message.test.tsx @@ -0,0 +1,74 @@ +import { AssistantRuntimeProvider, type ThreadMessage, useExternalStoreRuntime } from '@assistant-ui/react' +import { cleanup, render } from '@testing-library/react' +import { afterEach, describe, expect, it, vi } from 'vitest' + +import { Thread } from '.' + +const timestamp = new Date('2026-05-01T00:00:00.000Z') + +class TestResizeObserver { + observe() {} + unobserve() {} + disconnect() {} +} + +vi.stubGlobal('ResizeObserver', TestResizeObserver) +vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => + window.setTimeout(() => callback(performance.now()), 0) +) +vi.stubGlobal('cancelAnimationFrame', (id: number) => window.clearTimeout(id)) +vi.stubGlobal('CSS', { escape: (str: string) => str }) + +Element.prototype.scrollTo = function scrollTo() {} + +function Harness({ text }: { text: string }) { + const message = { + id: 'system-1', + role: 'system', + content: [{ type: 'text', text }], + createdAt: timestamp, + metadata: { custom: { timelineTimestamp: timestamp.getTime() / 1000 } } + } as unknown as ThreadMessage + + const runtime = useExternalStoreRuntime({ + messages: [message], + isRunning: false, + onNew: async () => {} + }) + + return ( + + + + ) +} + +function expectTimestampSeparated(container: HTMLElement, precedingText: string) { + const row = container.querySelector('[data-role="system"]') + const stamp = row?.querySelector('[data-slot="timeline-timestamp"]')?.textContent + + expect(stamp).toBeTruthy() + expect(row?.textContent).toContain(`${precedingText} ${stamp}`) +} + +afterEach(cleanup) + +describe('system message timestamp text separation', () => { + it('separates an ordinary system row timestamp in accessible and copied text', () => { + const { container } = render() + + expectTimestampSeparated(container, 'Review saved.') + }) + + it('separates a slash-status timestamp in accessible and copied text', () => { + const { container } = render() + + expectTimestampSeparated(container, 'model changed') + }) + + it('separates a steer timestamp in accessible and copied text', () => { + const { container } = render() + + expectTimestampSeparated(container, 'rerun tests') + }) +}) diff --git a/apps/desktop/src/components/assistant-ui/thread/system-message.tsx b/apps/desktop/src/components/assistant-ui/thread/system-message.tsx index dcaa7fd1c3..4fefc7a306 100644 --- a/apps/desktop/src/components/assistant-ui/thread/system-message.tsx +++ b/apps/desktop/src/components/assistant-ui/thread/system-message.tsx @@ -61,6 +61,7 @@ export const SystemMessage: FC = () => { steered ยท {steerNote.groups.text.trim()} + {' '} ) @@ -93,6 +94,7 @@ export const SystemMessage: FC = () => { )} + {' '} ) @@ -110,6 +112,7 @@ export const SystemMessage: FC = () => { data-slot="aui_system-message-root" > + {' '} )