# acp_thread: Clear running_turn when prompt task drops tx \(\#55562\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/0a52f80824a2f1e9b48dbdc615d63453eaaaf1f9)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 0a52f80824a2f1e9b48dbdc615d63453eaaaf1f9

Requested commit: 0a52f80824a2f1e9b48dbdc615d63453eaaaf1f9

Commit: 0a52f80824a2f1e9b48dbdc615d63453eaaaf1f9

Tree: 6c230791854e9a9572c54a10bfefb63df3fae238

Author: Bruno Moreira

Committer: GitHub

## Message

```
acp_thread: Clear running_turn when prompt task drops tx (#55562)

`AcpThread::status` is purely `running_turn.is_some()`. The cleanup that
takes `running_turn` sat below the early-return guard that fires when
the prompt response oneshot resolves to `Err(Cancelled)` (the inner
`send_task` was dropped before `tx.send`). Any code path that drops the
in-flight `send_task` therefore left the panel stuck in `Generating`.
Reordered so cleanup runs before the dropped-tx guard; the same-turn
invariant is preserved.

Related to #47928 (partial — that issue also has an upstream
`claude-agent-acp` component this PR does not address).

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed agent panel staying in a generating state when the underlying
prompt task was cancelled before completing
```

## Parents

- [6aa90e750ded06c684393ab4cccf159c731f58b6](https://git.cafe/gitcafe/zed/commit/6aa90e750ded06c684393ab4cccf159c731f58b6?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/0a52f80824a2f1e9b48dbdc615d63453eaaaf1f9?format=markdown)
