Skip to content

text: Commit background parses that a newer streamed chunk overtook - #4

Merged
trancong12102 merged 1 commit into
mainfrom
sync/text-parse-overtaken
Oct 1, 2026
Merged

trancong12102 merged 1 commit into
mainfrom
sync/text-parse-overtaken

Conversation

@trancong12102

Copy link
Copy Markdown

Takes longbridge#3344 (open upstream) ahead of its merge, reconciled with #3.

Bug. A text view dropped every background parse whose revision wasn't the latest. In a fast stream, every parse is overtaken by the next chunk before it lands, so nothing landed until the stream stopped. In this fork that applies to appends the UI thread doesn't parse itself: a last block plus appended text over MAX_SYNC_PARSE_BYTES, which a long streamed answer reaches.

Fix. Upstream's rule: commit a result parsed since the last replacement that is newer than what's committed.

Reconciled with #3:

  • The receiving task's read-before-update check uses the same rule (takes_parse_of), so a discarded result is still not an update.
  • commit_parsed_update hands the result to the fork's commit_parse.
  • Upstream's two tests now build on a paragraph past the synchronous limit. stream_commits_a_parse_that_a_newer_chunk_overtook fails under the old rule.

cargo test -p gpui-base --lib text::: 335 pass.

When longbridge#3344 merges upstream, take its version and keep this reconciliation.

Written with Claude Code.

Taken from longbridge#3344 (FenjuFu), not yet merged there.

A background parse result used to be dropped whenever its revision was not
the latest. A stream that appends faster than a parse completes had always
moved on, so nothing landed until the stream stopped. A result parsed since
the text was last replaced is a prefix of the current text, and is now
committed. One from before that replacement, or older than what is already
committed, is discarded.

Reconciled with this fork's own changes:
- The receiving task reads the state first, so that a result it discards
  is not an update. It now uses the same rule (`takes_parse_of`).
- `commit_parsed_update` hands the result to the fork's `commit_parse`.
- The fork parses a small append on the UI thread, so the two tests build
  on a paragraph long enough to send the append to the background parser.

Co-Authored-By: Claude Code
@trancong12102
trancong12102 force-pushed the sync/text-parse-overtaken branch from 75d03bd to 5ca864e Compare October 1, 2026 16:46
@trancong12102
trancong12102 merged commit 5b79c23 into main Oct 1, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants