diff --git a/packages/app/src/settings/workspaces/workspaces.tsx b/packages/app/src/settings/workspaces/workspaces.tsx index 236c14c3f00..8eadeec66e5 100644 --- a/packages/app/src/settings/workspaces/workspaces.tsx +++ b/packages/app/src/settings/workspaces/workspaces.tsx @@ -196,13 +196,13 @@ export const SettingsWorkspaces: Component<{ if (!updated) return undefined - return getRelativeTime(new Date(updated).toISOString(), language.t) + return getRelativeTime(new Date(updated).toISOString(), language.t, language.intl()) } const sessionTime = (session: SessionInfo) => { if (!session.time.updated) return undefined - return getRelativeTime(new Date(session.time.updated).toISOString(), language.t) + return getRelativeTime(new Date(session.time.updated).toISOString(), language.t, language.intl()) } const inspect = async (directory: string, active: string | undefined, signal?: AbortSignal) => { diff --git a/packages/app/src/shell/commands/dialog.css b/packages/app/src/shell/commands/dialog.css index 89f886ccacd..fffd293cccb 100644 --- a/packages/app/src/shell/commands/dialog.css +++ b/packages/app/src/shell/commands/dialog.css @@ -85,6 +85,7 @@ .command-palette-meta { flex-shrink: 0; + font-variant-numeric: tabular-nums; } .command-palette-file-path { diff --git a/packages/app/src/shell/commands/dialog.tsx b/packages/app/src/shell/commands/dialog.tsx index 38251ddd6ef..743035bfc20 100644 --- a/packages/app/src/shell/commands/dialog.tsx +++ b/packages/app/src/shell/commands/dialog.tsx @@ -2,6 +2,7 @@ import { getDirectory, getFilename } from "@opencode/util/path" import { FileIcon } from "@opencode/ui/file-icon" import { Dialog, DialogBody } from "@opencode/ui/dialog" import { Keybind } from "@opencode/ui/keybind" +import { Tooltip } from "@opencode/ui/tooltip" import { SearchHighlight, SearchList, type SearchListRow } from "@opencode/ui/search-list" import { createMemo, Match, Show, Switch } from "solid-js" import { createStore } from "solid-js/store" @@ -252,9 +253,21 @@ function PaletteSessionRow(props: { fallback={ {(updated) => ( - - {getRelativeTime(new Date(updated()).toISOString(), props.language.t)} - + + + {getRelativeTime(new Date(updated()).toISOString(), props.language.t, props.language.intl())} + + )} } diff --git a/packages/app/src/shell/time.test.ts b/packages/app/src/shell/time.test.ts new file mode 100644 index 00000000000..7f6724cc44f --- /dev/null +++ b/packages/app/src/shell/time.test.ts @@ -0,0 +1,23 @@ +import { afterEach, expect, setSystemTime, test } from "bun:test" +import { getRelativeTime } from "./time" + +const now = new Date(2026, 8, 22, 12) + +const t = (key: string, params?: Record) => `${key}:${params?.count ?? ""}` + +afterEach(() => { + setSystemTime() +}) + +test.each([ + [30_000, "common.time.justNow:"], + [5 * 60_000, "common.time.minutesAgo.short:5"], + [3 * 3_600_000, "common.time.hoursAgo.short:3"], + [6 * 86_400_000, "common.time.daysAgo.short:6"], + [7 * 86_400_000, "Sep 15"], + [400 * 86_400_000, "Aug 18, 2025"], +])("formats %pms ago", (ago, expected) => { + setSystemTime(now) + + expect(getRelativeTime(new Date(now.getTime() - ago).toISOString(), t, "en-US")).toBe(expected) +}) diff --git a/packages/app/src/shell/time.ts b/packages/app/src/shell/time.ts index 96399f1176e..32801dde31a 100644 --- a/packages/app/src/shell/time.ts +++ b/packages/app/src/shell/time.ts @@ -6,7 +6,7 @@ type TimeKey = type Translate = (key: TimeKey, params?: Record) => string -export function getRelativeTime(dateString: string, t: Translate): string { +export function getRelativeTime(dateString: string, t: Translate, locale: string): string { const date = new Date(dateString) const now = new Date() const diffMs = now.getTime() - date.getTime() @@ -21,5 +21,11 @@ export function getRelativeTime(dateString: string, t: Translate): string { if (diffHours < 24) return t("common.time.hoursAgo.short", { count: diffHours }) - return t("common.time.daysAgo.short", { count: diffDays }) + if (diffDays < 7) return t("common.time.daysAgo.short", { count: diffDays }) + + return new Intl.DateTimeFormat(locale, { + day: "numeric", + month: "short", + year: date.getFullYear() === now.getFullYear() ? undefined : "numeric", + }).format(date) }