From 0c5fef739de40a406d2db33c127c7234b73bd48d Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sat, 21 Feb 2026 15:12:52 -0500 Subject: [PATCH] feat: show full datetime for non-today messages in timeline and fork dialogs --- .../session/dialog-fork-from-timeline.tsx | 2 +- .../tui/routes/session/dialog-timeline.tsx | 2 +- packages/opencode/src/util/locale.ts | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx index 62154cce5636..d85a39a1a0f0 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx @@ -30,7 +30,7 @@ export function DialogForkFromTimeline(props: { sessionID: string; onMove: (mess result.push({ title: part.text.replace(/\n/g, " "), value: message.id, - footer: Locale.time(message.time.created), + footer: Locale.shortDateTime(message.time.created), onSelect: async (dialog) => { const forked = await sdk.client.session.fork({ sessionID: props.sessionID, diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx index 87248a6a8ba6..2cf50ef2e42d 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx @@ -31,7 +31,7 @@ export function DialogTimeline(props: { result.push({ title: part.text.replace(/\n/g, " "), value: message.id, - footer: Locale.time(message.time.created), + footer: Locale.shortDateTime(message.time.created), onSelect: (dialog) => { dialog.replace(() => ( diff --git a/packages/opencode/src/util/locale.ts b/packages/opencode/src/util/locale.ts index 653da09a0b7d..26898c850482 100644 --- a/packages/opencode/src/util/locale.ts +++ b/packages/opencode/src/util/locale.ts @@ -1,4 +1,6 @@ export namespace Locale { + const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + export function titlecase(str: string) { return str.replace(/\b\w/g, (c) => c.toUpperCase()) } @@ -28,6 +30,25 @@ export namespace Locale { } } + export function shortDateTime(input: number): string { + const date = new Date(input) + const now = new Date() + const isToday = + date.getFullYear() === now.getFullYear() && + date.getMonth() === now.getMonth() && + date.getDate() === now.getDate() + + const timeStr = time(input) + + if (isToday) { + return timeStr + } else { + const month = MONTHS[date.getMonth()] + const day = date.getDate() + return `${month} ${day} ${timeStr}` + } + } + export function number(num: number): string { if (num >= 1000000) { return (num / 1000000).toFixed(1) + "M"