Skip to content

The agent that grows with you

fix(desktop): statusbar timer shows focus-since on tiles and says so

Hermes Agent490037b87d88
diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx
index 6ff80a9b8fa..3c3aa027df9 100644
--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx
+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx
@@ -1,10 +1,17 @@
import { renderHook } from '@testing-library/react'
import type { WritableAtom } from 'nanostores'
-import type { ReactNode } from 'react'
+import { isValidElement, type ReactNode } from 'react'
import { MemoryRouter } from 'react-router'
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { $connection, $currentCwd, $selectedStoredSessionId, $sessions } from '@/store/session'
+import {
+ $connection,
+ $currentCwd,
+ $selectedStoredSessionId,
+ $sessions,
+ $sessionStartedAt,
+ $tileSessionFocusStartedAt
+} from '@/store/session'
import { $focusedTreePaneId as $focusedTreePaneIdMock } from '@/store/session-focus'
import { $sessionTiles } from '@/store/session-states'
@@ -56,6 +63,8 @@ afterEach(() => {
$focusedTreePaneId.set(null)
$selectedStoredSessionId.set(null)
$sessions.set([])
+ $sessionStartedAt.set(null)
+ $tileSessionFocusStartedAt.set(null)
})
describe('statusbar workspace menu — "Open containing folder"', () => {
@@ -88,3 +97,97 @@ describe('statusbar workspace menu — "Open containing folder"', () => {
expect(workspaceMenuIds()).not.toContain('reveal-workspace-finder')
})
})
+
+const statusbarOptions = {
+ agentsOpen: false,
+ chatOpen: true,
+ commandCenterOpen: false,
+ extraLeftItems: [],
+ extraRightItems: [],
+ freshDraftReady: false,
+ gatewayState: 'ready' as const,
+ inferenceStatus: null,
+ openAgents: () => {},
+ openCommandCenterSection: () => {},
+ requestGateway: async () => undefined as never,
+ statusSnapshot: null,
+ toggleCommandCenter: () => {}
+}
+
+function sessionTimerItem() {
+ const { result } = renderHook(() => useStatusbarItems(statusbarOptions), { wrapper })
+
+ return result.current.statusbarItems.find(item => item.id === 'session-timer')
+}
+
+function timerSince(item: ReturnType<typeof sessionTimerItem>): number | null {
+ return isValidElement(item?.detail) ? (item.detail.props.since as number | null) : null
+}
+
+describe('statusbar session timer — focused since (#103123)', () => {
+ const dayOldRowSeconds = 1_700_000_000
+
+ it('uses the primary focus stamp, not the row age, and labels it so a long value is not a turn', () => {
+ $selectedStoredSessionId.set('primary')
+ $sessionStartedAt.set(4_000)
+ $sessions.set([{ id: 'primary', started_at: dayOldRowSeconds }] as never)
+ $focusedTreePaneId.set(null)
+
+ const item = sessionTimerItem()
+
+ expect(timerSince(item)).toBe(4_000)
+ expect(item?.label).toBe('Focused since')
+ expect(item?.title).toMatch(/not how long a turn/)
+ })
+
+ it('stamps tile focus instead of the day-old row, on the same labeled item', () => {
+ const before = Date.now()
+
+ $selectedStoredSessionId.set('primary')
+ $sessionStartedAt.set(4_000)
+ $sessions.set([{ id: 'tile-old', started_at: dayOldRowSeconds }] as never)
+ $focusedTreePaneId.set('session-tile:tile-old')
+
+ const item = sessionTimerItem()
+ const since = timerSince(item)
+
+ expect(since).toBeGreaterThanOrEqual(before)
+ expect(since).toBeLessThanOrEqual(Date.now())
+ expect(since).not.toBe(dayOldRowSeconds * 1000)
+ expect(since).not.toBe(4_000)
+ expect(item?.label).toBe('Focused since')
+ expect(item?.hidden).toBeFalsy()
+ })
+
+ it('re-stamps when the same tile is focused again after primary', () => {
+ const now = vi.spyOn(Date, 'now')
+
+ $selectedStoredSessionId.set('primary')
+ now.mockReturnValue(10_000)
+ $focusedTreePaneId.set('session-tile:tile-old')
+ expect($tileSessionFocusStartedAt.get()).toEqual({ since: 10_000, storedId: 'tile-old' })
+
+ now.mockReturnValue(20_000)
+ $focusedTreePaneId.set(null)
+ expect($tileSessionFocusStartedAt.get()?.since).toBe(10_000)
+
+ now.mockReturnValue(30_000)
+ $focusedTreePaneId.set('session-tile:tile-old')
+ expect($tileSessionFocusStartedAt.get()).toEqual({ since: 30_000, storedId: 'tile-old' })
+
+ now.mockRestore()
+ })
+
+ it('hides the item when a focused tile has no focus stamp', () => {
+ $selectedStoredSessionId.set('primary')
+ $sessionStartedAt.set(4_000)
+ $sessions.set([{ id: 'tile-old', started_at: dayOldRowSeconds }] as never)
+ $focusedTreePaneId.set('session-tile:tile-old')
+ $tileSessionFocusStartedAt.set(null)
+
+ const item = sessionTimerItem()
+
+ expect(timerSince(item)).toBeNull()
+ expect(item?.hidden).toBe(true)
+ })
+})
diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
index 009cb39c8b8..440d25a8e21 100644
--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
@@ -31,6 +31,7 @@ import {
Zap
} from '@/lib/icons'
import { runtimeReadinessDisplay, type RuntimeReadinessResult } from '@/lib/runtime-readiness'
+import { resolveSessionTimerSince } from '@/lib/session-timer-since'
import { cacheHitLabel, contextBarLabel, LiveDuration, tokensPerSecondLabel, usageContextLabel } from '@/lib/statusbar'
import { useStoreSelector } from '@/lib/use-session-slice'
import { cn } from '@/lib/utils'
@@ -52,6 +53,7 @@ import {
$selectedStoredSessionId,
$sessions,
$sessionStartedAt,
+ $tileSessionFocusStartedAt,
$turnStartedAt,
idsShareLineage,
sessionMatchesStoredId
@@ -132,6 +134,7 @@ export function useStatusbarItems({
const primaryUsage = useStore($currentUsage)
const gatewayRestarting = useStore($gatewayRestarting)
const primarySessionStartedAt = useStore($sessionStartedAt)
+ const tileSessionFocusStartedAt = useStore($tileSessionFocusStartedAt)
const primaryTurnStartedAt = useStore($turnStartedAt)
// The indicator must speak the same scope as the Spawn-tree panel it opens:
@@ -205,16 +208,10 @@ export function useStatusbarItems({
const turnStartedAt = primaryFocused ? primaryTurnStartedAt : focusedTurnStartedAt
- // A tile's session-start + cold cwd come from its stored row (the cache only
- // knows runtime state). Only these scalars are read off `$sessions`, so
- // select them — a whole-list `useStore` re-ran the hook on every session-list
- // write (title updates, poll refreshes, archives).
- const focusedRowStartedAt = useStoreSelector($sessions, sessions =>
- focusedStoredSessionId
- ? (sessions.find(s => sessionMatchesStoredId(s, focusedStoredSessionId))?.started_at ?? null)
- : null
- )
-
+ // A tile's cold cwd comes from its stored row (the cache only knows runtime
+ // state). Only these scalars are read off `$sessions`, so select them — a
+ // whole-list `useStore` re-ran the hook on every session-list write (title
+ // updates, poll refreshes, archives).
const focusedRowCwd = useStoreSelector($sessions, sessions => {
if (!focusedStoredSessionId) {
return ''
@@ -275,11 +272,12 @@ export function useStatusbarItems({
const projectTree = useStore($projectTree)
const projectName = useMemo(() => projectNameForCwd(currentCwd), [currentCwd, projectTree])
- const sessionStartedAt = primaryFocused
- ? primarySessionStartedAt
- : focusedRowStartedAt
- ? focusedRowStartedAt * 1000
- : null
+ const sessionStartedAt = resolveSessionTimerSince({
+ focusedStoredSessionId,
+ primaryFocused,
+ primarySessionStartedAt,
+ tileFocus: tileSessionFocusStartedAt
+ })
// The backend only knows a session's MEASURED occupancy once a turn has run
// in this process, so a resumed conversation reports none and the gauge had
@@ -692,7 +690,8 @@ export function useStatusbarItems({
detail: <LiveDuration since={sessionStartedAt} />,
hidden: !sessionStartedAt,
id: 'session-timer',
- label: copy.session,
+ label: copy.focusedSince,
+ title: copy.focusedSinceTitle,
toggleLabel: copy.toggleSessionTimer,
variant: 'text'
},
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index d3a5f26cfde..cb55ac47dad 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -2874,7 +2874,8 @@ export const ar = defineLocale({
openCron: 'فتح المهام المجدولة',
turnRunning: 'الدور يعمل',
contextUsage: 'استخدام السياق',
- session: 'الجلسة',
+ focusedSince: 'منذ التركيز',
+ focusedSinceTitle: 'الوقت منذ تركيز هذه المحادثة — وليس مدة الدور',
yoloOn: 'YOLO مفعل',
yoloOff: 'YOLO معطل',
modelNone: 'لا نموذج',
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index 61b8f68f86e..49dbb46b032 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -5080,7 +5080,8 @@ export const deOverrides = {
title: 'Kontext-Verbrauch',
tokenSummary: (used, max) => `${used} / ${max} Tokens`
},
- session: 'Session',
+ focusedSince: 'Fokussiert seit',
+ focusedSinceTitle: 'Zeit seit dem Fokussieren dieses Chats — nicht die Laufzeit eines Turns',
yoloOn: 'YOLO an — gefährliche Befehle werden automatisch genehmigt. Shift+Klick schaltet global um.',
yoloOff: 'YOLO aus. Shift+Klick schaltet global um.',
modelNone: 'keines',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 433c0c00099..a3b52cef002 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -4625,7 +4625,8 @@ export const en: Translations = {
title: 'Context Usage',
tokenSummary: (used, max) => `${used} / ${max} Tokens`
},
- session: 'Session',
+ focusedSince: 'Focused since',
+ focusedSinceTitle: 'Time since this chat was focused — not how long a turn has been running',
yoloOn: 'YOLO on — auto-approving dangerous commands. Shift+click toggles globally.',
yoloOff: 'YOLO off. Shift+click toggles globally.',
modelNone: 'none',
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index 9c16eeaeffc..1e9bdaff18d 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -5071,7 +5071,8 @@ export const esOverrides = {
title: 'Uso del contexto',
tokenSummary: (used, max) => `${used} / ${max} tokens`
},
- session: 'Sesión',
+ focusedSince: 'Enfocado desde',
+ focusedSinceTitle: 'Tiempo desde que este chat está enfocado — no cuánto lleva un turno',
yoloOn: 'YOLO activado — autoaprobando comandos peligrosos. Shift+clic lo alterna globalmente.',
yoloOff: 'YOLO desactivado. Shift+clic lo alterna globalmente.',
modelNone: 'ninguno',
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index c414f18e017..38d03b07ec8 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -5091,7 +5091,8 @@ export const frOverrides = {
title: 'Utilisation du contexte',
tokenSummary: (used, max) => `${used} / ${max} jetons`
},
- session: 'Session',
+ focusedSince: 'Focalisé depuis',
+ focusedSinceTitle: 'Temps depuis que cette conversation est au premier plan — pas la durée d’un tour',
yoloOn: 'YOLO activé — approbation automatique des commandes dangereuses. Shift+clic pour basculer globalement.',
yoloOff: 'YOLO désactivé. Shift+clic pour basculer globalement.',
modelNone: 'aucun',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 9670bbe8e17..d1a612b254e 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -3364,7 +3364,8 @@ export const ja = defineLocale({
title: 'コンテキスト使用状況',
tokenSummary: (used, max) => `${used} / ${max} Tokens`
},
- session: 'セッション',
+ focusedSince: 'フォーカスしてから',
+ focusedSinceTitle: 'このチャットをフォーカスしてからの時間。ターンの実行時間ではありません',
yoloOn: 'YOLO オン — 危険なコマンドを自動承認中。Shift+クリックで全体に切り替え。',
yoloOff: 'YOLO オフ。Shift+クリックで全体に切り替え。',
modelNone: 'なし',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 9cb5e87ec77..b1d869a8e74 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -3599,7 +3599,8 @@ export const ru = defineLocale({
title: 'Использование контекста',
tokenSummary: (used, max) => `${used} / ${max} токенов`
},
- session: 'Сеанс',
+ focusedSince: 'В фокусе с',
+ focusedSinceTitle: 'Время с момента фокуса этого чата — не длительность хода',
yoloOn: 'YOLO включён — автоматическое подтверждение опасных команд. Shift-клик переключает глобально.',
yoloOff: 'YOLO выключен. Shift-клик переключает глобально.',
modelNone: 'нет',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 78242812f93..94966b3b0ff 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -3897,7 +3897,8 @@ export interface Translations {
title: string
tokenSummary: (used: string, max: string) => string
}
- session: string
+ focusedSince: string
+ focusedSinceTitle: string
yoloOn: string
yoloOff: string
modelNone: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index dc9fd09baf4..d584221093a 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -3559,7 +3559,8 @@ export const zhHant = defineLocale({
title: '上下文使用量',
tokenSummary: (used, max) => `${used} / ${max} Tokens`
},
- session: '工作階段',
+ focusedSince: '聚焦以來',
+ focusedSinceTitle: '自本次聚焦此對話以來的時間,不是回合執行時長',
yoloOn: 'YOLO 已開啟 — 自動核准危險指令。Shift+點擊可全域切換。',
yoloOff: 'YOLO 已關閉。Shift+點擊可全域切換。',
modelNone: '無',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 59772a1b962..e799f20079e 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -4350,7 +4350,8 @@ export const zh = defineLocale({
title: '上下文用量',
tokenSummary: (used, max) => `${used} / ${max} Tokens`
},
- session: '会话',
+ focusedSince: '聚焦以来',
+ focusedSinceTitle: '自本次聚焦该对话以来的时间,不是回合运行时长',
yoloOn: 'YOLO 已开启 — 自动批准危险命令。Shift+点击可全局切换。',
yoloOff: 'YOLO 已关闭。Shift+点击可全局切换。',
modelNone: '无',
diff --git a/apps/desktop/src/lib/session-timer-since.test.ts b/apps/desktop/src/lib/session-timer-since.test.ts
new file mode 100644
index 00000000000..458aacf8538
--- /dev/null
+++ b/apps/desktop/src/lib/session-timer-since.test.ts
@@ -0,0 +1,70 @@
+import { describe, expect, it } from 'vitest'
+
+import { resolveSessionTimerSince, tileFocusStampOnFocusChange } from './session-timer-since'
+
+describe('resolveSessionTimerSince', () => {
+ it('uses the primary focus stamp while the primary surface is focused', () => {
+ expect(
+ resolveSessionTimerSince({
+ focusedStoredSessionId: 'sess-primary',
+ primaryFocused: true,
+ primarySessionStartedAt: 1_000,
+ tileFocus: { since: 9_999, storedId: 'sess-tile' }
+ })
+ ).toBe(1_000)
+ })
+
+ it('uses the tile focus stamp instead of any other clock (#103123)', () => {
+ expect(
+ resolveSessionTimerSince({
+ focusedStoredSessionId: 'sess-tile',
+ primaryFocused: false,
+ primarySessionStartedAt: 1_000,
+ tileFocus: { since: 5_000, storedId: 'sess-tile' }
+ })
+ ).toBe(5_000)
+ })
+
+ it('hides the timer when the tile stamp belongs to a different session', () => {
+ expect(
+ resolveSessionTimerSince({
+ focusedStoredSessionId: 'sess-b',
+ primaryFocused: false,
+ primarySessionStartedAt: 1_000,
+ tileFocus: { since: 5_000, storedId: 'sess-a' }
+ })
+ ).toBeNull()
+ })
+
+ it('hides the timer when a tile is focused but not yet stamped', () => {
+ expect(
+ resolveSessionTimerSince({
+ focusedStoredSessionId: 'sess-tile',
+ primaryFocused: false,
+ primarySessionStartedAt: 1_000,
+ tileFocus: null
+ })
+ ).toBeNull()
+ })
+})
+
+describe('tileFocusStampOnFocusChange', () => {
+ it('stamps focus time when a tile gains focus', () => {
+ expect(tileFocusStampOnFocusChange('sess-a', 'sess-primary', 42)).toEqual({
+ since: 42,
+ storedId: 'sess-a'
+ })
+ })
+
+ it('re-stamps when focus moves to a sibling tile', () => {
+ expect(tileFocusStampOnFocusChange('sess-b', 'sess-primary', 99)).toEqual({
+ since: 99,
+ storedId: 'sess-b'
+ })
+ })
+
+ it('does not stamp while primary is focused, so a later return can re-stamp', () => {
+ expect(tileFocusStampOnFocusChange('sess-primary', 'sess-primary', 99)).toBeNull()
+ expect(tileFocusStampOnFocusChange(null, 'sess-primary', 99)).toBeNull()
+ })
+})
diff --git a/apps/desktop/src/lib/session-timer-since.ts b/apps/desktop/src/lib/session-timer-since.ts
new file mode 100644
index 00000000000..2fa233021da
--- /dev/null
+++ b/apps/desktop/src/lib/session-timer-since.ts
@@ -0,0 +1,50 @@
+/**
+ * Statusbar timer contract (#103123): both surfaces show "focused since".
+ * Primary stamps `$sessionStartedAt` on every switch; tiles used to read the
+ * row's durable `started_at`, so a day-old tile jumped to 23:03:00. The item is
+ * labeled "Focused since" so a long value doesn't read as a stuck turn.
+ */
+
+export interface TileSessionFocusStamp {
+ since: number
+ storedId: string
+}
+
+/** Pick the LiveDuration `since` for the statusbar Session item. Never row age. */
+export function resolveSessionTimerSince(input: {
+ focusedStoredSessionId: null | string
+ primaryFocused: boolean
+ primarySessionStartedAt: number | null
+ tileFocus: null | TileSessionFocusStamp
+}): number | null {
+ if (input.primaryFocused) {
+ return input.primarySessionStartedAt
+ }
+
+ const focused = input.focusedStoredSessionId
+ const tile = input.tileFocus
+
+ if (!focused || !tile || tile.storedId !== focused) {
+ return null
+ }
+
+ return tile.since
+}
+
+/**
+ * Stamp "focused since" when a non-primary tile is the focused surface.
+ * Returns null while primary is focused so the caller leaves the previous
+ * stamp alone. Each focus change re-stamps; do not keep a stamp across a
+ * detour to primary and back.
+ */
+export function tileFocusStampOnFocusChange(
+ focusedStoredSessionId: null | string,
+ selectedStoredSessionId: null | string,
+ now: number
+): null | TileSessionFocusStamp {
+ if (!focusedStoredSessionId || focusedStoredSessionId === selectedStoredSessionId) {
+ return null
+ }
+
+ return { since: now, storedId: focusedStoredSessionId }
+}
diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.ts
index b3fbb29ced1..c7923c19b60 100644
--- a/apps/desktop/src/store/session-states.ts
+++ b/apps/desktop/src/store/session-states.ts
@@ -34,6 +34,7 @@ import { resolveRememberedActivePane, workspaceScopeKey } from '@/components/pan
import type { WorkspaceMode } from '@/contrib/types'
import type { ChatMessage } from '@/lib/chat-messages'
import type { ErrorSurface } from '@/lib/error-surface'
+import { tileFocusStampOnFocusChange } from '@/lib/session-timer-since'
import { stableArray } from '@/lib/stable-array'
import { readJson, writeJson } from '@/lib/storage'
import type { SessionInfo } from '@/types/hermes'
@@ -63,7 +64,8 @@ import {
setActiveSessionStoredIdRotation,
setAwaitingResponse,
setBusy,
- setSessions
+ setSessions,
+ setTileSessionFocusStartedAt
} from './session'
import { secondaryProfileOwnerForEvent } from './session-event-provenance'
import { $focusedTreePaneId } from './session-focus'
@@ -2510,6 +2512,17 @@ export const $focusedSessionState = computed([$focusedRuntimeId, $sessionStates]
export const selectionHomesToWorkspace = (selected: null | string, tiles: readonly SessionTile[]): boolean =>
!(selected && tiles.some(t => t.storedSessionId === selected))
+// Statusbar timer: stamp "focused since" for non-primary tiles so they share
+// the primary's contract instead of the row's durable started_at (#103123).
+// Primary focus leaves the stamp alone; the next tile focus re-stamps.
+function stampTileSessionFocus(focused: null | string) {
+ const stamp = tileFocusStampOnFocusChange(focused, $selectedStoredSessionId.get(), Date.now())
+
+ if (stamp) {
+ setTileSessionFocusStartedAt(stamp)
+ }
+}
+
// Bringing a finished session to the front clears its green dot. Keyed on the
// FOCUSED session, not the selected one: a tile is never $selectedStoredSessionId,
// and a tile tab click goes through activateTreePane rather than focusOpenSession,
@@ -2522,8 +2535,12 @@ $focusedStoredSessionId.listen(focused => {
markSessionRead(focused)
ackStoredSessionId(focused)
}
+
+ stampTileSessionFocus(focused)
})
+stampTileSessionFocus($focusedStoredSessionId.get())
+
// Cold-start restore is the one selection change that is NOT a navigation: the
// route already pointed at the primary session before the window loaded, and
// homing on it would front the workspace tab over the PERSISTED active tab —
diff --git a/apps/desktop/src/store/session.ts b/apps/desktop/src/store/session.ts
index ec7bde884a1..5fe728f9863 100644
--- a/apps/desktop/src/store/session.ts
+++ b/apps/desktop/src/store/session.ts
@@ -12,6 +12,7 @@ import {
rescopeConnectionScopedStores
} from '@/lib/connection-scoped'
import { isMessagingSource } from '@/lib/session-source'
+import type { TileSessionFocusStamp } from '@/lib/session-timer-since'
import { persistBoolean, persistString, readJson, storedBoolean, storedString, writeJson } from '@/lib/storage'
import type { SessionInfo, UsageStats } from '@/types/hermes'
@@ -1336,6 +1337,9 @@ export const $currentUsage = atom<UsageStats>({
total: 0
})
export const $sessionStartedAt = atom<number | null>(null)
+// $sessionStartedAt is primary-only; tiles get their own "focused since" stamp
+// for the statusbar timer (#103123), set when a tile becomes the focused surface.
+export const $tileSessionFocusStartedAt = atom<null | TileSessionFocusStamp>(null)
export const $turnStartedAt = atom<number | null>(null)
export const $introPersonality = atom('')
export const $currentPersonality = atom('')
@@ -1715,6 +1719,8 @@ export const workspaceCwdForNewSession = (): string => {
export const setCurrentBranch = (next: Updater<string>) => updateAtom($currentBranch, next)
export const setCurrentUsage = (next: Updater<UsageStats>) => updateAtom($currentUsage, next)
export const setSessionStartedAt = (next: Updater<number | null>) => updateAtom($sessionStartedAt, next)
+export const setTileSessionFocusStartedAt = (next: Updater<null | TileSessionFocusStamp>) =>
+ updateAtom($tileSessionFocusStartedAt, next)
export const setTurnStartedAt = (next: Updater<number | null>) => updateAtom($turnStartedAt, next)
export const setIntroPersonality = (next: Updater<string>) => updateAtom($introPersonality, next)
export const setCurrentPersonality = (next: Updater<string>) => updateAtom($currentPersonality, next)