fix(app): prevent streaming content duplication during event coalescing#14820
Open
praxstack wants to merge 2 commits intoanomalyco:devfrom
Open
fix(app): prevent streaming content duplication during event coalescing#14820praxstack wants to merge 2 commits intoanomalyco:devfrom
praxstack wants to merge 2 commits intoanomalyco:devfrom
Conversation
…cing When message.part.updated events coalesce within a 16ms batch window (text-end replaces text-start at the same queue index), stale message.part.delta events remained in the queue. On flush, the reducer applied the full text from the coalesced update, then appended the stale deltas on top — doubling the content. Fix: When a message.part.updated event coalesces over an earlier entry, void all stale message.part.delta events for the same messageID:partID already in the queue. Voided indices are skipped during flush. Zero overhead in normal operation (voided set stays empty when no coalescing occurs). Scoped by messageID+partID to avoid affecting unrelated parts. Fixes content repetition visible during LLM streaming in desktop UI. Content displays correctly after app restart (loaded from DB).
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
6 tasks
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.
Issue for this PR
Closes #14822
Type of change
What does this PR do?
During streaming, SSE events are batched in 16ms windows.
message.part.updatedevents coalesce (text-end replaces text-start at same queue index), butmessage.part.deltaevents never coalesce. When both land in the same batch, the full text gets applied via reconcile, then stale deltas append on top — doubling the content.The fix adds a
voidedSet in global-sdk.tsx. When amessage.part.updatedcoalesces, all stalemessage.part.deltaevents for that messageID+partID are voided. Voided indices are skipped during flush. Zero overhead when no coalescing occurs (the common case).How did you verify your code works?
bun run --cwd packages/desktop tauri devScreenshots / recordings
Text-only change in event batching layer, no UI changes.
Checklist