agent_ui: Fix agent terminal close behavior with keyboard shortcuts (#58217)
Self-Review Checklist:
- [ *] I've reviewed my own diff for quality, security, and reliability
- [ *] Unsafe blocks (if any) have justifying comments
- [ *] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ *] Tests cover the new/changed behavior
- [ *] Performance impact has been considered and is acceptable
What:
- Closing the active terminal from the sidebar activated the remaining
terminal.But closing a terminal with Ctrl-D could leave the agent panel
in an
uninitialized `Zed Agent` state instead of activating the remaining
terminal.
<img width="804" height="380" alt="image"
src="https://github.com/user-attachments/assets/eaa67c6e-7f3d-4a1c-b72d-9cabfaab872b"
/>
How:
- Terminal exits emit `TerminalCloseRequested`.
- The sidebar handles that request through the same close path used by
the
sidebar close button.
- Neighbor activation, draft fallback, metadata cleanup, and
linked-worktree/
archive handling stay centralized in the sidebar close flow.
Added test coverage for closing an active terminal via terminal exit and
activating the remaining terminal neighbor.
Testing:
- `cargo check -p agent_ui`
- `cargo check -p sidebar`
- Manually verified Ctrl-D terminal close behavior with multiple agent
threads/terminals
Release Notes:
- Fixed closing an agent terminal with Ctrl-D leaving the agent panel
uninitialized instead of activating the remaining terminal
104ccf4bb6Hugh L committed on 7/24/2026, 12:52:03 PM· committed by GitHubparent9a5344b