fix(tui): guard default agent selection
Summary
- prevent crash when agent list is empty by deferring current selection
- ensure current agent resets when list becomes available
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number>orCloses #<number>to this PR description
See CONTRIBUTING.md for details.
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:
-
#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
-
#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)
-
#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.