Skip to content

fix(opencode): scope TUI variant state per agent#18013

Open
CptnKirk wants to merge 4 commits intoanomalyco:devfrom
CptnKirk:fix/tui-agent-variant-state
Open

fix(opencode): scope TUI variant state per agent#18013
CptnKirk wants to merge 4 commits intoanomalyco:devfrom
CptnKirk:fix/tui-agent-variant-state

Conversation

@CptnKirk
Copy link
Copy Markdown

Issue for this PR

Closes #13718
Refs #16034

Type of change

  • Bug fix

What does this PR do?

Fixes a TUI bug where persisted variant selections were keyed by provider/model, so agents that shared a model could inherit a stale variant selection from each other.

This changes TUI variant persistence to use agent-scoped keys instead, and resolves the active variant as selected > configured > none. Obsolete legacy provider/model entries are ignored on load and removed on the next save.

How this relates to #16034

This proposed PR fixes the #13718 persistence-keying bug by storing TUI variant state per agent instead of per provider/model.

#16034 describes the broader symptom. #16032 approaches it by reapplying configured variants during agent/session switching; this proposed PR addresses the underlying cross-agent persistence collision instead.

How did you verify your code works?

Added unit tests in packages/opencode/test/cli/tui/model-variant.test.ts covering:

  • legacy key filtering
  • configured variant precedence
  • cycling behavior from configured and explicit default states

Screenshots / recordings

N/A

Checklist

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

@null-axiom
Copy link
Copy Markdown

I am experiencing the same issue this PR will fix. I am switching between plan and build agents, but the problem is that I cannot persist a variant exclusive to each agent, it currently shares the variant when switching between agents.

@tarurar
Copy link
Copy Markdown

tarurar commented Apr 28, 2026

Guys, please review and merge the PR, it fixes real bug.

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.

Build variant in config gets ignored by TUI due persisted per-model variant state

3 participants