Repository navigation
feat(core): compute real session-level modified-files diff - #71
Closed
quickbeard wants to merge 4 commits into
Closed
quickbeard wants to merge 4 commits into
quickbeard wants to merge 4 commits into
Conversation
SessionSummary.summarize now computes the whole-session snapshot diff (computeDiff over all messages, reusing the turn diff for single-turn sessions) and publishes it via Session.Event.Diff along with real session.summary aggregates, instead of upstream's unconditional zeros/empty diff. The GET /session/:id/diff endpoint without a messageID returns the computed session-wide diff instead of []. This lights up the TUI sidebar "Modified Files" section, the prompt-footer files hint (#69), and the web app's session diff, all of which upstream leaves permanently empty (only revert published data). Clearing paths (snapshots disabled, no messages, missing target) still publish empty; legacy session_diff storage rows are still never read back (#26574 guard preserved). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
SessionSummary.summarizenow computes the whole-session snapshot diff —computeDiffover all session messages (firststep-startsnapshot → laststep-finishsnapshot), reusing the already-computed turn diff for single-turn sessions — and publishes it viaSession.Event.Difftogether with realsession.summaryadditions/deletions/files aggregates.GET /session/{id}/diffwithout amessageID(the hydrate path used by both the TUI and the web app) returns the computed session-wide diff instead of[].This lights up three dormant surfaces at once, with zero client changes:
ctrl+b N todos · M fileshint (feat(tui): show hidden-sidebar hint in prompt footer #69),Upstream publishes a permanently empty session-level diff (
summary.tshardcodesdiff: []; only session revert carries data). That was a deliberate perf fix — anomalyco/opencode#30127 removed automatic full-session diffs after a snapshot-heavy historical session recomputed a multi-megabyte diff every turn — so this is a fork-only divergence, documented in DIVERGENCES.md. We accept the recompute cost: the single-turn reuse covers the common case, and counts-only publishing (patch is optional in the schema) is the follow-up lever if large sessions bite.Details:
summarize(no upfront empty publish → no sidebar flicker mid-computation); clearing paths (snapshots disabled, no messages, missing target) still publish zeros/empty.unquoteDiffs(git C-quoting), matching the existing per-message endpoint behavior.session_diffstorage rows are still never read back, preserving the #26574 regression guard; that test's stale header comment updated.test/session/summary.test.ts(real git snapshots, modeled onrevert-compact.test.ts): multi-turn session-wide diff + counters, single-turn reuse path, and the clearing path.Known limitations (accepted)
Session.Event.Diffnow ships full patches per step-finish; share-next forwards it verbatim — larger SSE/share payloads on big sessions (upstream revert already ships full patches on this event).diffFullper step-finish (serialized behind the snapshot lock); debounce is a follow-up if it ever shows in traces.Session.diff[]stub, so a freshly shared idle session shows an empty diff until its next activity.[]there).Verification
bun typecheck+test/session/summary.test.ts,test/server/session-diff-missing-patch.test.ts,test/session/revert-compact.test.ts,test/snapshot/snapshot.test.ts,test/share/share-next.test.tsall green frompackages/opencode.Live TUI run (tmux, scratch git project, real model turns): agent edits 2 files → footer hint shows
ctrl+b 2 modified files, sidebar lists both files with+1 -1; a later turn restoring one file to its original content drops it from the list (net diff, matchesgit status); TUI restart +-creopen shows1 modified filefrom the hydrate path, which previously always returned empty.🤖 Generated with Claude Code