Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ shortcuts").
| `Mod+R` | Refresh |
| `Mod+Shift+T` | Toggle light/dark theme |
| `Mod+B` | Toggle sidebar |
| `Mod+Z` | Undo last Workbench layout change while customizing |
| `Mod+Z` / `Mod+Shift+Z` | Undo / redo the latest Git action when the graph or Local Changes is focused |
| `Mod+Z` | Undo the last Workbench layout change while customizing, when focus is outside those views and any text field |
| `Mod+[` / `Mod+]` | Cycle panes in a composed Workbench |

Surface-local keys (not rebindable, documented in Settings → Keyboard):
Expand Down Expand Up @@ -325,6 +326,9 @@ the resolved app appearance automatically.
The merge editor can suggest a per-hunk AI resolution (explanation and
confidence); it is written only after you accept or edit each hunk and
click Resolve.
Undo Git Action and Redo Git Action walk a per-worktree journal of commit,
amend, reset, branch, checkout, merge, rebase, and cherry-pick; `Mod+Z` does
this only from the graph or Local Changes.
- **Patch interchange** — preview affected paths and validate patch imports
into the working tree, index, or both; import mailboxes with original authors
and Continue / Skip / Abort recovery; verify bundle refs and prerequisites,
Expand Down
6 changes: 5 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ through `discardPatch` (stage/unstage are non-destructive). A self-contained
`UndoToast` in `App.tsx` surfaces an Undo button for 6s per discard
("Undo send" model) — single-undo only ever recovers the most recent
discard. Selected-line discard joined the same single-undo pipeline on
2026-07-18; a persistent multi-entry undo stack remains future work.
2026-07-18. Ref-moving Git actions (commit, amend, reset, branch
create/delete/rename, checkout, merge, rebase, cherry-pick) now keep a
per-worktree journal with Undo Git Action and Redo Git Action
(2026-10-19). Discard, stash, fetch, pull, and push stay outside that
stack.

