fix(cli): pass --model through to the TUI entry by holny · Pull Request #48163 · anomalyco/opencode · GitHub
Skip to content

fix(cli): pass --model through to the TUI entry - #48163

Closed
holny wants to merge 1 commit into
anomalyco:devfrom
holny:tui-model-flag
Closed

holny wants to merge 1 commit into
anomalyco:devfrom
holny:tui-model-flag

Conversation

@holny

@holny holny commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Fixes #47172

Type of change

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

What does this PR do?

opencode --model <id> --prompt ... accepted the flag on the root command but dropped it before the TUI started, so the session silently ran on the configured default model — the requested id was never mentioned or validated. The run path already resolves and validates the same flag.

  • Define --model (with -m alias) on the root command params
  • Pass it through to the TUI args, where the existing args.model handling parses it and selects the model, warning on malformed values — matching the run path

How did you verify your code works?

  • --help on the root entry now lists --model, -m
  • bun typecheck in packages/cli and packages/tui
  • bun test in packages/cli (259 passing) and packages/tui (2 pre-existing timeouts in dialog-shell-output tests reproduce on a clean baseline, unrelated)

Checklist

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

Supersedes #47699 — the PR head fork was accidentally deleted on 2026-09-09 (not intentional, see the notification comment there); re-filing so the review can continue. Original conversation: #47699

The root command accepted --model but dropped it before the TUI started, so `opencode --model <id> --prompt ...` silently ran on the configured default model. Pass the flag through to the TUI args, where the existing args.model handling parses it and selects the model — matching the run path's behavior.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@holny

holny commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Hi, following up on this one more time. The fix is small -- it adds a --model/-m flag to the TUI entry and passes it through to the existing model resolution, so the TUI no longer silently drops it. CI has been green since it was opened. Would a review be possible sometime this week? Happy to rebase on the latest v2 or adjust anything.

@glmn

glmn commented Oct 7, 2026

Copy link
Copy Markdown

We need this for v2 as well. NeuroSquad (a desktop app that runs OpenCode in terminal panes) starts each pane with a chosen --model, and on v2 the root command drops the flag, so our v2 support would otherwise have to launch opencode mini instead of the default interface. We were going to open a PR for #47172 ourselves, but since this one already covers it, we'll wait for the maintainers' decision rather than duplicate it. Happy to test it on Windows/macOS.

@ShreeMulay

Copy link
Copy Markdown

--agent needs the same root-command wiring as this --model fix. I filed a template-compliant replacement for #53728: #56842. Would you prefer the two flags in one PR, or a separate small PR for --agent? I don't want to duplicate your work.

@holny

holny commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

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.

[bug] --model is silently ignored on the default (TUI) entry path: an unresolvable id runs the configured default model with no warning

3 participants