Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(chat): clock time on user messages and day dividers
review2504868ffb5f
diff --git a/src/renderer/lib/chatThread.test.ts b/src/renderer/lib/chatThread.test.tsindex 4c1e3bd54..f44d8349a 100644--- a/src/renderer/lib/chatThread.test.ts+++ b/src/renderer/lib/chatThread.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest'import type { ChatMessage } from '@shared/types'-import { assistantTurnEnds, chatRelativeTime } from './chatThread'+import { assistantTurnEnds, chatRelativeTime, dayDividers } from './chatThread'const NOW = Date.parse('2026-09-26T12:00:00Z')const MIN = 60_000@@ -100,3 +100,29 @@ describe('assistantTurnEnds (one action row per assistant turn)', () => {expect(assistantTurnEnds([say('user', 'q', 1)]).size).toBe(0)})})++describe('dayDividers', () => {+ // Local wall-clock values (new Date(y, m - 1, d, h)), so these hold in every timezone.+ const at = (y: number, m: number, d: number, h = 12) => new Date(y, m - 1, d, h).getTime()+ const u = (t?: number) => say('user', 'q', t)+ const a = (t?: number) => say('assistant', 'a', t)++ it('labels the first stamped message of each local day; Today / Yesterday by the viewer clock', () => {+ const now = at(2026, 11, 2, 15)+ const msgs = [u(at(2026, 11, 1)), a(at(2026, 11, 1, 13)), u(at(2026, 11, 2, 9)), a(undefined), a(at(2026, 11, 2, 10))]+ expect([...dayDividers(msgs, now)]).toEqual([[0, 'Yesterday'], [2, 'Today']])+ })++ it('divides two messages a minute apart across local midnight', () => {+ const now = at(2026, 11, 2, 15)+ const msgs = [u(new Date(2026, 10, 1, 23, 59, 30).getTime()), a(new Date(2026, 10, 2, 0, 0, 30).getTime())]+ expect([...dayDividers(msgs, now).keys()]).toEqual([0, 1])+ })++ it('adds the year only for another year', () => {+ expect(dayDividers([u(at(2025, 3, 4))], at(2026, 11, 2)).get(0)).toMatch(/2025/)+ expect(dayDividers([u(at(2026, 3, 4))], at(2026, 11, 2)).get(0)).not.toMatch(/2026/)+ })++ it('no stamps, no dividers', () => expect(dayDividers([u(undefined)], 0).size).toBe(0))+})diff --git a/src/renderer/lib/chatThread.ts b/src/renderer/lib/chatThread.tsindex c5818e286..cf5046c69 100644--- a/src/renderer/lib/chatThread.ts+++ b/src/renderer/lib/chatThread.ts@@ -1,6 +1,6 @@// Pure decisions behind the ⌘M thread's claude.ai look (ChatPanel): where an assistant turn's-// action row goes, what its Copy copies, and how its time reads. No React — see ChatPanel.tsx for-// the glue and chatThread.test.ts for the pins.+// action row goes, what its Copy copies, how its time reads, and where a day divider goes. No+// React — see ChatPanel.tsx for the glue and chatThread.test.ts for the pins.import type { ChatMessage } from '@shared/types'import { isSystemRecordMessage } from '@shared/chat-system-records'@@ -29,6 +29,46 @@ export function chatAbsoluteTime(at: number): string {return new Date(at).toLocaleString()}+/** The clock time under a user message ("09:41"), in the viewer's locale. */+export function chatClockTime(at: number): string {+ return new Date(at).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })+}++const localDay = (d: Date): string => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`++/**+ * Where the thread draws a day divider: message index → its label, on the FIRST stamped message of+ * each LOCAL calendar day (the viewer's, not the transcript writer's — an SSH host's midnight is not+ * the reader's). Unstamped messages never start a day; they sit under whichever day came before.+ * "Today" / "Yesterday" by the viewer's clock `now`, else a short date, with the year only when it+ * is not `now`'s.+ */+export function dayDividers(messages: readonly ChatMessage[], now: number): Map<number, string> {+ const dividers = new Map<number, string>()+ const today = new Date(now)+ const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1)+ let last: string | undefined+ messages.forEach((m, i) => {+ if (typeof m.at !== 'number') return+ const d = new Date(m.at)+ const day = localDay(d)+ if (day === last) return+ last = day+ if (day === localDay(today)) dividers.set(i, 'Today')+ else if (day === localDay(yesterday)) dividers.set(i, 'Yesterday')+ else+ dividers.set(+ i,+ d.toLocaleDateString(undefined, {+ month: 'short',+ day: 'numeric',+ ...(d.getFullYear() !== today.getFullYear() ? { year: 'numeric' } : {})+ })+ )+ })+ return dividers+}+export interface TurnEnd {/** The turn's text parts as markdown source, joined by a blank line; '' = nothing to copy. */copyText: stringdiff --git a/src/renderer/nodes/ChatPanel.thread.test.tsx b/src/renderer/nodes/ChatPanel.thread.test.tsxindex 89d2589e6..d241c6d14 100644--- a/src/renderer/nodes/ChatPanel.thread.test.tsx+++ b/src/renderer/nodes/ChatPanel.thread.test.tsx@@ -28,6 +28,7 @@ const { session, reads } = vi.hoisted(() => {vi.mock('../session/session', () => ({ useSession: () => session }))import { ChatPanel } from './ChatPanel'+import { chatClockTime } from '../lib/chatThread'const NODE = 'n-thread'const MIN = 60_000@@ -170,4 +171,52 @@ describe('⌘M thread look', () => {expect(host.querySelector('.term-chat__tool-group')).toBeNull()expect(host.querySelectorAll('.term-chat__tool')).toHaveLength(2)})++ it('shows the clock time under a user bubble and a day divider at each day start', async () => {+ // `thread` is stamped off the wall clock, so for ten minutes after midnight its first stamps fall+ // on yesterday; re-anchored at today's noon its stamps are all today whenever this runs.+ const noon = new Date(now).setHours(12, 0, 0, 0)+ await mount(thread.map((m) => ({ ...m, at: m.at! - now + noon })))+ const time = host.querySelector('.term-chat__msg--user time.term-chat__time--user')+ expect(time?.textContent).toBe(chatClockTime(noon - 10 * MIN))+ expect(time?.classList.contains('term-chat__time')).toBe(true)+ expect(time?.getAttribute('dateTime')).toBe(new Date(noon - 10 * MIN).toISOString())+ expect(time?.getAttribute('title')).toBeTruthy()+ const days = [...host.querySelectorAll('.term-chat__day')]+ expect(days.map((d) => d.textContent)).toEqual(['Today'])+ expect(days[0].getAttribute('role')).toBe('separator')+ expect(days[0].nextElementSibling?.classList.contains('term-chat__msg--user')).toBe(true)+ })++ it('no clock time under a user bubble the transcript did not stamp', async () => {+ await mount([{ role: 'user', parts: [{ kind: 'text', text: 'q' }], key: 0 }])+ expect(host.querySelector('.term-chat__msg--user')).not.toBeNull()+ expect(host.querySelector('.term-chat__time--user')).toBeNull()+ expect(host.querySelector('.term-chat__day')).toBeNull()+ })++ it('a day that starts on a folded turn end still gets its divider, before the folded row', async () => {+ const midnight = new Date(now).setHours(0, 0, 0, 0)+ await mount([+ { role: 'user', parts: [{ kind: 'text', text: 'q' }], key: 0, at: midnight - 120 * MIN },+ { role: 'assistant', parts: [{ kind: 'tool', name: 'Bash', arg: 'a' }], key: 10, at: midnight - 60 * MIN },+ { role: 'assistant', parts: [{ kind: 'tool', name: 'Bash', arg: 'b' }], key: 20, at: midnight + MIN }+ ])+ const days = [...host.querySelectorAll('.term-chat__day')]+ expect(days.map((d) => d.textContent)).toEqual(['Yesterday', 'Today'])+ expect(days[1].nextElementSibling?.classList.contains('term-chat__msg--folded')).toBe(true)+ })++ it('a day that starts inside a folded tool run keeps its divider (drawn where the run ends)', async () => {+ const midnight = new Date(now).setHours(0, 0, 0, 0)+ await mount([+ { role: 'user', parts: [{ kind: 'text', text: 'q' }], key: 0, at: midnight - 120 * MIN },+ { role: 'assistant', parts: [{ kind: 'tool', name: 'Bash', arg: 'a' }], key: 10, at: midnight - 60 * MIN },+ { role: 'assistant', parts: [{ kind: 'tool', name: 'Bash', arg: 'b' }], key: 20, at: midnight + MIN },+ { role: 'assistant', parts: [{ kind: 'text', text: 'Done.' }], key: 30, at: midnight + 2 * MIN }+ ])+ const days = [...host.querySelectorAll('.term-chat__day')]+ expect(days.map((d) => d.textContent)).toEqual(['Yesterday', 'Today'])+ expect(days[1].nextElementSibling?.textContent).toContain('Done.')+ })})diff --git a/src/renderer/nodes/ChatPanel.tsx b/src/renderer/nodes/ChatPanel.tsxindex cdfd84e99..578c65ffa 100644--- a/src/renderer/nodes/ChatPanel.tsx+++ b/src/renderer/nodes/ChatPanel.tsx@@ -1,6 +1,6 @@import { TEXT_NOT_SUBMITTED, isChatPromptBlocked } from '@shared/text-delivery'import { claudeScreenBlocksInput, readClaudeScreen } from '@shared/agents/claude-screen'-import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react'+import { Fragment, memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react'import { renderMarkdown } from '../lib/markdown'import { useAgentStatus } from '../state/agentStatus'import { useSession } from '../session/session'@@ -56,7 +56,7 @@ import { ChatComposer } from './ChatComposer'import { ChatTurnActions } from './ChatTurnActions'import { useCodeBlockCopy } from './CodeBlockCopy'import { useCodeHighlight } from './CodeHighlight'-import { assistantTurnEnds } from '../lib/chatThread'+import { assistantTurnEnds, chatAbsoluteTime, chatClockTime, dayDividers } from '../lib/chatThread'import { groupToolCalls, partPosition } from '../lib/chatToolGroups'import { ChatToolGroup } from './ChatToolGroup'import { FALLBACK_SESSION_NOTE, transcriptReadCwd } from '../lib/transcriptSession'@@ -988,6 +988,8 @@ export function ChatPanel({const t = setInterval(() => setNow(Date.now()), 60_000)return () => clearInterval(t)}, [])+ // A divider at the first message of each local day; the same `now`, so Today rolls to Yesterday.+ const days = useMemo(() => dayDividers(messages, now), [messages, now])// One part of a message, as the thread draws it. Also used for the members of a folded tool block,// which are drawn inside the block instead of at their own place (lib/chatToolGroups.ts).@@ -1115,42 +1117,64 @@ export function ChatPanel({{messages.map((m, i) => {// A message whose every part is drawn inside an earlier message's tool block has nothing of// its own to draw, unless it ends a turn: then it draws that turn's action row and nothing- // else. (Only assistant parts fold, so a queued message — the user's — never does.)+ // else — bar a day divider (below). (Only assistant parts fold, so a queued message — the+ // user's — never does.)const folded = m.parts.length > 0 && m.parts.every((_, j) => toolGroups.absorbed.has(partPosition(i, j)))const turnEnd = turnEnds.get(i)- if (folded && !turnEnd) return null// Keyed by the source line's byte offset: a prepended page does not re-key (and so does// not re-render) a single existing bubble. Unkeyed ones (grok, the optimistic sent// bubble) fall back to their position.const key = m.key !== undefined ? `k${m.key}` : `i${i}`+ // The day divider is a sibling BEFORE the wrapper, a folded one's too. A message drawn+ // whole inside an earlier tool block still draws its divider alone: its day would+ // otherwise lose its label, since the divider goes only on a day's FIRST stamped message.+ const day = days.get(i)+ const divider = day !== undefined && (+ <div className="term-chat__day" role="separator" aria-label={day}>+ {day}+ </div>+ )+ if (folded && !turnEnd) return divider ? <Fragment key={key}>{divider}</Fragment> : nullconst actions = turnEnd && (<ChatTurnActions copyText={turnEnd.copyText} at={turnEnd.at} now={now} latest={i === latestTurnEnd} />)if (folded) {return (- <div key={key} className={`term-chat__msg term-chat__msg--${m.role} term-chat__msg--folded`}>- {actions}- </div>+ <Fragment key={key}>+ {divider}+ <div className={`term-chat__msg term-chat__msg--${m.role} term-chat__msg--folded`}>{actions}</div>+ </Fragment>)}const queued = queuedRef.current.has(m)return (- <div- key={key}- className={`term-chat__msg term-chat__msg--${m.role}${m.role === 'user' ? ' term-chat__bubble' : ''}${- queued ? ' term-chat__msg--queued' : ''- }`}- >- {m.parts.map((p, j) => {- const at = partPosition(i, j)- const group = toolGroups.groupAt.get(at)- if (group) return <ChatToolGroup key={group.key} messages={messages} group={group} renderPart={renderPart} />- if (toolGroups.absorbed.has(at)) return null- return renderPart(p, i, j)- })}- {queued && <div className="term-chat__queued-label">Queued</div>}- {actions}- </div>+ <Fragment key={key}>+ {divider}+ <div+ className={`term-chat__msg term-chat__msg--${m.role}${m.role === 'user' ? ' term-chat__bubble' : ''}${+ queued ? ' term-chat__msg--queued' : ''+ }`}+ >+ {m.parts.map((p, j) => {+ const at = partPosition(i, j)+ const group = toolGroups.groupAt.get(at)+ if (group) return <ChatToolGroup key={group.key} messages={messages} group={group} renderPart={renderPart} />+ if (toolGroups.absorbed.has(at)) return null+ return renderPart(p, i, j)+ })}+ {m.role === 'user' && m.at !== undefined && (+ <time+ className="term-chat__time term-chat__time--user"+ dateTime={new Date(m.at).toISOString()}+ title={chatAbsoluteTime(m.at)}+ >+ {chatClockTime(m.at)}+ </time>+ )}+ {queued && <div className="term-chat__queued-label">Queued</div>}+ {actions}+ </div>+ </Fragment>)})}{screenBlock && (diff --git a/src/renderer/styles.chat-view.test.ts b/src/renderer/styles.chat-view.test.tsindex 9d3195050..95c190f29 100644--- a/src/renderer/styles.chat-view.test.ts+++ b/src/renderer/styles.chat-view.test.ts@@ -82,6 +82,11 @@ describe('⌘M thread: claude.ai look', () => {expect(folded).toMatch(/padding:\s*0;/)expect(folded).toMatch(/min-height:\s*0;/)})++ it('a day divider is a centered caption, and the clock time under a user bubble is small', () => {+ expect(ruleBody('.term-chat__day')).toMatch(/text-align:\s*center;/)+ expect(ruleBody('.term-chat__time--user')).toMatch(/font-size:\s*11px;/)+ })})describe('the shared .term-chat__input (plan "Revise…", question "Other") keeps a visible field', () => {diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 83e1c39bf..b05851ab7 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -3557,6 +3557,23 @@ body,padding: 0 4px;white-space: nowrap;}+/* The clock time under a user message (its bubble's last line), quiet like the action row's. */+.term-chat__time--user {+ display: block;+ margin-top: 4px;+ padding: 0;+ font-size: 11px;+ color: var(--muted);+ text-align: right;+}+/* A day divider (lib/chatThread.ts `dayDividers`): a quiet centered caption before the first+ message of each local calendar day. */+.term-chat__day {+ flex: 0 0 auto;+ text-align: center;+ font-size: 11px;+ color: rgba(var(--tint-rgb), 0.35);+}.term-chat__text > :first-child {margin-top: 0;}diff --git a/src/shared/types.ts b/src/shared/types.tsindex 560289500..2b6d31365 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -3618,7 +3618,8 @@ export interface ChatMessage {/*** When the transcript line was written (epoch ms, from claude's ISO `timestamp`). Set on BOTH* read paths; absent when the line states none (grok, older records). The ⌘M thread shows it as a- * relative time under an assistant message.+ * relative time under an assistant turn and a clock time under a user message, and starts a day+ * divider at each local day's first stamped message.*/at?: number}