Skip to content

fix(tui): prevent subagent sessions from overwriting the selected agent#18498

Closed
Haohao-end wants to merge 1 commit intoanomalyco:devfrom
Haohao-end:fix/18404-subagent-identity-swap
Closed

fix(tui): prevent subagent sessions from overwriting the selected agent#18498
Haohao-end wants to merge 1 commit intoanomalyco:devfrom
Haohao-end:fix/18404-subagent-identity-swap

Conversation

@Haohao-end
Copy link

@Haohao-end Haohao-end commented Mar 21, 2026

Summary

Fixes #18404

Prevent child/subagent sessions from mutating the globally selected primary agent in the TUI.

This change gates both:

  • prompt-state restore
  • tool-driven plan/build agent switching

to root sessions only (!session.parentID).

As a result, subagent sessions no longer overwrite the selected primary agent after tool activity, while existing root-session behavior remains unchanged.

Testing

  • Verified the change is limited to:
    • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
    • packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
  • CI bun typecheck currently fails in unrelated packages/app files
  • Local Bun/tsgo validation was unavailable in the original shell

@github-actions
Copy link
Contributor

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 github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 21, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@Haohao-end
Copy link
Author

Updated the PR description to use the template and linked the issue with Fixes #18404.

Also, the current bun typecheck failure appears to be in packages/app:

  • src/components/dialog-connect-provider.tsx
  • src/components/dialog-custom-provider.tsx

Those files are unrelated to this PR’s TUI-only changes.

@github-actions
Copy link
Contributor

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 Mar 21, 2026
@github-actions github-actions bot closed this Mar 21, 2026
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subagent identity swapping after first tool call

1 participant