Fix OpenCode raw text delta assembly#2526
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Straightforward bug fix that removes incorrect text deduplication logic which was stripping valid content. The change is small, self-contained, and includes comprehensive test updates verifying the correct behavior. You can customize Macroscope's approvability policy. Learn more. |
What changed
message.part.deltatext chunks as raw incremental deltas and append them exactly as received.message.part.updatedsnapshot handling as the reconciliation path.Why this should exist
Fixes #2380.
Likely related to #2379.
OpenCode text deltas are already valid incremental chunks. The previous overlap heuristic tried to dedupe suffix/prefix overlap between the already assembled assistant text and the next delta, but normal text can overlap coincidentally.
For example, if the current text ends in
Band the next raw delta isBonus, stripping the overlap turnsBonusintoonus. A latermessage.part.updatedsnapshot then reconciles the missing text by emitting a larger corrective suffix, which can make the assistant response appear duplicated or corrupted near completion.This change makes raw deltas authoritative and leaves full part snapshots to reconcile state without mutating normal streamed chunks.
Scope
Validation
bun fmtbun lint- 0 errors, existing warnings onlybun typecheck- passedbun run --cwd apps/server test src/provider/Layers/OpenCodeAdapter.test.ts- 14 passedUI Changes
Not applicable. This is a server-side provider streaming fix.
Checklist
Note
Medium Risk
Changes OpenCode assistant text streaming assembly; incorrect handling could impact user-visible output ordering/duplication, but scope is limited to a single provider and covered by new regression tests.
Overview
Fixes OpenCode assistant text assembly by treating
message.part.deltatext as raw incremental chunks and appending them verbatim, removing the prior suffix/prefix overlap de-duplication heuristic.Keeps
message.part.updatedhandling as the reconciliation mechanism, and updates/adds tests to cover overlapping-update scenarios and the regression where coincidental prefix overlap (e.g.B+Bonus) previously caused valid characters to be stripped.Reviewed by Cursor Bugbot for commit 584ab1c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
appendOpenCodeAssistantTextDeltato append raw deltas without stripping prefix overlapssuffixPrefixOverlaphelper and the trimming logic fromappendOpenCodeAssistantTextDeltain OpenCodeAdapter.ts; deltas are now appended as-is.nextTextis now a direct concatenation ofpreviousTextand the full delta, and callers receive the original delta string rather than an overlap-trimmed version.Macroscope summarized 584ab1c.