Track activity markers during merge/rebase

This commit is contained in:
Chris Wanstrath 2026-03-11 22:13:55 -07:00
parent 9994782748
commit 6d86a988f7
3 changed files with 12 additions and 0 deletions

View File

@ -141,6 +141,7 @@ export async function mergeAndClose(branch: string, opts?: { squash?: boolean; f
try {
await vm.ensure((msg) => { spin.text = msg })
if (session) await vm.setActivity(session.worktree, branch)
await resolveConflicts(conflicts, root, (file) => { spin.text = `Resolving ${file}` })
if (opts?.squash) {
@ -154,6 +155,8 @@ export async function mergeAndClose(branch: string, opts?: { squash?: boolean; f
spin.fail(message)
await git.abortMerge(root)
process.exit(1)
} finally {
if (session) await vm.clearActivity(session.worktree, branch)
}
if (session) await teardownSession(root, branch, session.worktree)

View File

@ -33,6 +33,7 @@ export async function action(branch: string) {
try {
await vm.ensure((msg) => { resolveSpin.text = msg })
await vm.setActivity(worktree, branch)
let round = 1
while (conflicts.length > 0) {
@ -53,5 +54,7 @@ export async function action(branch: string) {
resolveSpin.fail(String((err as Error).message ?? err))
await git.rebaseAbort(worktree)
process.exit(1)
} finally {
await vm.clearActivity(worktree, branch)
}
}

View File

@ -358,6 +358,12 @@ export async function isClaudeActive(worktree: string, branch: string): Promise<
}
}
/** Set the activity marker for a worktree (e.g. during conflict resolution). */
export async function setActivity(worktree: string, branch: string): Promise<void> {
const file = `${dirname(worktree)}/.activity-${branch}`
await Bun.write(file, "active\n")
}
/** Remove the activity marker file for a worktree. */
export async function clearActivity(worktree: string, branch: string): Promise<void> {
const file = `${dirname(worktree)}/.activity-${branch}`