zed/crates/acp_thread
Ben Brandt e70e0250a0
Shut down ACP v2 connections on teardown (#65873)
Give ACP v2 runtime/process resources an explicit, idempotent shutdown
boundary independent of retained session models.

- Shut down v2 connections when their shared `AgentConnectionStore` is
released or the app quits. Weak ownership tracking includes replaced
connections still retained by old views or pending receipts without
pinning them.
- Cancel pending connection startup when its owner ends and shut down a
connection that succeeds after its owner has gone away. A weak
resource-level v2 app-quit hook is installed before initialization
completes, so process termination does not depend on foreground startup
cancellation being polled during quit.
- Keep startup resources alive through startup error arbitration. A
protocol rejection must not be replaced by the SIGKILL caused by our own
cleanup. Explicit owner/app shutdown can still take the resources
immediately; the existing priority for natural process exit remains
unchanged.
- Close the shared foreground dispatcher after I/O/disconnect cleanup
finishes, even when retained API handles still own senders.
- Preserve receipt evidence and single-view release policy. No
`session/close` RPC, automatic resend, or process termination merely
because one view is released.

## Shutdown contract and scope

- This is a **hard stop** using the existing owned-child mechanism, not
a graceful agent shutdown or a new grace period. Agent-side
work/persistence can be interrupted when the shared owner ends.
- Quit callbacks synchronously initiate process termination and
cooperative runtime cleanup, then return. They **do not wait for process
reaping, final receipts or a full foreground/protocol drain before
`App::shutdown()` returns**. Tests that await those outcomes afterward
do not establish a before-return drain guarantee.
- The explicit resource-shutdown hook is implemented for v2. Completed
v1/native connections retain their existing default release behavior.
- **Pending-connect cancellation applies to all agent types**, and
dispatcher cleanup is shared with v1. These are intentional broader
changes, not v2-only plumbing.

Release Notes:

- N/A
2026-10-20 15:14:07 +00:00
..
src Shut down ACP v2 connections on teardown (#65873) 2026-10-20 15:14:07 +00:00
Cargo.toml acp_thread: Add shared tool-call state and diff previews (#64875) 2026-09-28 15:53:24 +00:00
LICENSE-GPL