Repository navigation
feat: record workspace changes during each run (#257) - #308
Merged
Merged
Conversation
regnull
force-pushed
the
feat/run-file-changes
branch
from
October 19, 2026 11:22
28b48d4 to
46670d6
Compare
Port OpenCode's snapshot approach (MIT-licensed, credit in snapshot.py) to record which workspace files each run changed and a unified diff, without touching the workspace's own .git. - New SnapshotStore (backend/openbot/runtime/snapshot.py): per-workspace dedicated git repo under .openbot/snapshots/<hash> — git add -A + write-tree before/after each run, diff-tree for changed files + unified diff. Concurrent bots share one workspace safely: in-process serialization per store, git's own index.lock for cross-process, and .openbot always excluded. - DB: migration 0023 adds changed_files (JSON) and diff (Text) to runs. - Runner: _snapshot_capture_before at run start, _snapshot_attach_terminal at completion/failure/cancellation; CLI agent path updated too. - API: RunOut schema exposes changed_files + diff. - Frontend: RunCard renders a 'Changed' section (file count, filenames, collapsible unified diff) when changed_files is non-empty, consistent with existing card style. - Tests: 7 tests in tests/test_snapshot.py covering store init, capture+diff, gitignore/OOB exclusion, no-change empty diff, and full runner wiring with actual tool calls. All values are best-effort: a failed snapshot never blocks the run.
- Label run changes as workspace changes during the run, and flag runs whose window overlapped another run in the same workspace (runs.changes_shared). - Record the terminal status first; the after-capture and diff run in a background task so a slow git add never delays or breaks a run's ending. - Close the window when a run parked on a human is cancelled outside execute(). - Move the diff from RunOut to RunDetail; the UI fetches it when opened. - Cap stored diffs at 200k chars, run git gc --auto on the store. - Correct the docstring: the workspace's .git/info/exclude does not apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t robustness - Open a run's window before its before-capture and close it only after the after-capture, so runs that queue on the store lock count as overlapping. - Nested workspace roots (thread at . and thread at sub/) overlap. - execute() wraps every exit: an exception or cancel at any await, or the thread-deleted bail-out, finishes the snapshot unless the run is parked. - Pin before-trees under refs/runs/<id> so gc --auto never prunes them; a failed diff leaves the columns NULL instead of reading as no changes. - git: 120s timeout, child killed on timeout/cancel, stale index.lock removed, init keeps the environment (PATH/HOME), info/ created, T status counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
regnull
force-pushed
the
feat/run-file-changes
branch
from
November 18, 2026 02:34
46670d6 to
2ad980c
Compare
regnull
marked this pull request as ready for review
November 18, 2026 02:38
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.
Summary
Records which workspace files changed while each run was active, plus the unified diff, without touching the workspace's own
.git. The snapshot approach is ported from OpenCode's MIT-licensedsnapshot/service.Closes #257.
How it works
<state dir>/snapshots/<hash of root>.git add -A+write-tree) before it starts. When it ends, it captures a second tree and diffs the two.git addnever delays or breaks a run's ending.It is a time window, not attribution
The diff shows what changed while the run was active. Another bot in the same workspace, a person's editor, or a build can change files in that window too, so the UI says "Workspace changes".
runs.changes_sharedis set when another run was active in an overlapping workspace (the same root, or one inside the other) during the window, and the UI warns that some changes may belong to that other run.Reliability
execute()finishes the snapshot, except a run parked on a human. That covers exceptions or cancels at any await and the thread-deleted bail-out. Cancelling a run parked on a human (cancel_run) closes its window too. Without this, a leaked window would flag every later run in that workspace as shared.refs/runs/<id>, sogc --autonever prunes the tree of a run that waits on a human for weeks. If the diff fails, the columns stay NULL instead of reading as "no changes".index.lockleft by a killed git is removed.initkeeps PATH and HOME.T, e.g. a file replaced by a symlink) are listed.API and UI
RunOutcarrieschanged_filesandchanges_shared. The diff is only onRunDetail(GET /runs/{id}): thread loads list every run, and diffs can be large.RunCardfetches it when "View diff" is opened.0023addsruns.changed_files(JSON),runs.diff(Text), andruns.changes_shared(Boolean).Known limits
.git/info/excludedoes not apply, because git readsinfo/excludefrom the store..gitignorefiles and global excludes do apply, and.openbotis always excluded.OPENBOT_ROOT_DIRECTORY). Without one they are off.Tests
tests/test_snapshot.pyhas 18 tests:execute()fails before itstryblockindex.lockrecovery, and a failed diff giving no difftscis clean, 442 tests passed, and lint shows one existing warning.🤖 Generated with Claude Code