fix: RevertBanner UI shows no changes after successful file revert#8121
Conversation
When reverting a session, the diff was computed after files were already reverted to their pre-change state, producing an empty or wrong diff. By computing the diff before restoring files, the revert summary now correctly reflects what was actually undone for the user.
| summary_additions: input.summary?.additions, | ||
| summary_deletions: input.summary?.deletions, | ||
| summary_files: input.summary?.files, | ||
| summary_diffs: input.summary?.diffs ?? null, |
There was a problem hiding this comment.
WARNING: Persisting raw summary.diffs here stores every file's full before/after contents in the session row and republishes them on Session.Event.Updated. We already strip summary.diffs off user messages because these payloads can grow very large, and the RevertBanner only needs file names plus add/delete counts. Consider storing a metadata-only shape here and keeping the full diff bodies in session_diff storage / diff events.
There was a problem hiding this comment.
The issue has been resolved.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Reviewed by gpt-5.4-20260305 · 1,445,338 tokens |
Full file contents were being stored in the session summary diffs, causing unnecessary database bloat. The webview RevertBanner only needs file path, line counts, and status — not the full diff content.
|
Hi @IamCoder18, thanks for contributing. Could you please add |
|
@IamCoder18 I added the change marker, thanks for the fix! |
Context
IMPORTANT: The revert button was reverting changes correctly, it just didn't convey that in the banner, causing confusion.
The "Revert to here" button in the VS Code extension sidebar appears to not revert file changes — after clicking it, messages disappear but the RevertBanner shows no file change information. This gives the impression that only chat messages are reverted and not the associated git/file changes. In reality,
Snapshot.revert(patches)was always reverting files correctly. The actual bug is that the diff data never reaches the webview, so the RevertBanner is always empty after revert.Closes #8048
Two bugs contribute to this:
computeDiff()called after file revert —SessionSummary.computeDiff()was called afterSnapshot.revert(patches). By that point files on disk already matched therevert.snapshotbaseline, soSnapshot.diffFull(from, to)compared identical states and returned an empty diff.Diffs not persisted to the database —
Session.setRevert()storedsummary_additions,summary_deletions, andsummary_filesbut notsummary_diffs. The column exists in the schema but was never written. The webview readssession.summary()?.diffsfor the RevertBanner, which was alwaysundefined.Additionally, revert does not work in repositories with no commits (e.g.,
git initbut no commits yet) because the snapshot system's initialgit rev-list --max-parents=0 --allreturns empty, causing the project to be stored without git VCS tracking. This is a pre-existing limitation, not addressed in this PR.Implementation
Two files changed:
packages/opencode/src/session/revert.tsCompute diffs before reverting files: Moved
SessionSummary.computeDiff()to execute beforeSnapshot.revert(patches). The diff captures changes being undone while files on disk still reflect the AI's modifications.Snapshot.revertitself was not changed — it was always working correctly.Include
diffsin the summary: ThesetRevertcall now passesdiffsin the summary so it propagates throughsessionToWebviewto the webview's RevertBanner.packages/opencode/src/session/index.tssummary_diffsinsetRevert: Addedsummary_diffs: input.summary?.diffs ?? nullto the Drizzle.set()call. Thesummary_diffscolumn already exists in the schema but was never written during revert operations.Screenshots
How to Test
Get in Touch
My discord is
@iamcoder18and I am in the Kilo Code discord server.