acp_thread: Await Tree-sitter parsing before building agent panel diffs#49101
Merged
benbrandt merged 1 commit intozed-industries:mainfrom Feb 16, 2026
Conversation
Wait for `parsing_idle()` after `set_language()` in both `Diff::finalized()` and `PendingDiff::finalize()` so that syntax highlighting is available when excerpts are created, fixing missing highlights for multiline strings. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
Manual test passed. See this comment. |
rtfeldman
pushed a commit
that referenced
this pull request
Feb 17, 2026
…fs (#49101) ## Summary Fixes #48684 - Await `parsing_idle()` after `set_language()` in both `Diff::finalized()` and `PendingDiff::finalize()` so that tree-sitter parsing completes before buffer snapshots are taken for excerpts - Without this, the 1ms sync parse timeout almost always expires for non-trivial files, causing excerpts to be created with empty syntax trees and missing syntax highlighting ## Root Cause When the agent panel creates or finalizes a diff, it creates a new `Buffer`, calls `set_language()` (which triggers async tree-sitter parsing), then immediately proceeds to take buffer snapshots and create excerpts **without waiting for parsing to complete**. The sync parse timeout is only 1ms in production (`buffer.rs:1138`), so large files almost always fail the sync parse and fall back to async parsing — but no one awaits the async parse before building the diff. ## Fix Add `buffer.update(cx, |buffer, _| buffer.parsing_idle()).await` after `set_language()` in both code paths (`Diff::finalized()` and `PendingDiff::finalize()`). This is the same pattern already used in `buffer_diff.rs:1728-1731`. ## Test plan - [x] `cargo test -p acp_thread` — all relevant tests pass - [x] `./script/clippy` — no warnings - [x] Manual test: open agent panel, ask it to generate a Python file with multiline strings (`"""`), verify syntax highlighting is correct after diff is finalized Release Notes: - Fixed missing syntax highlighting for multiline strings in agent panel diffs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #48684
parsing_idle()afterset_language()in bothDiff::finalized()andPendingDiff::finalize()so that tree-sitter parsing completes before buffer snapshots are taken for excerptsRoot Cause
When the agent panel creates or finalizes a diff, it creates a new
Buffer, callsset_language()(which triggers async tree-sitter parsing), then immediately proceeds to take buffer snapshots and create excerpts without waiting for parsing to complete. The sync parse timeout is only 1ms in production (buffer.rs:1138), so large files almost always fail the sync parse and fall back to async parsing — but no one awaits the async parse before building the diff.Fix
Add
buffer.update(cx, |buffer, _| buffer.parsing_idle()).awaitafterset_language()in both code paths (Diff::finalized()andPendingDiff::finalize()). This is the same pattern already used inbuffer_diff.rs:1728-1731.Test plan
cargo test -p acp_thread— all relevant tests pass./script/clippy— no warnings"""), verify syntax highlighting is correct after diff is finalizedRelease Notes:
🤖 Generated with Claude Code