fix(desktop): reseed new chats from profile defaults - #67207
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing a real Desktop precedence bug. The current fresh-draft path calls a non-forced refresh at apps/desktop/src/app/contrib/hooks/use-background-sync.ts:129-136, while refreshCurrentModel() preserves persisted manual state at apps/desktop/src/app/session/hooks/use-model-controls.ts:61-63.
Problems
- The new
refreshCurrentModel(true)call can overwrite a newer picker selection.forcebypasses the manual-state guards before and aftergetGlobalModelInfo()(apps/desktop/src/app/session/hooks/use-model-controls.ts:61-80), so a manual no-session pick made while the request is pending is replaced when it resolves. This conflicts with the Desktop stale-result invariant inapps/desktop/AGENTS.md:68-70.
Suggested changes
- Guard the forced result with a selection/draft generation (or an equivalent initial-state snapshot) and add a deferred-request regression test proving a post-start manual pick wins.
Automated hermes-sweeper review.
| useEffect(() => { | ||
| if (gatewayState === 'open' && !activeSessionId && freshDraftReady) { | ||
| void refreshCurrentModel() | ||
| void refreshCurrentModel(true) |
There was a problem hiding this comment.
force bypasses both manual-selection checks in use-model-controls.ts:61,67; because the global-model lookup is async, a picker selection made after this call starts can be overwritten by its later result. Please tag this refresh with a draft/selection generation (and add a deferred-result test) so newer manual intent wins.
|
Carried this forward in #67291 (your commit preserved via The gap teknium1 flagged is real: Fix in #67291: a monotonic manual-pick token in Green: full |
|
Thanks @deniqlab — and good instinct on the precedence question. After weighing the UX, we're going to keep the sticky-last-pick behavior rather than reseed new chats to the profile default. The reasoning: switching between existing chats is session-scoped and unaffected, so this only changes the new-chat (Cmd+N) boundary — and resetting a deliberate manual pick there is worse for the "I switched models on purpose, keep it" workflow than seeding from the default is worth. Sticky-last-choice is what most editors/browsers do. The genuine bug behind #65300 / #58498 — a removed or default-derived model (owl-alpha) lingering and overriding config.yaml — is already fixed on Closing this (and my rebase #67291) as intended-behavior. If a manually picked model later gets removed and 404s on new chats, that's a narrow separate edge worth a "fall back to default when the pick is no longer available" guard — happy to take that if it comes up. Appreciate the contribution. |
Refs #65300\n\n## Summary\n- Force reseed the composer model/provider when a fresh new-chat draft becomes ready.\n- Keep live-session model selection sticky for active runtimes.\n- Add focused tests for fresh-draft reseeding and model-control refresh behavior.\n\n## Verification\n- vitest run --project ui src/app/session/hooks/use-model-controls.test.tsx src/app/contrib/hooks/use-background-sync.test.tsx\n- git diff --check\n- npm run typecheck (blocked by unrelated missing module/type errors in this worktree environment)