# agent_ui: Keep pending subagent edits when regenerating a prompt \(\#59060\) · gitcafe/zed

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

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

Visibility: public

Requested revision: c78bd36fd8bf3204a487f95d214421ebcc0695d5

Requested commit: c78bd36fd8bf3204a487f95d214421ebcc0695d5

Commit: c78bd36fd8bf3204a487f95d214421ebcc0695d5

Tree: f53e1b68c36e7bccff7ece7cd8ef09e27891344f

Author: MartinYe1234

Committer: GitHub

## Message

```
agent_ui: Keep pending subagent edits when regenerating a prompt (#59060)

Fixes the agent panel silently reverting all pending subagent file
changes when an earlier message is edited and regenerated.

`ThreadView::regenerate` decides whether to auto-keep pending edits from
earlier prompts (behavior introduced in #43347) by scanning the parent
thread's entries for diffs. Subagent edits never appear there — they are
only forwarded to the parent's action log via the linked-log mechanism —
so the auto-keep step was skipped and `rewind`'s unscoped
`reject_all_edits` reverted all of them on disk, without confirmation.

The fix treats any earlier subagent tool call as potentially having
edits, so they get auto-kept just like direct edits from earlier
prompts. Keeping all edits is a no-op when the subagent made none. Edits
produced by the prompt being regenerated are still auto-rejected,
consistent with existing behavior.

Also adds a regression test
(`test_regenerate_keeps_pending_subagent_edits`) that reproduces the
full flow — subagent edit forwarded through a linked action log,
follow-up prompt, regenerate — and fails with the exact reported data
loss without the fix.

Closes AI-386

Closes https://github.com/zed-industries/zed/issues/58932

Release Notes:

- Fixed pending subagent file changes being discarded when editing an
earlier message in the agent panel.
```

## Parents

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

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