Skip to content

Turn-level file change summary with View deleted & Undo (#82) - #83

Open
datvm wants to merge 3 commits into
phuryn:mainfrom
datvm:add-file-diff-summary
Open

Turn-level file change summary with View deleted & Undo (#82)#83
datvm wants to merge 3 commits into
phuryn:mainfrom
datvm:add-file-diff-summary

Conversation

@datvm

@datvm datvm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #82.

Adds a Changed N files card at the end of (and during) each agent turn that mutates the workspace:

image
  • Lists every path Grok edited or deleted (shell Remove-Item / rm included), with path-deduped +N −M counts
  • Multi-edit on the same file sums each edit’s stats; open-diff spans the full turn (first before → last after)
  • View on deleted files shows pre-delete content (host first-touch baseline)
  • Undo one file or Undo all restores pre-turn disk state (confirm modal; desktop only)

How it works

Layer Role
Wire diffs ACP type:"diff" blocks still drive per-tool rows and the summary list
Host baselines First touch of a path this turn: snapshot before fs/write_text_file, or sync read before a shell delete
Webview Aggregates the list; View / Undo post to the host; content never leaves the host

Pure helpers live in src/file-baseline.ts and aggregateTurnEdits in media/webview-helpers.js. Deep dive: research/edit-diff.md § Turn-level.

Test plan

  • npm test — 1457 tests green

Out of scope (v1)

  • Baselines after extension reload (in-memory for the live session)
  • Non-delete shell mutations (sed / mv)
  • Subagent child edits
  • Dedicated CLI Rewind “files only” UI (Undo all uses client baselines)

datvm added 3 commits July 27, 2026 14:34
…aggregate edits

- Introduced a new feature to summarize file changes at the turn level, displaying a card for each agent turn that lists the number of files changed along with added and removed lines.
- Added functions to handle the aggregation of edits, including case normalization for file paths and summing changes across multiple edits.
- Enhanced the diff rendering to support multiple edits on the same file, ensuring that the openDiff reflects the full range of changes.
- Updated tests to cover new functionality, including handling of shell delete commands and ensuring correct behavior for multi-edit scenarios.
- Refactored existing tests to accommodate the new summary feature and ensure comprehensive coverage of edge cases.
- Introduced `turnBaselines` message type to handle host-side file baselines.
- Added support for viewing deleted files and undoing changes per file or all files in a turn.
- Captured first-touch snapshots of files before mutations occur, enabling restoration of previous states.
- Enhanced UI to display "Undo all" and "View" buttons for files based on baseline metadata.
- Implemented helper functions for parsing shell delete commands and managing baseline data.
- Added tests for baseline functionality, including normalization, parsing, and archival behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Summary of files Grok changed each turn

1 participant