Skip to content

The agent that grows with you

fix(desktop): paint the cold-resume preview through the transient composer setters

Konstantin Khlopkov7d033d61e464
diff --git a/apps/desktop/src/app/session/hooks/use-model-controls.ts b/apps/desktop/src/app/session/hooks/use-model-controls.ts
index d66fb84dc92..c5b7178fe51 100644
--- a/apps/desktop/src/app/session/hooks/use-model-controls.ts
+++ b/apps/desktop/src/app/session/hooks/use-model-controls.ts
@@ -147,6 +147,15 @@ export function useModelControls({
const staleMoaPick = () => !force && manualPick() && pickProvider().toLowerCase() === 'moa'
+ // A THIRD exception: a manual pick whose provider is EMPTY is never a
+ // coherent selection. It can only come from a persisted preview paint
+ // written before the transient setters existed — an abandoned cold
+ // resume stranded it in localStorage (#125336), and
+ // `desktopSessionCreateParams` then ships the model alone, pairing it
+ // with the unrelated profile provider. Reseed from the profile default
+ // so installs carrying the poisoned row recover on the next launch.
+ const orphanedModelPick = () => !force && manualPick() && pickProvider() === ''
+
// A SECOND exception: a bare provider slug can be a stale spelling of a
// `custom:<key>` profile default (#87035 aliases the two spellings for
// one endpoint). Shipping the bare form resolves the NATIVE provider and
@@ -158,7 +167,7 @@ export function useModelControls({
const maybeSupersededPick = () =>
!force && manualPick() && pickProvider() !== '' && !pickProvider().includes(':')
- if (manualPick() && !force && !staleMoaPick() && !maybeSupersededPick()) {
+ if (manualPick() && !force && !staleMoaPick() && !maybeSupersededPick() && !orphanedModelPick()) {
return
}
@@ -202,6 +211,7 @@ export function useModelControls({
(manualPick() &&
!force &&
!reseedStaleMoa &&
+ !orphanedModelPick() &&
!customDefaultSupersedesPick($currentProvider.get(), result.provider ?? ''))
) {
return
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts
index fb0fe16330f..19583b6497d 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts
+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts
@@ -8,8 +8,12 @@ import { $activeGatewayProfile } from '@/store/profile'
import {
$currentBranch,
$currentCwd,
+ $currentModel,
+ $currentProvider,
setCurrentBranch,
setCurrentCwd,
+ setCurrentModel,
+ setCurrentProvider,
setSelectedStoredSessionId,
workspaceCwdBelongsToSelectedSession
} from '@/store/session'
@@ -2273,3 +2277,32 @@ describe('preserveLocalPendingTurnMessages attachment rewrites (#120978)', () =>
])
})
})
+
+describe('applyStoredSessionPreviewRuntimeInfo does not persist the preview', () => {
+ beforeEach(() => {
+ localStorage.clear()
+ setCurrentModel('user-pick')
+ setCurrentProvider('anthropic')
+ })
+
+ afterEach(() => {
+ localStorage.clear()
+ })
+
+ // The preview is provisional: it paints while session.resume is still in
+ // flight. An abandoned resume never repairs the selection afterwards, so a
+ // persisting paint strands a manual model with an EMPTY provider in
+ // localStorage — every later session.create pairs that model with the
+ // profile provider and fails the coherence gate.
+ it('moves the visible model/provider without persisting them', () => {
+ applyStoredSessionPreviewRuntimeInfo({ cwd: '', model: 'claude-opus-5-5' }, 'session-next')
+
+ // Visible paint happened…
+ expect($currentModel.get()).toBe('claude-opus-5-5')
+ expect($currentProvider.get()).toBe('')
+
+ // …but nothing was persisted: the composer's sticky selection survives.
+ expect(localStorage.getItem('hermes.desktop.composer.model')).toBe('user-pick')
+ expect(localStorage.getItem('hermes.desktop.composer.provider')).toBe('anthropic')
+ })
+})
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
index 9e5993de136..466bca28ba7 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
@@ -35,8 +35,10 @@ import {
setCurrentCwdTransient,
setCurrentFastMode,
setCurrentModel,
+ setCurrentModelTransient,
setCurrentPersonality,
setCurrentProvider,
+ setCurrentProviderTransient,
setCurrentReasoningEffort,
setCurrentReasoningEffortWire,
setCurrentServiceTier,
@@ -2275,8 +2277,15 @@ export function applyStoredSessionPreviewRuntimeInfo(
stored: { cwd?: null | string; model?: null | string } | undefined,
storedSessionId: null | string
) {
- setCurrentModel(stored?.model || '')
- setCurrentProvider('')
+ // Transient: this is a PREVIEW painted while `session.resume` is still in
+ // flight. If the resume is abandoned (user starts a new chat before it
+ // returns, or the row is switched away), nothing repairs the selection
+ // afterwards — persisting these values left the composer holding a manual
+ // model with an EMPTY provider in localStorage, and every later
+ // `session.create` paired that model with the profile provider and failed
+ // the coherence gate (#125336).
+ setCurrentModelTransient(stored?.model || '')
+ setCurrentProviderTransient('')
setCurrentReasoningEffort('')
setCurrentServiceTier('')
setCurrentFastMode(false)