Fix an ownership cycle in ACP session loading: a connection-owned
pending task retained the thread, which in turn retained the connection.
Closing the loading view could therefore keep both alive indefinitely
while the agent's response was outstanding.
- Keep strong thread ownership with active callers; shared load/resume
operations retain only weak application references while awaiting the
agent.
- Preserve concurrent-load deduplication. Track session close alongside
pending loads so reopening the same session waits for the previous
operation's cleanup before registering a replacement.
- Drain queued foreground replay at cleanup boundaries, without adding a
barrier to successful live loads or changing their mode/config
initialization ordering.
- Ignore replay targeting a released model while preserving session-list
metadata updates.
## Lifecycle boundaries
Successful abandoned loads settle, attempt a best-effort close, and
drain queued replay before replacement. Failed loads drain and clean up
locally before retry, preserving the existing no-close-on-load-error
policy. The tracked close also covers releasing an already-loaded
thread.
This does not add timeouts or cancel detached filesystem/terminal work
already launched by a handler. Same-session reopening waits for the
earlier load/close to settle; pending wire operations no longer keep the
application connection alive by themselves.
Release Notes:
- Fixed external-agent session cleanup when closing and reopening
conversations.
3ab0b5df18Ben Brandt committed on 9/24/2026, 12:26:04 PM· committed by GitHubparent382ff7a