Skip to content

fix(configure): stop pinning a default model for OpenCode and CoDev Code - #221

Merged
quickbeard merged 1 commit into
mainfrom
unpin-opencode-model
Jul 30, 2026
Merged

quickbeard merged 1 commit into
mainfrom
unpin-opencode-model

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Why

Per the install docs, the model choice exists for the tools that can't switch:

OpenCode lets you switch models freely inside the CLI, but Claude Code and Codex don't — they only let you replace the proprietary Anthropic/OpenAI model with a single one.

configureOpenCodeKind nevertheless wrote that choice into ~/.config/opencode/opencode.json and ~/.config/codev/codev.jsonc as a top-level "model": "<provider>/<id>". That key outranks the in-CLI selection on every launch — OpenCode resolves config model before the recent models in its state dir — so every /models switch silently reverted on restart, and the only fix was hand-editing the config. All three writer paths reapplied it: codevhub install, codevhub model, and the gateway-key auto-refresh in refresh.ts.

What changed

  • configureOpenCodeKind no longer writes model. Claude Code, Codex, and Continue are untouched — the model choice still works exactly as documented for them.
  • The chosen model now leads the provider's models map ([defaultModel, ...creds.models], deduped). With no pin, a launch with nothing selected falls through to the provider's first model, so ordering carries the choice for a fresh install while yielding to any later in-CLI switch.
  • codevhub model's completion line adds a dim second line — In OpenCode and CoDev Code, switch models anytime with /models. — so it no longer reads as authoritative for the two tools it can only suggest to.

Nothing in the hub reads the pin back (readOpenCodeConfig uses the provider block for baseUrl/identity), so removing it doesn't affect detection, doctor, restore, or remove.

Testing

pnpm check, pnpm typecheck, pnpm test — 70 files, 1251 tests, all passing. Updated the assertions that pinned config.model for both the opencode and codev-code writers plus the custom-provider identity cases (now asserted through the provider map), and added coverage for the new codevhub model line.

Related

Fork-side counterpart: quickbeard/codev-code#142 removes the same pin from CoDev Code's own SSO setup flow (buildGatewayConfig), which wrote a hub-shaped block. With both merged, no writer produces the pin.

🤖 Generated with Claude Code

The install-time model choice exists because Claude Code and Codex can only
replace their proprietary model with a single one (docs/hub/installation);
OpenCode and CoDev Code switch freely in-CLI. Writing the choice as a
top-level `model` in their configs outranked that in-CLI selection on every
launch — the pin beats the recent models in their state dir — so each
/models switch reverted on restart and only hand-editing the config undid
it. Every install, `codevhub model` run, and gateway-key refresh rewrote
the pin back.

configureOpenCodeKind no longer emits `model`. The chosen model now leads
the provider's models map instead, so a first launch with nothing selected
still lands on it while any later in-CLI switch wins for good. Claude Code,
Codex, and Continue are untouched — `codevhub model` still steers those
authoritatively, and its completion line now says where the in-CLI choice
rules instead of implying it changed those two.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 4a046ed into main Jul 30, 2026
2 of 4 checks passed
@quickbeard
quickbeard deleted the unpin-opencode-model branch July 30, 2026 13:34
quickbeard added a commit that referenced this pull request Jul 30, 2026
PR #221 stopped emitting a top-level `model` in the OpenCode-family configs,
which left `OPENCODE_K.model` with no reader. Biome doesn't flag an unused
object property, so it survived. Pure removal — the comment at the write
site already explains why no pin is written, and CoDev Code shares this
constant table via configureOpenCodeKind, so nothing else references it.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
quickbeard added a commit that referenced this pull request Jul 31, 2026
#229)

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: Quickbeard <quickbeard@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant