Skip to content

fix(tui): retain current model and agent across session switches#25285

Closed
saisharan0103 wants to merge 1 commit intoanomalyco:devfrom
saisharan0103:fix/issue-4930-retain-model-agent-on-session-switch
Closed

fix(tui): retain current model and agent across session switches#25285
saisharan0103 wants to merge 1 commit intoanomalyco:devfrom
saisharan0103:fix/issue-4930-retain-model-agent-on-session-switch

Conversation

@saisharan0103
Copy link
Copy Markdown

@saisharan0103 saisharan0103 commented May 1, 2026

Issue for this PR

Closes #4930

Type of change

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

What does this PR do?

When the user switched between sessions via Ctrl+X l, the prompt's createEffect watching props.sessionID reset the agent and model from the picked session's last user message every time, overriding whatever the user had selected before the switch.

The fix adds an initialized flag in that effect so the restoration runs only on the first session sync (initial app load), giving the TUI sensible defaults from the session on startup. On every subsequent session switch the effect short-circuits and leaves the user's current local.agent / local.model / local.model.variant untouched. The existing primary-agent guard and --agent CLI override still apply.

How did you verify your code works?

  • bun run typecheck (tsgo) — clean.
  • oxlint packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx — same 10 pre-existing warnings before and after the change, 0 errors (verified by stashing the change and re-running).
  • Traced the reactive flow: initial load (syncedSessionID undefined, initialized false) restores from the session's last user message and sets initialized = true; subsequent Ctrl+X l switches update syncedSessionID but skip the restoration block.

Screenshots / recordings

N/A

Checklist

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

…malyco#4930)

Only initialize the agent/model/variant from a session's last user message
on the very first session sync. On subsequent session switches, preserve
the user's current selection instead of reverting to the session's
historical configuration.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential Related PR Found

PR #24508: "feat: toggle to keep model/agent when switching sessions"

PR #17190: "fix(app): keep selected model across new sessions"

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 1, 2026
@github-actions github-actions Bot closed this May 1, 2026
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.

Feature Request: Retain current model and agent selection when switching sessions

2 participants