The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): /timestamps keeps its window override across config refreshes
Teknium6acaee605a4f
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsxindex a1d9e601a65..324bf0f63df 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsx@@ -1,4 +1,4 @@-import { cleanup } from '@testing-library/react'+import { act, cleanup, renderHook } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { toChatMessages } from '@/lib/chat-messages'@@ -6,6 +6,8 @@ import { resolveDesktopCommand } from '@/lib/desktop-slash-commands'import { $connection } from '@/store/session'import { dropSessionState } from '@/store/session-states'+import { useHermesConfig } from '../use-hermes-config'+import { actRender, Harness, type HarnessHandle, RUNTIME_SESSION_ID } from './index-test-utils'import { clearSingleFlightSessionResumeState } from './single-flight-resume'import { formatHistory } from './slash-desktop-commands'@@ -16,6 +18,8 @@ import { formatHistory } from './slash-desktop-commands'vi.mock('@/hermes', () => ({getLatestSessionMessages: vi.fn(async () => ({ messages: [], session_id: 'session' })),getProfiles: vi.fn(async () => ({ profiles: [] })),+ getHermesConfig: vi.fn(async () => ({ display: { timestamps: false } })),+ getHermesConfigDefaults: vi.fn(async () => ({})),getSession: vi.fn(),PROMPT_SUBMIT_REQUEST_TIMEOUT_MS: 1_800_000,setApiRequestProfile: vi.fn(),@@ -390,6 +394,21 @@ describe('/timestamps, /palette, /worktree, /snapshot', () => {expect(renderedText(handle)).toMatch(/timestamps: off/i)})+ it('/timestamps is a window override that survives an ordinary config refresh', async () => {+ const { $displayTimestamps } = await import('@/store/display-timestamps')+ $displayTimestamps.set(false)+ const config = renderHook(() => useHermesConfig({ activeSessionIdRef: { current: RUNTIME_SESSION_ID } }))+ const handle = await mount(gateway(() => undefined))++ await handle.submitText('/timestamps on')+ await act(async () => {+ await config.result.current.refreshHermesConfig()+ })++ expect($displayTimestamps.get()).toBe(true)+ await handle.submitText('/timestamps off')+ })+it('/palette opens the desktop command palette', async () => {const { $commandPaletteOpen } = await import('@/store/command-palette')$commandPaletteOpen.set(false)diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.tsindex 96992219210..63ad36c4029 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.ts+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.ts@@ -1,7 +1,7 @@import { chatMessageText, toChatMessages } from '@/lib/chat-messages'import { isMissingRpcMethod } from '@/lib/gateway-rpc'import { openCommandPalette } from '@/store/command-palette'-import { $displayTimestamps } from '@/store/display-timestamps'+import { $displayTimestamps, setDisplayTimestampsWindowOverride } from '@/store/display-timestamps'import { runExportProfileFlow, runImportProfileFlow } from '@/store/profile-share'import { $connection } from '@/store/session'import type { SessionMessage } from '@/types/hermes'@@ -431,7 +431,7 @@ export function desktopReadCommandHandlers<C extends { arg: string }>(env: Desktreturn out?.render('usage: /timestamps [on|off|status]')}- $displayTimestamps.set(next)+ setDisplayTimestampsWindowOverride(next)if (word === 'status') {const out = await env.withSlashOutput(ctx)diff --git a/apps/desktop/src/store/display-timestamps.ts b/apps/desktop/src/store/display-timestamps.tsindex 75e30673f98..72adae0f454 100644--- a/apps/desktop/src/store/display-timestamps.ts+++ b/apps/desktop/src/store/display-timestamps.ts@@ -15,6 +15,15 @@ import { atom } from 'nanostores'export const $displayTimestamps = atom<boolean>(false)+// `/timestamps` is a this-window choice: it outranks the config default until the window closes,+// so a routine config refresh does not undo it.+let windowOverride: boolean | null = null+export function setDisplayTimestampsFromConfig(value: unknown): void {- $displayTimestamps.set(value === true || value === 'true' || value === 1)+ $displayTimestamps.set(windowOverride ?? (value === true || value === 'true' || value === 1))+}++export function setDisplayTimestampsWindowOverride(value: boolean): void {+ windowOverride = value+ $displayTimestamps.set(value)}