Skip to content

Commit d80de8e

Browse files
committed
fix(tui): put the date before the time in turn footers
A turn that did not finish today rendered `11:26 PM · 10/4/2026` because the footer reused Locale.todayTimeOrDateTime, whose datetime form is time first. It now uses Locale.todayTimeOrDateFirst and reads `10/4/2026 11:26 PM`; today's turns stay time-only. todayTimeOrDateTime keeps its order for /timestamps and `opencode session list`. The same change is folded into the feature commit on tui-turn-timing (PR anomalyco#53195). AI-Tool: opencode 1.18.33-vt-60-2fa3363c92 AI-Model: anthropic/claude-opus-5-5 AI-Variant: high AI-Platform: linux AI-Harness: Vibeterm e8a11eb AI-Session-ID: ses_ef81c1485ffeC5Sb59U9mVI77g
1 parent 8e1d9b7 commit d80de8e

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

‎packages/tui/src/routes/session/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; las
16511651
<span style={{ fg: theme.text }}>{Locale.titlecase(props.message.mode)}</span>
16521652
<span style={{ fg: theme.textMuted }}> · {model()}</span>
16531653
<Show when={ctx.showTurnTime() && completed()}>
1654-
{(time) => <span style={{ fg: theme.textMuted }}> · {Locale.todayTimeOrDateTime(time())}</span>}
1654+
{(time) => <span style={{ fg: theme.textMuted }}> · {Locale.todayTimeOrDateFirst(time())}</span>}
16551655
</Show>
16561656
<Show when={ctx.showTurnDuration() && completed()}>
16571657
{(time) => (

‎packages/tui/src/util/locale.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,26 @@ export function datetime(input: number): string {
1515
}
1616

1717
export function todayTimeOrDateTime(input: number): string {
18-
const date = new Date(input)
19-
const now = new Date()
20-
const isToday =
21-
date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate()
22-
23-
if (isToday) {
18+
if (isToday(input)) {
2419
return time(input)
2520
} else {
2621
return datetime(input)
2722
}
2823
}
2924

25+
export function todayTimeOrDateFirst(input: number): string {
26+
if (isToday(input)) return time(input)
27+
return `${new Date(input).toLocaleDateString()} ${time(input)}`
28+
}
29+
30+
function isToday(input: number) {
31+
const date = new Date(input)
32+
const now = new Date()
33+
return (
34+
date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate()
35+
)
36+
}
37+
3038
export function number(num: number): string {
3139
if (num >= 1000000) {
3240
return (num / 1000000).toFixed(1) + "M"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { expect, test } from "bun:test"
2+
import { Locale } from "../../src/util/locale"
3+
4+
test("todayTimeOrDateFirst shows only the time for today", () => {
5+
const now = Date.now()
6+
expect(Locale.todayTimeOrDateFirst(now)).toBe(Locale.time(now))
7+
})
8+
9+
test("todayTimeOrDateFirst puts the date before the time on other days", () => {
10+
const yesterday = Date.now() - 86_400_000
11+
expect(Locale.todayTimeOrDateFirst(yesterday)).toBe(
12+
`${new Date(yesterday).toLocaleDateString()} ${Locale.time(yesterday)}`,
13+
)
14+
})

0 commit comments

Comments
 (0)