Repository navigation
fix(cli): pass --agent through to TUI - #56848
ShreeMulay wants to merge 1 commit into
Conversation
Agent-Session: ses_02af8789bffeFnT0FL166url19
There was a problem hiding this comment.
This looks good to me. On the base, opencode --agent plan isn't accepted: it prints the usage text and never starts. With this change, --agent plan opens the TUI with Plan selected and no warning, and an unknown name shows the usual Agent not found toast. I checked this by running both checkouts from source and driving the TUI with the simulated model. The new CLI and TUI tests pass, and the new TUI tests fail against the base source. CLI and TUI typechecks pass.
Public API: adds an optional --agent <name> flag to the root opencode command (backwards compatible). Nothing else outside the code changes.
The flag is checked once, after the launch directory's agents have loaded, so a valid name isn't wrongly rejected at startup. It outranks a session's saved agent the same way args.agent already did. Hidden primary agents are still rejected, which matches how the TUI already works (#45573 asks to change that separately). Your branch and #48163 (--model) edit the same spot in the root flags and the handler's TUI args, so whichever lands second will need a small rebase. No blocking concerns.

Issue for this PR
Closes #56842
Type of change
What does this PR do?
Adds
--agent <name>to the rootopencodecommand and passes it to the full-screen TUI.The TUI now waits for the launch location's agents before applying the CLI selection. That avoids falsely rejecting a valid agent during startup. Only a validated primary agent can override a resumed session's saved agent; invalid, hidden, and subagent names keep the existing warning.
How did you verify your code works?
bun run check: 34/34 tasks passed--agent planselected Plan without a false warning; an unknown name showed the existing warningScreenshots / recordings
Not included. This changes startup selection behavior without changing the interface layout.
Checklist
Added by the opencode bot (AI-generated).
Related: #56218, #45573
Public API: adds the
--agent <name>flag to the rootopencodecommand (backwards compatible)