Repository navigation
feat(git): per-worktree undo journal for ref moves (DAN-87) - #156
Merged
Merged
Conversation
This was referenced Oct 19, 2026
danielss-dev
marked this pull request as ready for review
October 19, 2026 15:12
danielss-dev
force-pushed
the
developements/git-undo-journal-a431
branch
from
October 19, 2026 15:12
334a9d8 to
2cfc040
Compare
danielss-dev
added a commit
that referenced
this pull request
Oct 19, 2026
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.
Linear: https://linear.app/daniels-dev/issue/DAN-87
First slice of multi-step undo/redo for Git actions. Each worktree stores
strand-journal.jsonin its own git dir and records the before/after branch tips, HEAD, and index tree for ref-moving operations. Undo Git Action and Redo Git Action are separate from text undo: they are in the Edit menu (no native accelerator) and the command palette, andMod+Z/Mod+Shift+Zrun only while the commit graph or Local Changes has focus. A success toast names the action. Git Action History lists both stacks; Enter on a row walks the stack through that action.Undo refuses when a recorded ref no longer points at its after-target. A hard reset, checkout, merge, rebase, or cherry-pick stashes tracked work first when the worktree or index would otherwise be overwritten (
Safety: before …), matching reset. Pushes are not journaled, and undoing a later local commit does not move the remote.Left out of this slice
git write-treecan expand a sparse index or fault missing blobs, so those repos skip the journal.Interactive rebase is included: it uses the same rebase journal entry as
git rebase.Manual checks
Windows:
macOS (
nativeMenuPreemptsKeydownis true; predefined Edit → Undo/Redo own ⌘Z):Proof
cargo test -p strand-core: 260 lib tests plus clone/sparse integration tests, all passed. Journal coverage isjournal::tests(15): round-trip for commit, amend, soft/mixed/hard reset, branch create/delete/rename, checkout, merge, rebase, interactive rebase, and cherry-pick; external ref move is refused and namesrefs/heads/main; deleted-branch undo restores the same SHA; rebase undo restores the pre-rebase tip; the journal file survivesRepo::discoverand is per worktree; push is not an entry and undo does not move the bare remote.cargo clippy -p strand-core -p strand-tauri -p strand-ops -p strand-headless -p strand-azdo-protocol -p strand-azdo -- -D warningspassed.pnpm --filter ./ui exec tsc --noEmitpassed.pnpm --filter ./ui test: 627 passed, includinggitUndoBindingAllowed(graph and Local Changes allow the shortcut; an editable inside Local Changes, and the Work editor, do not) and the check thatundo-gitis not a native-menu command.Review fixes
push_is_not_journaled_and_undo_refuses_to_drop_pushed_commitsasserts the refusal, and that the local and remote refs are unchanged.strand-journal.json.lock. Saves go to a unique temp file, thenrename(no remove first).drop_git_actionandrepo_drop_git_action. After a refused undo or redo, the history dialog offers to remove that stale top entry.run_git's doc comment is reattached.runGitActiondrops a call while one is in flight, and the undo/redo shortcut ignores key auto-repeat.checkout_staged_pathspasses paths tocheckout-index -z --stdin, not argv.git rmno longer leaves a stray untracked copy. The re-created file is removed only if it is still the blob the checkout wrote. Agit rm --cachedfile stays (the collision guard refuses that undo).git rm, and agit rm --cached.Merge order 157 → 153 → 155 → 154 → 156 → 158: this PR must wrap #155's new rebase signatures and #154's
amend_intoin the journal. #158 needs this PR'sCommits.tsxattribute.