Add progress indicator to conflict resolution

This commit is contained in:
Chris Wanstrath 2026-03-13 13:47:07 -07:00
parent 53a426778d
commit 90bb8da28e
2 changed files with 11 additions and 6 deletions

View File

@ -85,10 +85,11 @@ export async function teardownSession(root: string, branch: string, worktree: st
export async function resolveConflicts(
files: string[],
cwd: string,
onFile: (file: string) => void,
onFile: (file: string, index: number, total: number) => void,
): Promise<void> {
for (const file of files) {
onFile(file)
for (let i = 0; i < files.length; i++) {
const file = files[i]
onFile(file, i + 1, files.length)
const content = await Bun.file(join(cwd, file)).text()
const resolved = await vm.claudePipe(
@ -142,7 +143,9 @@ 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}` })
await resolveConflicts(conflicts, root, (file, i, total) => {
spin.text = total > 1 ? `(${i}/${total}) Resolving ${file}` : `Resolving ${file}`
})
if (opts?.squash) {
await squashCommit(branch, root)

View File

@ -41,8 +41,10 @@ export async function action(branch: string) {
throw new Error(`Exceeded ${MAX_REBASE_ROUNDS} conflict resolution rounds — aborting rebase`)
}
await resolveConflicts(conflicts, worktree, (file) => {
resolveSpin.text = `Resolving ${file} (round ${round})`
await resolveConflicts(conflicts, worktree, (file, i, total) => {
resolveSpin.text = total > 1
? `(${i}/${total}) Resolving ${file} (round ${round})`
: `Resolving ${file} (round ${round})`
})
conflicts = await git.rebaseContinue(worktree)