fix(tui): keep --model when resuming a session with --session by SeashoreShi · Pull Request #53838 · anomalyco/opencode · GitHub
Skip to content

fix(tui): keep --model when resuming a session with --session - #53838

Closed
SeashoreShi wants to merge 1 commit into
anomalyco:devfrom
SeashoreShi:fix/session-model-flag
Closed

SeashoreShi wants to merge 1 commit into
anomalyco:devfrom
SeashoreShi:fix/session-model-flag

Conversation

@SeashoreShi

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #53806

Type of change

  • Bug fix

What does this PR do?

Resuming a session with --session <id> re-initializes the prompt's agent/model from the session's last user message (packages/tui/src/component/prompt/index.tsx). The --agent restore was already guarded — if (!args.agent) — so an explicit command line flag wins, but the model restore ran unconditionally: --session <id> --model <provider/model> was ignored and the next prompt was sent to the session's previous model.

The fix mirrors the agent guard around the model restore (if (!args.model && msg.model)), so an explicit --model is preserved while the session's model is still restored when no flag is given. The variant travels with the model and is only restored alongside it.

How did you verify your code works?

Read the code path and confirmed the asymmetry with the --agent guard; when no --model is passed the behaviour is unchanged. bun test in packages/tui is green (194 pass, 0 fail). There is no existing unit test for this session-sync effect (it depends on the prompt component), so I did not add one — happy to add coverage if you have a preferred harness for it.

Screenshots / recordings

n/a — the change is the resolved model on resume, not a visual change.

Checklist

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

Resuming a session (`--session <id>`) re-initializes the prompt's model from
the session's last user message. The `--agent` flag was already guarded so an
explicit command line value wins, but the model restore ran unconditionally:
`--session <id> --model <provider/model>` was ignored and the next prompt went
to the session's previous model.

Guard the model restore with `!args.model`, mirroring the agent guard, so an
explicit `--model` is preserved while the session's model is still restored
when no flag is given. The variant travels with the model and is only restored
alongside it.
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@opencode-agent opencode-agent Bot closed this Oct 8, 2026
@opencode-agent

opencode-agent Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--model is ignored when resuming a session with --session

1 participant