The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): gate cold-start restore on display.resume_last_session
Teknium648c664eb33d
diff --git a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsxindex 5dd54083cff..8bc399e67fb 100644--- a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx+++ b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.test.tsx@@ -80,6 +80,8 @@ describe('useDesktopIntegrations', () => {locationPathname = '/',profileReady = false,resumeExhaustedSessionId = null as string | null,+ // null = config record still loading (the hook takes undefined; null dodges the destructuring default).+ resumeLastSession = true as boolean | null,routedSessionId = null as string | null,sessions = [] as readonly SessionInfo[]} = {}) {@@ -89,6 +91,7 @@ describe('useDesktopIntegrations', () => {locationPathname,profileReady,resumeExhaustedSessionId,+ resumeLastSession,routedSessionId,sessions}: {@@ -96,6 +99,7 @@ describe('useDesktopIntegrations', () => {locationPathname: stringprofileReady: booleanresumeExhaustedSessionId: string | null+ resumeLastSession: boolean | nullroutedSessionId: string | nullsessions: readonly SessionInfo[]}) =>@@ -108,6 +112,7 @@ describe('useDesktopIntegrations', () => {profileReady,refreshSessions: vi.fn(),resumeExhaustedSessionId,+ resumeLastSession: resumeLastSession ?? undefined,routedSessionId,runtimeIdByStoredSessionId: { current: new Map() },sessions@@ -118,6 +123,7 @@ describe('useDesktopIntegrations', () => {locationPathname,profileReady,resumeExhaustedSessionId,+ resumeLastSession,routedSessionId,sessions}@@ -171,6 +177,7 @@ describe('useDesktopIntegrations', () => {locationPathname: '/',profileReady: true,resumeExhaustedSessionId: null,+ resumeLastSession: true,routedSessionId: null,sessions: [session({ id: 'remembered-session', profile: 'default' })]})@@ -179,6 +186,53 @@ describe('useDesktopIntegrations', () => {})})+ describe('display.resume_last_session', () => {+ it('stays on the fresh chat when the setting is off, and keeps remembering the open chat', () => {+ window.localStorage.setItem('hermes.desktop.lastRoute.profile.default', '/remembered-session')+ window.localStorage.setItem('hermes.desktop.lastSessionId.profile.default', 'remembered-session')++ const sessions = [session({ id: 'remembered-session', profile: 'default' })]+ const result = render({ profileReady: true, resumeLastSession: false, sessions })++ expect(navigate).not.toHaveBeenCalled()++ // The user opens another chat: it is still remembered for the next launch+ // (and for notifications), so flipping the switch back on resumes it.+ result.rerender({+ activeProfile: 'default',+ locationPathname: '/other-session',+ profileReady: true,+ resumeExhaustedSessionId: null,+ resumeLastSession: false,+ routedSessionId: 'other-session',+ sessions: [...sessions, session({ id: 'other-session', profile: 'default' })]+ })++ expect(window.localStorage.getItem('hermes.desktop.lastSessionId.profile.default')).toBe('other-session')+ })++ it('holds the restore until the config record answers, then restores when on', () => {+ window.localStorage.setItem('hermes.desktop.lastSessionId.profile.default', 'remembered-session')++ const sessions = [session({ id: 'remembered-session', profile: 'default' })]+ const result = render({ profileReady: true, resumeLastSession: null, sessions })++ expect(navigate).not.toHaveBeenCalled()++ result.rerender({+ activeProfile: 'default',+ locationPathname: '/',+ profileReady: true,+ resumeExhaustedSessionId: null,+ resumeLastSession: true,+ routedSessionId: null,+ sessions+ })++ expect(navigate).toHaveBeenCalledWith('/remembered-session', { replace: true })+ })+ })+describe('ownership validation', () => {it('refuses to restore a session route owned by another profile', () => {window.localStorage.setItem('hermes.desktop.lastRoute.profile.default', '/ai-session')@@ -329,6 +383,7 @@ describe('useDesktopIntegrations', () => {locationPathname: '/ops-session',profileReady: true,resumeExhaustedSessionId: null,+ resumeLastSession: true,routedSessionId: 'ops-session',sessions})@@ -395,6 +450,7 @@ describe('useDesktopIntegrations', () => {locationPathname: '/settings',profileReady: true,resumeExhaustedSessionId: null,+ resumeLastSession: true,routedSessionId: null,sessions: []})diff --git a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.ts b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.tsindex 132dffe6564..6d8cef2ec16 100644--- a/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.ts+++ b/apps/desktop/src/app/contrib/hooks/use-desktop-integrations.ts@@ -41,6 +41,8 @@ interface DesktopIntegrationsParams {navigate: (to: string, options?: { replace?: boolean }) => voidprofileReady: booleanrefreshSessions: () => Promise<unknown> | unknown+ /** `display.resume_last_session`; `undefined` while the config record is still loading. */+ resumeLastSession: boolean | undefinedresumeExhaustedSessionId: null | stringroutedSessionId: null | stringruntimeIdByStoredSessionId: { readonly current: Map<string, string> }@@ -60,6 +62,7 @@ export function useDesktopIntegrations({navigate,profileReady,refreshSessions,+ resumeLastSession,resumeExhaustedSessionId,routedSessionId,runtimeIdByStoredSessionId,@@ -110,6 +113,20 @@ export function useDesktopIntegrations({// Only cold-start navigation at the default route is replaceable; a deep// link or hidden-then-shown window keeps its explicit destination.if (locationPathname === NEW_CHAT_ROUTE) {+ // display.resume_last_session (#60812): hold the latch until the config+ // record answers, then either restore below or stay on the fresh chat.+ // Remembered ids keep being written either way, so flipping the switch+ // back on resumes from the very next launch.+ if (resumeLastSession === undefined) {+ return+ }++ if (!resumeLastSession) {+ restoredRef.current = true++ return+ }+const route = getRememberedRoute(activeProfile)const routeSession = route ? routeSessionId(route) : nullconst last = getRememberedSessionId(activeProfile)@@ -168,7 +185,7 @@ export function useDesktopIntegrations({} else if (!routedSessionId && !isOverlayView(appViewForPath(locationPathname))) {setRememberedRoute(locationPathname, activeProfile)}- }, [activeProfile, locationPathname, navigate, profileReady, routedSessionId, sessions])+ }, [activeProfile, locationPathname, navigate, profileReady, resumeLastSession, routedSessionId, sessions])useEffect(() => {if (!profileReady || !resumeExhaustedSessionId) {diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex 03fdf6de9c9..c80edb0cfa8 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -93,6 +93,7 @@ import { CommandPalette } from '../command-palette'import { triggerAndRefreshCronJobs } from '../cron/cron-actions'import { useGatewayBoot } from '../gateway/hooks/use-gateway-boot'import { useGatewayRequest } from '../gateway/hooks/use-gateway-request'+import { useHermesConfigRecord } from '../hooks/use-config-record'import { useKeybinds } from '../hooks/use-keybinds'import { useHudHandoff } from '../hud/handoff'import { ModelPickerOverlay } from '../model-picker-overlay'@@ -842,6 +843,15 @@ export function ContribWiring({ children }: { children: ReactNode }) {// remembered-session restore, and cross-window session-list sync.const previewTarget = useStore($previewTarget)+ // display.resume_last_session gates the cold-start restore. `undefined` while+ // the record is still loading holds the restore latch open; a failed fetch+ // falls back to the historical behavior (resume).+ const configRecord = useHermesConfigRecord()++ const resumeLastSession = configRecord.isPending+ ? undefined+ : (configRecord.data?.display as { resume_last_session?: unknown } | undefined)?.resume_last_session !== false+useDesktopIntegrations({activeProfile: normalizeProfileKey(activeGatewayProfile),chatOpen,@@ -850,6 +860,7 @@ export function ContribWiring({ children }: { children: ReactNode }) {navigate,profileReady: boot.phase === 'renderer.ready',refreshSessions,+ resumeLastSession,resumeExhaustedSessionId,routedSessionId,runtimeIdByStoredSessionId: runtimeIdByStoredSessionIdRef,diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsxindex c007ea937b2..64c3be3245a 100644--- a/apps/desktop/src/app/settings/appearance-settings.tsx+++ b/apps/desktop/src/app/settings/appearance-settings.tsx@@ -7,6 +7,7 @@ import { LanguageSwitcher } from '@/components/language-switcher'import { Button } from '@/components/ui/button'import { SegmentedControl } from '@/components/ui/segmented-control'import type { DesktopMarketplaceSearchItem } from '@/global'+import { saveHermesConfig } from '@/hermes'import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'import { Check, Download, Loader2, Palette, Trash2 } from '@/lib/icons'@@ -17,6 +18,7 @@ import { $backdrop, setBackdrop } from '@/store/backdrop'import { $composerPopoutGesturesEnabled, setComposerPopoutGesturesEnabled } from '@/store/composer-popout'import { $embedAllowed, $embedMode, clearEmbedAllowed, type EmbedMode, setEmbedMode } from '@/store/embed-consent'import { $introSplash, setIntroSplash } from '@/store/intro-splash'+import { notifyError } from '@/store/notifications'import { $activeGatewayProfile, $profiles, normalizeProfileKey } from '@/store/profile'import { $reactionsEnabled, setReactionsEnabled } from '@/store/reactions-enabled'import { $reasoningCollapsedByDefault, setReasoningCollapsedByDefault } from '@/store/reasoning-disclosure'@@ -53,13 +55,57 @@ import { installVscodeThemeFromMarketplace } from '@/themes/install'import type { DesktopTheme } from '@/themes/types'import { $marketplaceInstalls, isUserTheme, removeUserTheme } from '@/themes/user-themes'+import { setHermesConfigCache, useHermesConfigRecord } from '../hooks/use-config-record'+import { MODE_OPTIONS } from './constants'+import { setNested } from './helpers'import { PetSettings } from './pet-settings'import { ListRow, SectionHeading, SettingsContent, ToggleRow } from './primitives'import { APPEARANCE_SETTING_IDS } from './settings-search'import { TerminalFontSetting } from './terminal-font-setting'import { useDeepLinkHighlight } from './use-deep-link-highlight'+// display.resume_last_session lives in the backend config record (shared with+// config.yaml and the cold-start restore in use-desktop-integrations), not a+// renderer store. Saves write through the shared react-query cache so the+// restore gate sees the new value on the next launch.+function ResumeLastSessionSetting() {+ const { t } = useI18n()+ const a = t.settings.appearance+ const configQuery = useHermesConfigRecord()+ const config = configQuery.data+ const checked = (config?.display as { resume_last_session?: unknown } | undefined)?.resume_last_session !== false++ const update = (on: boolean) => {+ if (!config) {+ return+ }++ const next = setNested(config, 'display.resume_last_session', on)+ setHermesConfigCache(next)+ void saveHermesConfig(next)+ .then(result => {+ if (!result.ok) {+ throw new Error(t.settings.config.autosaveFailed)+ }+ })+ .catch(error => {+ setHermesConfigCache(config)+ notifyError(error, t.settings.config.autosaveFailed)+ })+ }++ return (+ <ToggleRow+ checked={checked}+ description={a.resumeLastSessionDesc}+ disabled={!config}+ label={a.resumeLastSessionTitle}+ onChange={update}+ />+ )+}+function ThemePreview({ name, mode }: { name: string; mode: 'light' | 'dark' }) {// Preview in the *current* mode: the dark palette in Dark, and the light// palette in Light — synthesizing one for dark-only themes — so every card@@ -742,6 +788,8 @@ export function AppearanceSettings() {onChange={setComposerPopoutGesturesEnabled}/>+ <ResumeLastSessionSetting />+<ListRowaction={<SegmentedControldiff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 225803cd30b..295cc157b00 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -487,6 +487,8 @@ export const ar = defineLocale({embedsAlways: 'دائما',embedsOff: 'إيقاف',embedsReset: count => `إعادة تعيين ${count} ${count === 1 ? 'خدمة مسموح بها' : 'خدمة مسموح بها'}`,+ resumeLastSessionTitle: 'إعادة فتح آخر محادثة عند التشغيل',+ resumeLastSessionDesc: 'متابعة من حيث توقفت عند بدء التطبيق. أوقفه للبدء دائمًا بمحادثة جديدة.',product: 'مبسط',productDesc: 'عرض أنظف يركز على النتيجة.',technical: 'تقني',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex f928ed91655..d9bf0a06db2 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -593,6 +593,8 @@ export const ru = defineLocale({embedsOff: 'Выкл',embedsReset: count =>`Сбросить ${count} ${RU_NOUN(count, 'разрешённый сервис', 'разрешённых сервиса', 'разрешённых сервисов')}`,+ resumeLastSessionTitle: 'Открывать последний чат при запуске',+ resumeLastSessionDesc: 'Продолжайте с того места, где остановились. Выключите, чтобы всегда начинать с нового чата.',product: 'Продукт',productDesc: 'Дружелюбная активность инструментов с краткими сводками.',technical: 'Технический',diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.mdindex 9e2afa1da97..87a4e6f419f 100644--- a/website/docs/user-guide/desktop.md+++ b/website/docs/user-guide/desktop.md@@ -163,6 +163,7 @@ Manage providers, models, tools, and credentials from a real UI instead of editi- **xAI Grok OAuth** — Grok is a first-class OAuth provider in the launcher; sign in through the browser flow like the other OAuth providers.- **Tool-backend installs from the GUI** — run a tool backend's post-setup install steps directly from the app instead of dropping to a terminal.- **Terminal font picker** — choose an installed font in **Settings → Appearance**. Nerd Fonts such as `MesloLGS NF` render Powerlevel10k separators and icons in both interactive and agent terminals; the setting is saved per profile.+- **Reopen Last Chat on Launch** — by default the app picks up where you left off on cold start. Turn it off in **Settings → Appearance** (or set `display.resume_last_session: false` in `config.yaml`) to always begin with a fresh chat. Deep links and explicit destinations are never overridden either way.- **Auxiliary-model warning** — if you switch the main model to a new provider while auxiliary tasks (titling, summarization, and similar helpers) are still pinned to another provider, the app warns you so you don't unknowingly split work across two providers.- **VS Code Marketplace themes** — beyond the built-in theme presets, the appearance settings include a live VS Code Marketplace search: pick any color theme and the app downloads, converts, and installs it as a desktop theme. The same importer is available from the command palette (*Install theme*), and imported themes can be removed again from the appearance settings.- **Keep computer awake** — **Settings → Advanced → Keep computer awake** stops the machine from sleeping so long or overnight agent runs keep going (the display can still dim). This is a per-computer setting.