fix(configure): seed the chosen model into the agents' saved selection - #229
Merged
Conversation
Dropping the top-level `model` pin (#221) relied on the chosen model leading the models map, but map order never carried the choice: with no pin and no saved selection the OpenCode-family TUI falls back to the first provider in its list — upstream's hosted Zen provider, which self-registers ahead of config providers — so a fresh install started on "Big Pickle · OpenCode Zen" instead of the gateway (and, within a provider, the server's own sort picks the model, not the map). Write the install-time choice where the TUI actually reads it: the state dir's model.json `recent` list, its highest-priority startup source after a config pin. Seed only when the recents list is empty or absent — this writer also runs on every gateway-key auto-refresh and `codevhub model`, and a non-empty list is a selection the user already made that must keep winning. Favorites/variants are carried over, a corrupt state file is replaced, and any filesystem failure is swallowed (the seed is a nicety; the config write already succeeded). Counterpart to codev-code#144, which fixes the TUI-side fallback to skip the Zen registration; either alone fixes the visible default, this one additionally makes the wizard's chosen model stick. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#221 dropped the top-level
modelpin from the OpenCode/CoDev Code configs so in-CLI/modelsswitches would stop reverting on restart, relying on the chosen model leading the models map to carry the first-launch default. That assumption never held: the map's order isn't read anywhere. With no pin and no saved selection, the OpenCode-family TUI falls back to the first provider in its list — upstream's hosted Zen provider, which self-registers (its free models need no auth) ahead of config-only providers — so a freshcodevhub installstarted on Big Pickle · OpenCode Zen instead of the gateway. And even within the right provider, the server's own model sort decides, not the map order (which is why a netgate fallback lands on the id-sort winner, not the wizard's choice).Fix
configureOpenCodeKindnow writes the install-time choice where the TUI actually reads it: the agent's XDG state dirmodel.jsonrecentlist (~/.local/state/{opencode,codev}/model.json) — the TUI's highest-priority startup source once the config carries no pin. A later in-CLI switch simply displaces it.Guardrails:
refresh.ts) andcodevhub model; a non-empty list is a selection the user already made and must keep winning (the exact behavior fix(configure): stop pinning a default model for OpenCode and CoDev Code #221 was protecting).Tests
7 new tests in
tests/lib/configure.test.ts: fresh seed for both kinds (correct per-app state dir),XDG_STATE_HOMEhonored, non-empty recents never overridden, empty-recents seed preserves favorites/variants, corrupt file replaced, manual-path provider id used. Shared setup now clearsXDG_STATE_HOMEso a host exporting it can't leak test writes into a real state dir.pnpm fix/typecheck/test(1292 passed) /build+ Node smoke all green.Relation to codev-code#144
Counterpart to codev-code#144, which fixes the TUI-side fallback to skip the Zen registration. Either alone fixes the visible Zen default; this one additionally makes the wizard's chosen model actually stick as the first-launch default.
🤖 Generated with Claude Code