Codeman icon indicating copy to clipboard operation
Codeman copied to clipboard

Edit history panel: which files a claude session edited, with diffs and generated images

Open Randalix opened this issue 1 month ago • 2 comments

The gap

  1. While a claude session works, the only record of what it changed is the scrollback. Edits by subagents never show up in the main pane at all.
  2. The git panel answers "what is uncommitted in this repo", not "what did this session touch": it misses files outside the repo (scratch dirs, /tmp, other checkouts), edits that were committed meanwhile, and images a script rendered.
  3. For remote sessions there is nothing, since no hooks reach back from the remote host.

What I built (branch: https://github.com/Randalix/Codeman/tree/feat/edit-history-upstream, one commit on [email protected]). I'm asking before opening a PR.

  • An opt-in header button (per device, default OFF, next to Attachments) opens a floating panel. It lists every Edit/Write/NotebookEdit of the session's main agent and subagents (labelled with the subagent's description), newest first, each with an inline unified diff. Images show as thumbnails, and a click opens the existing file preview. Options: "Group by file", "Main agent only", "Load older".
  • Images come from three places: a Write/Edit to an image path; an image a Bash call produced (its path appears in the call and its mtime lies in the call's window); an image claude delivered with SendUserFile.
  • Source: the session's own transcripts, read by byte offset (main + subagents/), stored per session under dataPath('edit-history'), and deleted with the session. Never git.
  • Local sessions sync 500 ms after an Edit/Write/Bash/Agent tool ends. Remote sessions sync when they go idle, in one ssh round trip. The panel can also ask (?sync=1).

The invariants I would want reviewed

  1. A remote read never wakes a host. A sleeping host answers state: 'unavailable' with the stored entries. The edit-history modules have no access to the wake registry (wiring-guard test).
  2. Read-only: nothing is written to the session's workspace or the remote host.
  3. Docker and non-claude sessions answer unsupported and are never read.

Verification

  • Full npm test: 572 files / 11372 passed, 12 skipped.
  • Live, isolated instance from the branch, one prompt with 2 Edits, a Write, a subagent Write and a Bash-rendered PNG: local 5 entries without asking (same 5 after a restart); remote 5 entries ~2 s after idle, ?sync=1 in 0.49 s; host "asleep" (fake ssh, 10 s timeout) → unavailable with the 5 stored entries in 10.0 s, no wake.

PR welcome?

Randalix avatar Oct 16 '26 05:10 Randalix

Thanks @Randalix, yes, a PR is welcome. The gap is real: the git panel answers "what is uncommitted here", not "what did this session touch", and subagent edits never reach the main pane at all. The invariants you listed are the right ones.

One change to the shape: please make the first PR local sessions only, and bring remote sessions as a second PR on top. The remote read is the riskiest part (a new ssh read path), and it should get its own review rather than ride along with a large UI change. Docker and non-claude answering unsupported is right for both.

What the review will look at, so you can get ahead of it:

  • Opt-in all the way down. The header button is per device and off by default, but the server-side sync should not run for sessions nobody looks at. Either drive it lazily from the panel (?sync=1 on open, then follow while it is open) or gate the background sync on a synced setting, off by default. Reuse the existing transcript watcher rather than adding a hook or a second watcher.
  • The store holds secrets. Diffs carry whatever the agent wrote, keys and .env contents included. So, like intents.json: written 0600 via tmp+rename under dataPath('edit-history'), bounded per session (entries and bytes), deleted with the session, never fed to /api/search, and every route through findSessionOrFail with req so multi-user ownership holds.
  • Images go through the existing file surfaces. A thumbnail or click on an image inside the workspace uses the confined routes, one outside it goes through the attachment routes (POST /api/sessions/:id/attachments with notify: false), with their extension allowlist. Never a new route that serves a path taken from the transcript: the transcript is agent-written and prompt-injectable, so a path found there is untrusted the same way the magic-link scanner's are.
  • Rendering. Diffs and file names render via textContent only, and the panel should not slow the terminal: bounded reads by byte offset (as you have), and nothing parsed on the PTY hot path.
  • CLAUDE_CONFIG_DIR. A session pointed at another config dir writes its transcripts outside ~/.claude/projects, so the panel goes blind for it, like the response viewer and subagent windows. Say so in the panel and the docs rather than guessing a path.
  • Frontend rules. Read src/web/CLAUDE.md first: the header button needs the marker-class hiding pattern and must stay off phones (test/mobile-header-buttons-policy.test.ts).
  • Docs: a wiki page section (docs/wiki/), the setting in Settings-Reference, and the architecture note for the new store.

For the remote PR later: every ssh command line through buildSshConnectionArgs(), remote paths only as shellescaped tokens, reads bounded by src/remote-ssh-limiter.ts, the host taken from the session, and your no-wake wiring guard kept as a test.

Ark0N avatar Oct 18 '26 05:10 Ark0N

Both parts are in: local sessions in #693, remote in #766 (1.49.0). Closing, thanks.

Randalix avatar Nov 06 '26 10:11 Randalix