fix(app): prevent session model overwrite on tab switch#35898
Conversation
Kobalte Select auto-fires onChange when its controlled value prop changes externally (e.g. switching session tabs), which spuriously triggered agent.set/variant.set. The agent's configured default model then overwrote the user-selected model in saved.session[sessionID], causing all sessions in the same workspace to silently revert to the same default model. Three-layer fix: - ui/select.tsx: skip onSelect when new value equals current value - app/prompt-input.tsx: guard all 4 agent/variant onSelect callbacks - app/local.tsx: agent.set preserves prev model/variant when agent unchanged, so even a spurious trigger cannot overwrite user selection
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Tested this patch on Windows 10 Pro 22H2 (build 19045) and can confirm it fixes the issue. Before the patch, switching between sessions would reset the model from the session-specific choice (e.g., deepseek) back to the agent default (kimi). After applying the patch and building the Desktop app with OPENCODE_CHANNEL=prod, session switches now correctly preserve the previously used model. Build / test environment:
Thanks for the fix! |
|
Also hitting this on Desktop — switching sessions silently reverts to agent default model every time. Same root cause as described. Eagerly waiting for this to land, thanks for the fix! |
Kobalte Select auto-fires onChange when its controlled value prop changes externally (e.g. switching session tabs), which spuriously triggered agent.set/variant.set. The agent's configured default model then overwrote the user-selected model in saved.session[sessionID], causing all sessions in the same workspace to silently revert to the same default model.
Three-layer fix:
Issue for this PR
Closes #35899
Type of change
What does this PR do?
切换会话时,模型选择器的 Select 组件会错误触发 onChange,导致 agent.set 把插件配置的默认模型覆盖了用户选的模型。修复了三层:Select 组件本身加守卫、回调处加守卫、agent.set 函数内部也加守卫,确保用户选中的模型不会被覆盖。
Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
在Web应用上测试:两个使用不同模型的会话,反复切换它们,每个会话保留自己的模型。
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.