**Commit graph + detail panel (2026-05-28):** All Commits is now an
actual graph: `ui/src/lib/graph.ts` walks `repo_log`'s topologically-
Expand Down
10 changes: 10 additions & 0 deletions TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ community plugins, performance and platform certification from Git feature gaps.
(radiogroup, mixed default, danger-styled hard) and the Reflog's "Reset HEAD
here…"; palette "Undo last commit (soft reset)" = soft reset to `HEAD~1`,
gated on a non-root HEAD.)
- ☑ Per-worktree Git action journal (`journal.rs` —
`Repo::undo_git_action` / `redo_git_action` / `git_action_history`,
`strand-journal.json` in the worktree git dir). Records commit, amend,
reset, branch create/delete/rename, checkout, merge, rebase, and
cherry-pick. UI: Edit menu and palette "Undo Git Action" / "Redo Git
Action" (`undo-git` / `redo-git`) plus "Git Action History".
- ☐ Journal working-tree actions (discard, stash) and remote updates
(push, fetch, pull). Conflicted sequencer ops, sparse/partial clones,
tags, and hosting-provider actions stay out until they can be reversed
without discarding uncommitted work or rewriting a published ref.
- ☑ Rename / move a working-tree entry (`Repo::move_path` in `rename.rs` —
`to` is the full destination path. Tracked sources (any index entry at the
path or under it) shell out to `git mv` so the index entry moves with the
Expand Down
67 changes: 67 additions & 0 deletions crates/strand-core/src/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ impl Repo {
/// check goes through the worktree registry; a registry read failure
/// falls through (the rollback below still protects the repo).
pub fn checkout_branch(&self, name: &str) -> Result<CheckoutOutcome> {
crate::journal::record(
self,
crate::journal::GitOp::Checkout,
format!("Checkout {name}"),
true,
|| self.checkout_branch_inner(name),
)
}

fn checkout_branch_inner(&self, name: &str) -> Result<CheckoutOutcome> {
if self.sparse_enabled() || self.is_partial_clone() {
self.git2()?.find_branch(name, git2::BranchType::Local)?;
crate::network::run_git_streaming(&self.path, &["switch", "--", name], |_| {}, None)?;
Expand Down Expand Up @@ -124,6 +134,23 @@ impl Repo {
name: &str,
start_point: Option<&str>,
checkout: bool,
) -> Result<CheckoutOutcome> {
let label = if checkout {
format!("Create and check out branch {name}")
} else {
format!("Create branch {name}")
};
// Nested checkout is one user action: the outer record owns the entry.
crate::journal::record(self, crate::journal::GitOp::BranchCreate, label, checkout, || {
self.create_branch_inner(name, start_point, checkout)
})
}

fn create_branch_inner(
&self,
name: &str,
start_point: Option<&str>,
checkout: bool,
) -> Result<CheckoutOutcome> {
let repo = self.git2()?;

Expand Down Expand Up @@ -158,6 +185,16 @@ impl Repo {
///
/// [`checkout_branch`]: Repo::checkout_branch
pub fn checkout_commit(&self, rev: &str) -> Result<CheckoutOutcome> {
crate::journal::record(
self,
crate::journal::GitOp::Checkout,
format!("Checkout {rev}"),
true,
|| self.checkout_commit_inner(rev),
)
}

fn checkout_commit_inner(&self, rev: &str) -> Result<CheckoutOutcome> {
let repo = self.git2()?;
let commit = repo.revparse_single(rev)?.peel_to_commit()?;

Expand Down Expand Up @@ -192,6 +229,16 @@ impl Repo {
/// This keeps a confirmation opened from stale UI state from deleting a
/// branch that moved in the meantime.
pub fn delete_branch(&self, name: &str, force: bool) -> Result<()> {
crate::journal::record(
self,
crate::journal::GitOp::BranchDelete,
format!("Delete branch {name}"),
false,
|| self.delete_branch_inner(name, force),
)
}

fn delete_branch_inner(&self, name: &str, force: bool) -> Result<()> {
let repo = self.git2()?;
let mut branch = repo.find_branch(name, git2::BranchType::Local)?;
if branch.is_head() {
Expand Down Expand Up @@ -236,6 +283,16 @@ impl Repo {
/// the exact source commit the provider reported. This is the squash/rebase
/// merge counterpart to [`delete_branch`]'s ancestry guard.
pub fn delete_branch_at(&self, name: &str, expected_target: &str) -> Result<()> {
crate::journal::record(
self,
crate::journal::GitOp::BranchDelete,
format!("Delete branch {name}"),
false,
|| self.delete_branch_at_inner(name, expected_target),
)
}

fn delete_branch_at_inner(&self, name: &str, expected_target: &str) -> Result<()> {
let expected = git2::Oid::from_str(expected_target)?;
let repo = self.git2()?;
let mut branch = repo.find_branch(name, git2::BranchType::Local)?;
Expand Down Expand Up @@ -271,6 +328,16 @@ impl Repo {
/// branch's config section (upstream) along, and HEAD follows when the
/// renamed branch is checked out. No force — errors if `new` exists.
pub fn rename_branch(&self, old: &str, new: &str) -> Result<()> {
crate::journal::record(
self,
crate::journal::GitOp::BranchRename,
format!("Rename branch {old} to {new}"),
false,
|| self.rename_branch_inner(old, new),
)
}

fn rename_branch_inner(&self, old: &str, new: &str) -> Result<()> {
let new = new.trim();
if new.is_empty() {
return Err(crate::Error::Other("branch name is required".into()));
Expand Down
26 changes: 26 additions & 0 deletions crates/strand-core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ impl Repo {
}

pub fn commit_with_signing(&self, subject: &str, body: Option<&str>, amend: bool, signing: SigningMode) -> Result<CommitOutcome> {
let subject_label = action_subject(subject);
let (op, label) = if amend {
(crate::journal::GitOp::Amend, format!("Amend: {subject_label}"))
} else {
(crate::journal::GitOp::Commit, format!("Commit: {subject_label}"))
};
// Commit and amend move HEAD only. The index is already the committed
// tree, so undo is a soft ref move and must not rewrite the index.
crate::journal::record(self, op, label, false, || {
self.commit_with_signing_inner(subject, body, amend, signing)
})
}

fn commit_with_signing_inner(&self, subject: &str, body: Option<&str>, amend: bool, signing: SigningMode) -> Result<CommitOutcome> {
let message = match body.map(str::trim).filter(|b| !b.is_empty()) {
Some(b) => format!("{}\n\n{}\n", subject.trim(), b),
None => format!("{}\n", subject.trim()),
Expand Down Expand Up @@ -82,6 +96,18 @@ pub(crate) fn temp_message_file(message: &str) -> Result<std::path::PathBuf> {
))
}

fn action_subject(subject: &str) -> String {
let line = subject.lines().next().unwrap_or("").trim();
let mut short: String = line.chars().take(72).collect();
if line.chars().count() > 72 {
short.push('…');
}
if short.is_empty() {
short = "(no message)".to_string();
}
short
}

/// Run a blocking `git` subcommand in `cwd`, returning trimmed stdout and
/// mapping a non-zero exit to its combined stderr+stdout. Mirrors the helpers
/// in [`history`](crate::history) and `stash`; `GIT_TERMINAL_PROMPT=0` keeps a
Expand Down
65 changes: 63 additions & 2 deletions crates/strand-core/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ impl Repo {
/// not a failure), `Ok(false)` when it applied cleanly, and `Err` only for
/// a real failure (e.g. picking a merge commit without `-m`).
pub fn cherry_pick(&self, commits: &[String], mainline: Option<u32>) -> Result<bool> {
crate::journal::record(
self,
crate::journal::GitOp::CherryPick,
cherry_pick_label(commits),
true,
|| self.cherry_pick_inner(commits, mainline),
)
}

fn cherry_pick_inner(&self, commits: &[String], mainline: Option<u32>) -> Result<bool> {
if commits.is_empty() {
return Err(Error::Other("cherry-pick: no commits given".into()));
}
Expand Down Expand Up @@ -204,6 +214,16 @@ impl Repo {
/// (left in progress for resolution), `Ok(false)` on a clean merge, and
/// `Err` for a real failure (dirty tree, unrelated histories, …).
pub fn merge(&self, refname: &str, mode: MergeMode) -> Result<bool> {
crate::journal::record(
self,
crate::journal::GitOp::Merge,
format!("Merge {refname}"),
true,
|| self.merge_inner(refname, mode),
)
}

fn merge_inner(&self, refname: &str, mode: MergeMode) -> Result<bool> {
validate_ref(refname)?;
let mut args = vec!["merge"];
match mode {
Expand All @@ -228,8 +248,19 @@ impl Repo {
/// on this call wins over any `rebase.updateRefs` the user set. A dirty
/// working tree makes git refuse — that surfaces as `Err`. `paused` is set
/// when the rebase stopped on a conflict; branch tips move only once it
/// completes.
/// completes. One journal entry covers every ref the rebase moved, so Undo
/// also puts stacked branches back.
pub fn rebase(&self, onto: &str, update_refs: bool) -> Result<RebaseOutcome> {
crate::journal::record(
self,
crate::journal::GitOp::Rebase,
format!("Rebase onto {onto}"),
true,
|| self.rebase_inner(onto, update_refs),
)
}

fn rebase_inner(&self, onto: &str, update_refs: bool) -> Result<RebaseOutcome> {
validate_ref(onto)?;
let mut args = vec!["rebase"];
push_update_refs(&mut args, update_refs)?;
Expand Down Expand Up @@ -360,7 +391,13 @@ impl Repo {
preserve_merges: bool,
update_refs: bool,
) -> Result<RebaseOutcome> {
self.interactive_rebase_inner(base, steps, preserve_merges, update_refs, false)
let label = match base {
Some(base) => format!("Rebase onto {base}"),
None => "Rebase from root".to_string(),
};
crate::journal::record(self, crate::journal::GitOp::Rebase, label, true, || {
self.interactive_rebase_inner(base, steps, preserve_merges, update_refs, false)
})
}

fn interactive_rebase_inner(
Expand Down Expand Up @@ -641,7 +678,21 @@ impl Repo {
/// range is refused before anything is written. Other local branches whose
/// tips sit in the rewritten range move with it (`--update-refs`), so a
/// stacked branch never keeps the pre-amend commits.
///
/// The fixup commit and the rebase are one Git Action History entry, so a
/// single Undo returns to the pre-amend tip, index and stacked branches.
pub fn amend_into_commit(&self, target: &str) -> Result<bool> {
let short: String = target.chars().take(7).collect();
crate::journal::record(
self,
crate::journal::GitOp::Amend,
format!("Amend staged changes into {short}"),
true,
|| self.amend_into_commit_inner(target),
)
}

fn amend_into_commit_inner(&self, target: &str) -> Result<bool> {
if let Some(operation) = self.operation_in_progress() {
return Err(Error::Other(format!(
"cannot amend into a commit while {operation} is in progress"
Expand Down Expand Up @@ -1000,6 +1051,16 @@ fn is_ancestor(cwd: &Path, maybe_ancestor: &str) -> Result<bool> {
Ok(status.success())
}

fn cherry_pick_label(commits: &[String]) -> String {
if commits.len() == 1 {
let oid = &commits[0];
let short = &oid[..oid.len().min(7)];
format!("Cherry-pick {short}")
} else {
format!("Cherry-pick {} commits", commits.len())
}
}

fn rebase_action_name(action: RebaseAction) -> &'static str {
match action {
RebaseAction::Pick => "pick",
Expand Down
Loading
Loading