# Do not react on already observed buffer edits' versions \(\#46308\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 31343566e7ab827f4a1fb3c8fd34a3126527a342

Requested commit: 31343566e7ab827f4a1fb3c8fd34a3126527a342

Commit: 31343566e7ab827f4a1fb3c8fd34a3126527a342

Tree: 832ebe6606c6d1b883e4dad4e110c1ec99a9451d

Author: Kirill Bulatov

Committer: GitHub

## Message

````
Do not react on already observed buffer edits' versions (#46308)

If I apply

```diff
diff --git a/crates/action_log/src/action_log.rs b/crates/action_log/src/action_log.rs
index 404fb3616d..ece063c34f 100644
--- a/crates/action_log/src/action_log.rs
+++ b/crates/action_log/src/action_log.rs
@@ -223,6 +223,7 @@ impl ActionLog {
             futures::select_biased! {
                 buffer_update = buffer_updates.next() => {
                     if let Some((author, buffer_snapshot)) = buffer_update {
+                        dbg!(&author);
                         Self::track_edits(&this, &buffer, author, buffer_snapshot, cx).await?;
                     } else {
                         break;
```

on top of `main`, `User` and `Agent` will always interleave.

This happens because `action_log` does updates on `Entity<Buffer>` which
is a current editor's buffer, tracked, and updated by agent output (acp
or regular threads) — those updates come back as `BufferEvent::Edited`
event after each agent's edit and forces unnecessary computations.

Instead, update tracked buffer's version after each agent update report
to only react on one, `Agent`-authored, edit events.

Release Notes:

- N/A
````

## Parents

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

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