Skip to content

copilot: Fix panic in Copilot edit prediction due to anchor/snapshot mismatch#46022

Merged
Veykril merged 2 commits intozed-industries:mainfrom
vadim-su:fix-copilot-anchor-snapshot-mismatch
Jan 4, 2026
Merged

copilot: Fix panic in Copilot edit prediction due to anchor/snapshot mismatch#46022
Veykril merged 2 commits intozed-industries:mainfrom
vadim-su:fix-copilot-anchor-snapshot-mismatch

Conversation

@vadim-su
Copy link
Contributor

@vadim-su vadim-su commented Jan 4, 2026

When trim_completion() creates new anchors from the current buffer state, completion.snapshot was not being updated, leaving it with the older snapshot from when the prediction was initially fetched. This caused a panic in interpolate_edits() when trying to resolve anchors with Lamport timestamps newer than what the old snapshot had observed.

The fix ensures that completion.snapshot is updated whenever new anchors are created in trim_completion(), keeping the snapshot and anchors consistent.

Closes #45956

Release Notes:

  • Fixed a panic in Copilot edit predictions caused by anchor/snapshot version mismatch

When `trim_completion()` creates new anchors from the current buffer state,
`completion.snapshot` was not being updated, leaving it with the older
snapshot from when the prediction was initially fetched. This caused a
panic in `interpolate_edits()` when trying to resolve anchors with Lamport
timestamps newer than what the old snapshot had observed.

The fix ensures that `completion.snapshot` is updated whenever new anchors
are created in `trim_completion()`, keeping the snapshot and anchors
consistent.

Fixes zed-industries#45956
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 4, 2026
@vadim-su vadim-su mentioned this pull request Jan 4, 2026
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril enabled auto-merge (squash) January 4, 2026 13:27
@Veykril Veykril disabled auto-merge January 4, 2026 13:27
@Veykril Veykril changed the title Fix panic in Copilot edit prediction due to anchor/snapshot mismatch copilot: Fix panic in Copilot edit prediction due to anchor/snapshot mismatch Jan 4, 2026
@Veykril Veykril enabled auto-merge (squash) January 4, 2026 13:27
@Veykril Veykril disabled auto-merge January 4, 2026 13:28
@Veykril
Copy link
Member

Veykril commented Jan 4, 2026

rustfmt is not happy

@SomeoneToIgnore SomeoneToIgnore added the area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Jan 4, 2026
@vadim-su
Copy link
Contributor Author

vadim-su commented Jan 4, 2026

rustfmt is not happy

One moment, I'll fix this.

I executed cargo fmt --all -- --check, but no errors were reported. What am I missing?

@Veykril
Copy link
Member

Veykril commented Jan 4, 2026

Looks good now, thanks! not sure what went wrong for you there unfortunatley

@Veykril Veykril merged commit 5505e63 into zed-industries:main Jan 4, 2026
23 checks passed
@vadim-su vadim-su deleted the fix-copilot-anchor-snapshot-mismatch branch January 4, 2026 14:17
@osiewicz
Copy link
Member

osiewicz commented Jan 5, 2026

Thank you!

rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
…mismatch (#46022)

When `trim_completion()` creates new anchors from the current buffer
state, `completion.snapshot` was not being updated, leaving it with the
older snapshot from when the prediction was initially fetched. This
caused a panic in `interpolate_edits()` when trying to resolve anchors
with Lamport timestamps newer than what the old snapshot had observed.

The fix ensures that `completion.snapshot` is updated whenever new
anchors are created in `trim_completion()`, keeping the snapshot and
anchors consistent.

Closes #45956

Release Notes:

- Fixed a panic in Copilot edit predictions caused by anchor/snapshot
version mismatch
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…mismatch (zed-industries#46022)

When `trim_completion()` creates new anchors from the current buffer
state, `completion.snapshot` was not being updated, leaving it with the
older snapshot from when the prediction was initially fetched. This
caused a panic in `interpolate_edits()` when trying to resolve anchors
with Lamport timestamps newer than what the old snapshot had observed.

The fix ensures that `completion.snapshot` is updated whenever new
anchors are created in `trim_completion()`, keeping the snapshot and
anchors consistent.

Closes zed-industries#45956

Release Notes:

- Fixed a panic in Copilot edit predictions caused by anchor/snapshot
version mismatch
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…mismatch (zed-industries#46022)

When `trim_completion()` creates new anchors from the current buffer
state, `completion.snapshot` was not being updated, leaving it with the
older snapshot from when the prediction was initially fetched. This
caused a panic in `interpolate_edits()` when trying to resolve anchors
with Lamport timestamps newer than what the old snapshot had observed.

The fix ensures that `completion.snapshot` is updated whenever new
anchors are created in `trim_completion()`, keeping the snapshot and
anchors consistent.

Closes zed-industries#45956

Release Notes:

- Fixed a panic in Copilot edit predictions caused by anchor/snapshot
version mismatch
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Feb 15, 2026
…mismatch (zed-industries#46022)

When `trim_completion()` creates new anchors from the current buffer
state, `completion.snapshot` was not being updated, leaving it with the
older snapshot from when the prediction was initially fetched. This
caused a panic in `interpolate_edits()` when trying to resolve anchors
with Lamport timestamps newer than what the old snapshot had observed.

The fix ensures that `completion.snapshot` is updated whenever new
anchors are created in `trim_completion()`, keeping the snapshot and
anchors consistent.

Closes zed-industries#45956

Release Notes:

- Fixed a panic in Copilot edit predictions caused by anchor/snapshot
version mismatch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic on dev

4 participants