Skip to content

The agent that grows with you

fix(desktop): show exact timestamps in tooltips (#70450)

liguoyuc9d0cbaba3ab
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
index e49dd7db8cd..9e354264165 100644
--- a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import type { SessionInfo } from '@/hermes'
import { createClientSessionState } from '@/lib/chat-runtime'
import type * as ChatRuntime from '@/lib/chat-runtime'
+import type * as Time from '@/lib/time'
import type * as ComposerStatusStore from '@/store/composer-status'
import type * as SessionStore from '@/store/session'
import { clearAllSessionStates, publishSessionState } from '@/store/session-states'
@@ -32,6 +33,12 @@ vi.mock('@/i18n', () => ({
sessionRunning: 'Running',
waitingForAnswer: 'Waiting for answer'
}
+ },
+ assistant: {
+ thread: {
+ today: (time: string) => `Today at ${time}`,
+ yesterday: (time: string) => `Yesterday at ${time}`
+ }
}
}
})
@@ -62,7 +69,11 @@ vi.mock('@/lib/session-source', () => ({
handoffOriginSource: (state?: string, platform?: string) => (state && platform ? platform : null),
sessionSourceLabel: (source: string) => source
}))
-vi.mock('@/lib/time', () => ({ coarseElapsed: () => ({ unit: 'minute' as const, value: 5 }) }))
+vi.mock('@/lib/time', async importOriginal => {
+ const actual = await importOriginal<typeof Time>()
+
+ return { ...actual, coarseElapsed: () => ({ unit: 'minute' as const, value: 5 }) }
+})
// These mocks use importOriginal rather than replacing the module wholesale:
// session-row.tsx (and its transitive imports, e.g. session-color.ts) reads
@@ -297,6 +308,30 @@ describe('SidebarSessionRow', () => {
})
})
+ it('exposes the exact session time through a focusable Tip trigger', () => {
+ const startedAt = Math.floor(Date.now() / 1000) - 5 * 60
+
+ render(
+ <SidebarSessionRow
+ isPinned={false}
+ isSelected={false}
+ onArchive={noop}
+ onDelete={noop}
+ onPin={noop}
+ onResume={noop}
+ session={makeSession({ started_at: startedAt, title: 'Timestamped session' })}
+ />
+ )
+
+ const age = screen.getByText('5m')
+ expect(age.tagName).toBe('TIME')
+ expect(age.getAttribute('datetime')).toBe(new Date(startedAt * 1000).toISOString())
+ expect(age.getAttribute('aria-label')).toMatch(/^5m, Today at /)
+ expect(age.getAttribute('tabindex')).toBe('0')
+ expect(age.getAttribute('title')).toBeNull()
+ expect(tipTrigger(age)).toBeTruthy()
+ })
+
it('does not render a handoff avatar for a locally-started session', () => {
const { container } = render(
<SidebarSessionRow
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.tsx b/apps/desktop/src/app/chat/sidebar/session-row.tsx
index 835c7620eb4..bb66fefdba5 100644
--- a/apps/desktop/src/app/chat/sidebar/session-row.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-row.tsx
@@ -7,6 +7,7 @@ import { ProfileTag } from '@/app/chat/profile-tag'
import { startSessionDrag } from '@/app/chat/session-drag'
import { PlatformAvatar } from '@/app/messaging/platform-icon'
import { openSession } from '@/app/open-session'
+import { formatMessageTimestamp } from '@/components/assistant-ui/thread/timestamp'
import { Button } from '@/components/ui/button'
import { Codicon } from '@/components/ui/codicon'
import { OverflowTip, Tip } from '@/components/ui/tooltip'
@@ -145,7 +146,10 @@ function SidebarSessionRowImpl({
toolCallCount: fmt.toolCallCount
})
- const age = formatAge(session.last_active || session.started_at, r)
+ const timestamp = session.last_active || session.started_at
+ const age = formatAge(timestamp, r)
+ const timestampDate = new Date(timestamp * 1000)
+ const absoluteAge = formatMessageTimestamp(timestampDate, t.assistant.thread)
const handleLabel = `Reorder ${title}`
// Opt-in row metadata from the sidebar's filter menu. Read from the store
// rather than threaded as props: the subscription re-renders past the memo
@@ -172,11 +176,7 @@ function SidebarSessionRowImpl({
rowMeta.includes('tokens') && totalTokens > 0 ? compactNumber(totalTokens) : null,
// Sub-cent spend rounds to "$0.00", which reads as a bug rather than as a
// cheap session — below a cent the row says nothing at all.
- rowMeta.includes('cost') && cost >= 0.01 ? `$${cost.toFixed(2)}` : null,
- // The card always shows its age — it IS the header line's right edge — and
- // it rides the same trailing slot as everything else, so the kebab swaps
- // over it on hover exactly like the one-line row.
- pinnedAge || card ? age : null
+ rowMeta.includes('cost') && cost >= 0.01 ? `$${cost.toFixed(2)}` : null
].filter(Boolean) as string[]
// Everything the Show menu puts after the title shares ONE right-aligned
@@ -196,12 +196,14 @@ function SidebarSessionRowImpl({
trailing.push({ key: 'pr', node: <PrTag pr={pr} /> })
}
- if (figures.length) {
+ const showAge = pinnedAge || card
+
+ if (figures.length || showAge) {
// The card's meta lines separate by spacing alone, so its header figures
// match (non-breaking pair — plain spaces collapse to one); the one-line
// row keeps the interpunct between joined figures.
const sep = card ? '\u00A0\u00A0' : ' · '
- const head = figures.slice(0, -1).join(sep)
+ const head = (showAge ? figures : figures.slice(0, -1)).join(sep)
trailing.push({
key: 'figures',
@@ -211,7 +213,20 @@ function SidebarSessionRowImpl({
{/* The figures own their tail: the separator goes with it. */}
<span className={cn('inline-block text-right', TAIL_HIDES)}>
{head && sep}
- {figures.at(-1)}
+ {showAge ? (
+ <Tip label={absoluteAge} side="top">
+ <time
+ aria-label={`${age}, ${absoluteAge}`}
+ className="pointer-events-auto focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sidebar-ring"
+ dateTime={timestampDate.toISOString()}
+ tabIndex={0}
+ >
+ {age}
+ </time>
+ </Tip>
+ ) : (
+ figures.at(-1)
+ )}
</span>
</span>
)
@@ -219,7 +234,7 @@ function SidebarSessionRowImpl({
}
// A chip that ends the slot hides whole; the figures handle their own tail.
- const chipEndsSlot = trailing.length > 0 && !figures.length
+ const chipEndsSlot = trailing.length > 0 && !figures.length && !pinnedAge
// A handed-off session's live source is local, but it originated on a
// messaging platform — surface that origin as a small badge so e.g. a
// Telegram thread continued here still reads as Telegram.