feat(tui): add last-commit diff view option - #13257
Conversation
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (1 files)
Fix these issues in Kilo Cloud Previous Review Summaries (3 snapshots, latest commit 7400444)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 7400444)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 24a68cf)Status: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Previous review (commit 55ce8ec)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (8 files)
Reviewed by grok-4.6 · Input: 160.1K · Output: 10.6K · Cached: 265.1K Review guidance: REVIEW.md from base branch |
Adds a new diff source to the TUI diff viewer that shows only the changes introduced by the most recent git commit (HEAD vs HEAD~1), independent of working tree state. - Extend Vcs.Mode with "last-commit" and implement lastCommitDiff using new Git helpers (diffRefs, statsRefs, patchAllRefs) that compare two arbitrary refs. Build a batched patch from HEAD~1..HEAD so each file gets the correct ref-to-ref patch instead of falling through to the patchUntracked path. - Regenerate SDK and OpenAPI spec for the new mode. - Expose the option in the diff viewer's Switch source dialog.
55ce8ec to
24a68cf
Compare
|
Ready for review! |
7400444 to
0f2f2e8
Compare
When a single oversized file in a commit pushed the unified batch
patch over MAX_TOTAL_PATCH_BYTES, lastCommitDiff discarded the
batched patches of every smaller file and returned empty stubs. It
also silently dropped any chunk whose filename could not be parsed
back from the patch header.
Route the lastCommitDiff loop through the existing patchForItem +
totalPatch helpers used by diffAgainstRef: files present in the
batch map use the batched patch, files missing from it (truncated
tail or failed filename match) fall back to a per-file
`git diff <parent>..HEAD -- <file>` call, and the running byte
total still caps the overall output so behavior matches diff('branch').
0f2f2e8 to
e846360
Compare
|
Fixed. |
|
Thanks @IamCoder18 for the contribution! just merged it. |
Issue
Fixes #13258
Context
The TUI diff viewer offers three sources: working tree, main branch, and last assistant turn. There was no way to inspect only the changes introduced by the most recent git commit (HEAD vs HEAD~1) without mixing in working tree noise. This adds a new "Last commit" entry to the Switch source dialog that drives a new
last-commitmode on the existingVcs.diffroute.Implementation
A new
last-commitmode onVcs.diffthat resolvesHEAD~1viagit rev-parseand returns the diff between the two refs. The ref-to-ref helpers (diffRefs,statsRefs,patchAllRefs) live in a Kilo-only module (packages/opencode/src/kilocode/git-refs.ts) so the sharedGit.Interfaceis not widened. The result is built directly toFileDiff[]instead of going through the sharedfiles()helper, so a missing batched patch can never fall through to the working-tree-vs-/dev/nulluntracked diff path. The TUI diff viewer adds the new mode to itsDiffModetype, Switch source dialog, header label, and help dialog. SDK and OpenAPI spec are regenerated.How to Test
Manual/local verification
Manually tested end-to-end in the TUI (
bun dev) against a git repo with multiple commits and uncommitted working tree changes. Confirmed the "Last commit" option appears in the Switch source dialog, shows only the files changed in the most recent commit with correct patch content, and excludes uncommitted working tree edits.Checklist