Skip to content

The agent that grows with you

fix(desktop): re-stamp the effort wire level after a new pick

FroRaut0f85d2367ad8
diff --git a/apps/desktop/src/app/chat/composer/reasoning-pill.test.tsx b/apps/desktop/src/app/chat/composer/reasoning-pill.test.tsx
index ed10f1a4954..2dfbc86ee16 100644
--- a/apps/desktop/src/app/chat/composer/reasoning-pill.test.tsx
+++ b/apps/desktop/src/app/chat/composer/reasoning-pill.test.tsx
@@ -129,6 +129,49 @@ describe('ReasoningPill', () => {
expect(label()).toBe('Max')
})
+ it('re-stamps the wire level when a new pick is confirmed, so an old clamp never sticks', () => {
+ $selectedStoredSessionId.set('stored-1')
+
+ act(() => {
+ // Ultra on the direct Responses route was confirmed as "sends max".
+ publishSessionState('rt-1', {
+ ...createClientSessionState('stored-1'),
+ reasoningEffort: 'ultra',
+ reasoningEffortWire: 'max'
+ })
+ $activeSessionId.set('rt-1')
+ })
+
+ render(
+ <SessionViewProvider value={PRIMARY_SESSION_VIEW}>
+ <ReasoningPill disabled={false} model={modelState()} />
+ </SessionViewProvider>
+ )
+
+ const label = () => screen.getByTestId('reasoning-pill').textContent
+
+ expect(label()).toBe('Ultra→Max')
+
+ // The menu wrote Medium optimistically before this patch existed (old wire kept),
+ // then the gateway confirmed medium/medium: only the wire differs from the state.
+ act(() => {
+ const state = $sessionStates.get()['rt-1']!
+ publishSessionState('rt-1', { ...state, reasoningEffort: 'medium' })
+ })
+ act(() => {
+ const state = $sessionStates.get()['rt-1']!
+
+ publishSessionState(
+ 'rt-1',
+ applySessionInfoStatePatch(
+ state,
+ sessionInfoStatePatch({ reasoning_effort: 'medium', reasoning_effort_wire: 'medium' })
+ )
+ )
+ })
+ expect(label()).toBe('Med')
+ })
+
it('falls back to the profile default once the runtime reports the session has no pin of its own', () => {
$defaultReasoningEffort.set('ultra')
$selectedStoredSessionId.set('stored-1')
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/utils.ts b/apps/desktop/src/app/session/hooks/use-message-stream/utils.ts
index 2cb7db5cfa7..e14409efb7d 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/utils.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/utils.ts
@@ -87,6 +87,9 @@ export function applySessionInfoStatePatch(
(patch.personality === undefined || patch.personality === state.personality) &&
(patch.provider === undefined || patch.provider === state.provider) &&
(patch.reasoningEffort === undefined || patch.reasoningEffort === state.reasoningEffort) &&
+ // The wire level can change alone: an optimistic pick already holds the new
+ // effort, so skipping here kept the previous pick's clamp ("Medium→Max") forever.
+ (patch.reasoningEffortWire === undefined || patch.reasoningEffortWire === state.reasoningEffortWire) &&
(patch.reasoningEffortPending === undefined ||
patch.reasoningEffortPending === Boolean(state.reasoningEffortPending)) &&
(patch.serviceTier === undefined || patch.serviceTier === state.serviceTier) &&
diff --git a/apps/desktop/src/store/model-presets.ts b/apps/desktop/src/store/model-presets.ts
index f2ecc241ec3..1d1bce32d16 100644
--- a/apps/desktop/src/store/model-presets.ts
+++ b/apps/desktop/src/store/model-presets.ts
@@ -75,6 +75,8 @@ export async function applyModelPreset(
} else if (ctx.sessionId) {
sessionTileDelegate()?.updateSession(ctx.sessionId, state => ({
...state,
+ // Like setCurrentReasoningEffort: the wire level belongs to the previous
+ // effort, so it stays unknown until the next session.info re-stamps it.
...(effort !== undefined ? { reasoningEffort: effort, reasoningEffortWire: '' } : {}),
...(fast !== undefined ? { fast } : {})
}))