feat(opencode): push native turn-diff evidence to Review (#1625) - #1776
Merged
Merged
Conversation
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.
What
OpenCode now pushes native turn-diff evidence to Review. The provider consumes upstream
session.diffSSE events, validates each entry (safe path, full-context single-hunk patch, per-file and aggregate size bounds), reconstructs exact before/after contents, normalizes them into the canonical text patch, and emits provider-neutralProviderTurnDiffUpdateevents carryingturnId,turnExecutionId,deliveryAttempt, and a monotonicrevision. Malformed evidence rejects the whole aggregate and stays rejected; a net-zero turn emitsindeterminate-emptyso Review falls back honestly.turn-diffis now advertised in OpenCode's capabilities, and OpenCode runs the shared provider-neutral conformance suite.Review's Last turn header again labels the evidence source:
Agent changesfor native evidence,Tracked file evidencefor tracked snapshots, andGit fallback: same-file edits may appearfor the git fallback, exposed viadata-review-source/data-review-fidelity.Also included: a separate commit fixing the verify-mcode watcher proof, which rejected legitimate unrelated
files.changedbroadcasts and expected workspace-relative paths wherefile.refreshreports git-root-relative paths for fixture directories inside a parent repo.Why
Reviewers need to see exactly what the agent changed. Git-snapshot diffs can conflate external edits made to the same file; OpenCode's native
session.diffevidence is agent-attributed. Native evidence also powers the mid-turn Live view. Part of #1621. Closes #1625.UI Changes
Video (plays in browser via blob view): https://github.com/Mzeey-Empire/mcode/blob/pr-assets-1625/.dev/pr-assets/review-1625-labels.mp4 — searching for a thread, opening Review, Last turn view rendering the
Agent changeslabel over the agent-attributed patch.Config Changes
None.
Verification
bun run --cwd packages/providers test -- opencode-native-turn-diff.test.ts turn-diff-conformance.test.ts: 23 tests pass (accumulator safety: unsafe paths, missing/non-string/oversized/partial/multi-hunk patches, sticky rejection, same-file replacement, added/deleted files, indeterminate-empty, conformance suite).bun run --cwd apps/server test -- opencode-provider-turn-diff.test.ts turn-diff-review.test.ts turn-diff-service.test.ts: 32 tests pass (event ownership, foreign-session filtering, capability declaration, settlement and fallback semantics).tsc --noEmitclean inpackages/providers,apps/server,apps/web; lint clean on touched scopes.turnDiff.getComparisonRPC renders theAgent changeslabel and the agent patch in Electron-served Review UI.Review Notes
Environment coverage gaps, stated plainly: the
opencodeCLI is not installed on this machine, so no live OpenCode turn was driven end to end; the UI video drives the real Review RPC path against a seeded native snapshot rather than a live OpenCode session. Native Codex evidence also does not reach this environment (upstream/session-eviction gap unrelated to this change), so the settled-native path is demonstrated by test coverage plus the seeded RPC read. The watcher-proof fix is a separate commit on this branch.Assets note: this
ghbuild has no--attachsupport, so the screenshot and video are pushed onpr-assets-1625and linked above; delete that branch after merge.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.