David Jensen d39178f6c9 agent_ui: Keep focus when background threads auto-send queued messages (#66787)
## Summary

Typing in one conversation no longer loses keyboard focus when a
different, background conversation finishes a turn and automatically
sends its next queued follow-up. Sending a queued message yourself (Send
Now, or fast-tracking the next queued message by pressing Send in the
empty composer) still returns focus to that thread's composer.

The focus decision stays in the shared queued-entry dispatch. Each
caller now passes an explicit source (automatic or manual), and the
dispatch focuses the composer only for manual sends. Queue validation,
cancellation, sending and error recovery are unchanged.

Closes #66416

## Testing

Automated checks run locally on the initial fixed implementation:

- New regression test for automatic sends failed without the fix (at the
foreground composer focus assertion) and passes with it. A second new
test covers manual sends keeping focus. Both passed scheduler seeds
0-19.
- All `agent_ui` and `gpui_apple` tests passed, `cargo fmt --check` and
`./script/clippy -p agent_ui -p gpui_apple` passed, and a full
development build succeeded.
- The full workspace suite and Windows/Linux validation were not run
locally.

Automated native desktop UI test on macOS with a local simulated ACP
agent (not a real external agent or model, and not a human manual test):
thread A had two queued follow-ups, and numbered chunks 01-18 were typed
into thread B one character at a time. A's turns completed mid-typing
and each follow-up auto-submitted, with no clicks, refocuses or window
activations. B's draft was then submitted and received exactly `Typing
in B: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18`.

After the follow-up change that passes an explicit dispatch source (an
internal refactor of the same behavior), all `agent_ui` and `gpui_apple`
tests, both focus tests across seeds 0-19, Clippy and formatting were
rerun and passed. The development app and the desktop test above were
not rebuilt or repeated for that change, and the screenshots come from
the initial implementation.

To reproduce:

1. Open two threads, A and B, in the same window.
2. In A, send a message and, while it generates, queue two follow-ups.
3. Switch to B and start typing continuously.
4. When A's turn finishes, its next follow-up is sent. Typing in B
should continue uninterrupted.

AI assistance was used to prepare this change and its description.

## Self-review

- [ ] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

## Screenshots

<img width="800" height="125" alt="Image"
src="https://github.com/user-attachments/assets/69e7a496-d379-40de-bd0f-9febd5786ff7"
/>

Thread A – Queued followups

<img width="800" height="155" alt="Image"
src="https://github.com/user-attachments/assets/67a5b79c-de25-48f6-9f9b-eeec534b2398"
/>


Thread B – Typing focus retained

Release Notes:

- Fixed typing in an agent thread losing focus when another thread
automatically sends its queued messages.

---------

Co-authored-by: David Jensen <288440181+daejey@users.noreply.github.com>
2026-11-16 13:29:34 +00:00
…
…
2026-09-11 09:13:44 +00:00
…
…
…

Zed

Zed CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.

Sponsorship

Zed is developed by Zed Industries, Inc., a for-profit company.

If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.

S
Description
No description provided
Readme 1.6 GiB
Languages
Rust 95.4%
JSON-with-Comments 2.4%
Python 0.8%
Inno Setup 0.3%
Tree-sitter Query 0.3%
Other 0.4%