Skip to content

Fix OpenCode raw text delta assembly#2526

Open
Kiri110K wants to merge 1 commit intopingdotgg:mainfrom
Kiri110K:fix-opencode-raw-text-deltas
Open

Fix OpenCode raw text delta assembly#2526
Kiri110K wants to merge 1 commit intopingdotgg:mainfrom
Kiri110K:fix-opencode-raw-text-deltas

Conversation

@Kiri110K
Copy link
Copy Markdown

@Kiri110K Kiri110K commented May 5, 2026

What changed

  • Treat OpenCode message.part.delta text chunks as raw incremental deltas and append them exactly as received.
  • Keep message.part.updated snapshot handling as the reconciliation path.
  • Add regression coverage for coincidental suffix/prefix overlap, where the old dedupe logic could strip valid leading characters from a delta.

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 B and the next raw delta is Bonus, stripping the overlap turns Bonus into onus. A later message.part.updated snapshot 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

  • OpenCode provider assistant text assembly only.
  • No UI change.
  • No protocol or persistence change.
  • No behavior change for other providers.

Validation

  • bun fmt
  • bun lint - 0 errors, existing warnings only
  • bun typecheck - passed
  • bun run --cwd apps/server test src/provider/Layers/OpenCodeAdapter.test.ts - 14 passed

UI Changes

Not applicable. This is a server-side provider streaming fix.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (N/A)
  • I included a video for animation/interaction changes (N/A)

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.delta text as raw incremental chunks and appending them verbatim, removing the prior suffix/prefix overlap de-duplication heuristic.

Keeps message.part.updated handling 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 appendOpenCodeAssistantTextDelta to append raw deltas without stripping prefix overlaps

  • Removes the suffixPrefixOverlap helper and the trimming logic from appendOpenCodeAssistantTextDelta in OpenCodeAdapter.ts; deltas are now appended as-is.
  • Behavioral Change: nextText is now a direct concatenation of previousText and the full delta, and callers receive the original delta string rather than an overlap-trimmed version.

Macroscope summarized 584ab1c.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 901ace5f-583a-4af4-b630-e63a87d9d3ad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 5, 2026

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenCode provider can duplicate the assistant response / replay a large suffix chunk at completion

1 participant