fix(desktop): separate system timestamp text

This commit is contained in:
Nick Morales
2026-08-11 08:42:41 -07:00
committed by Teknium
parent a896322b46
commit 5f2a15a669
2 changed files with 77 additions and 0 deletions
@@ -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<ThreadMessage>({
messages: [message],
isRunning: false,
onNew: async () => {}
})
return (
<AssistantRuntimeProvider runtime={runtime}>
<Thread />
</AssistantRuntimeProvider>
)
}
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(<Harness text="Review saved." />)
expectTimestampSeparated(container, 'Review saved.')
})
it('separates a slash-status timestamp in accessible and copied text', () => {
const { container } = render(<Harness text={'slash:/model\nmodel changed'} />)
expectTimestampSeparated(container, 'model changed')
})
it('separates a steer timestamp in accessible and copied text', () => {
const { container } = render(<Harness text="steer:rerun tests" />)
expectTimestampSeparated(container, 'rerun tests')
})
})
@@ -61,6 +61,7 @@ export const SystemMessage: FC = () => {
<span className="text-muted-foreground/55">steered</span>
<span className="text-muted-foreground/35">·</span>
<span className="whitespace-pre-wrap">{steerNote.groups.text.trim()}</span>
{' '}
<MessageTimelineTimestamp />
</MessagePrimitive.Root>
)
@@ -93,6 +94,7 @@ export const SystemMessage: FC = () => {
<LinkifiedText className="whitespace-pre-wrap" explicitOnly pretty={false} text={output} />
</>
)}
{' '}
<MessageTimelineTimestamp className={cn(multiline ? 'mt-0.5 block' : 'ml-1.5')} />
</MessagePrimitive.Root>
)
@@ -110,6 +112,7 @@ export const SystemMessage: FC = () => {
data-slot="aui_system-message-root"
>
<LinkifiedText className="whitespace-pre-wrap" explicitOnly pretty={false} text={text} />
{' '}
<MessageTimelineTimestamp className={cn(multiline ? 'mt-0.5 block' : 'ml-1.5')} />
</MessagePrimitive.Root>
)