# Fix race condition in \`update_last_checkpoint\` \(\#44801\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 32621dc5ded88bde43ee7a463f72f747581435a0

Requested commit: 32621dc5ded88bde43ee7a463f72f747581435a0

Commit: 32621dc5ded88bde43ee7a463f72f747581435a0

Tree: 00d14c5349a3601fe92ede0187893d3fa51ce263

Author: Nathan Sobo

Committer: GitHub

## Message

```
Fix race condition in `update_last_checkpoint` (#44801)

Release Notes:

- Fixed spurious "no checkpoint" error in agent panel

---

## Summary

`update_last_checkpoint` would call `last_user_message()` twice - once
at the start to capture the checkpoint, and again in an async closure
after the checkpoint comparison completed. If a new user message without
a checkpoint was added between these two calls, the second call would
find the new message and fail with "no checkpoint".

## Fix

Capture the user message ID at the start and use `user_message_mut(&id)`
in the async closure to find the specific message.

cc @mikayla-maki
```

## Parents

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

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