diff options
| author | Alex Yaroshuk <[email protected]> | 2026-02-06 20:19:25 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-06 06:19:25 -0600 |
| commit | ac88c6b637e3d4f2b1022abd06f1a052d644deca (patch) | |
| tree | ddd76c32055846d3f1f74af479522b19d44207e8 /packages/app/src | |
| parent | d4fcc1b863b9f0ada5ac74863c67581e225d8869 (diff) | |
| download | opencode-ac88c6b637e3d4f2b1022abd06f1a052d644deca.tar.gz opencode-ac88c6b637e3d4f2b1022abd06f1a052d644deca.zip | |
feat(app): session last updated time display in command pallete's search (#12376)
Diffstat (limited to 'packages/app/src')
| -rw-r--r-- | packages/app/src/components/dialog-select-file.tsx | 10 | ||||
| -rw-r--r-- | packages/app/src/utils/time.ts | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/packages/app/src/components/dialog-select-file.tsx b/packages/app/src/components/dialog-select-file.tsx index 36448dd3e..8e221577b 100644 --- a/packages/app/src/components/dialog-select-file.tsx +++ b/packages/app/src/components/dialog-select-file.tsx @@ -15,6 +15,7 @@ import { useLayout } from "@/context/layout" import { useFile } from "@/context/file" import { useLanguage } from "@/context/language" import { decode64 } from "@/utils/base64" +import { getRelativeTime } from "@/utils/time" type EntryType = "command" | "file" | "session" @@ -30,6 +31,7 @@ type Entry = { directory?: string sessionID?: string archived?: number + updated?: number } type DialogSelectFileMode = "all" | "files" @@ -120,6 +122,7 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil title: string description: string archived?: number + updated?: number }): Entry => ({ id: `session:${input.directory}:${input.id}`, type: "session", @@ -129,6 +132,7 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil directory: input.directory, sessionID: input.id, archived: input.archived, + updated: input.updated, }) const list = createMemo(() => allowed().map(commandItem)) @@ -214,6 +218,7 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil description, directory, archived: s.time?.archived, + updated: s.time?.updated, })), ) .catch(() => [] as { id: string; title: string; description: string; directory: string; archived?: number }[]) @@ -384,6 +389,11 @@ export function DialogSelectFile(props: { mode?: DialogSelectFileMode; onOpenFil </Show> </div> </div> + <Show when={item.updated}> + <span class="text-12-regular text-text-weak whitespace-nowrap ml-2"> + {getRelativeTime(new Date(item.updated!).toISOString())} + </span> + </Show> </div> </Match> </Switch> diff --git a/packages/app/src/utils/time.ts b/packages/app/src/utils/time.ts new file mode 100644 index 000000000..ac709d86d --- /dev/null +++ b/packages/app/src/utils/time.ts @@ -0,0 +1,14 @@ +export function getRelativeTime(dateString: string): string { + const date = new Date(dateString) + const now = new Date() + const diffMs = now.getTime() - date.getTime() + const diffSeconds = Math.floor(diffMs / 1000) + const diffMinutes = Math.floor(diffSeconds / 60) + const diffHours = Math.floor(diffMinutes / 60) + const diffDays = Math.floor(diffHours / 24) + + if (diffSeconds < 60) return "Just now" + if (diffMinutes < 60) return `${diffMinutes}m ago` + if (diffHours < 24) return `${diffHours}h ago` + return `${diffDays}d ago` +} |
