opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(tui): guard default agent selection

Open Skyline-23 opened this issue 5 days ago • 2 comments

Summary

  • prevent crash when agent list is empty by deferring current selection
  • ensure current agent resets when list becomes available

Skyline-23 avatar Jan 11 '26 13:01 Skyline-23

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.

github-actions[bot] avatar Jan 11 '26 13:01 github-actions[bot]

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

I found several related PRs that address similar issues with agent handling in the TUI:

Potential Related PRs:

  1. #7748 - fix(tui): handle undefined agent.current() to prevent crash on startup

    • https://github.com/anomalyco/opencode/pull/7748
    • Addresses similar crash prevention when agent.current() is undefined
  2. #7747 - fix(tui): guard local.agent.current() after oauth redirect (fixes #7727)

    • https://github.com/anomalyco/opencode/pull/7747
    • Guards agent.current() in similar context (oauth redirect)
  3. #7689 - fix(tui): handle undefined agent.current() to prevent fatal TypeError

    • https://github.com/anomalyco/opencode/pull/7689
    • Another related guard for undefined agent.current()

These PRs appear to be addressing the same or very similar issues around guarding against undefined/empty agent states. You may want to review them to ensure there's no overlap in the fix approach or to coordinate the solutions.

github-actions[bot] avatar Jan 11 '26 13:01 github-actions[bot]