Skip to content

fix(app): prevent session model overwrite on tab switch#35898

Open
lbklb wants to merge 1 commit into
anomalyco:devfrom
lbklb:fix-session-model-isolation
Open

fix(app): prevent session model overwrite on tab switch#35898
lbklb wants to merge 1 commit into
anomalyco:devfrom
lbklb:fix-session-model-isolation

Conversation

@lbklb

@lbklb lbklb commented Jul 8, 2026

Copy link
Copy Markdown

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

Issue for this PR

Closes #35899

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

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
@lbklb lbklb requested review from Brendonovich and Hona as code owners July 8, 2026 11:17
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@hqy2435662352

Copy link
Copy Markdown

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:

  • OS: Windows 10 Pro 22H2 (build 19045)
  • OpenCode Desktop built from source with OPENCODE_CHANNEL=prod

Thanks for the fix!

@chennest

Copy link
Copy Markdown

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web: switching sessions overwrites user-selected model with agent default

3 participants