From 9b6245d9c90a35c0c42b5b7d19dfae2cd2af56ce Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 19 Feb 2026 19:22:24 -0800 Subject: [PATCH] Add branch name prefix to spinner output --- src/cli.ts | 18 +++++++++--------- src/spinner.ts | 9 +++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 8e862eb..8861b18 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -19,8 +19,8 @@ program.name("sandlot").description("Branch-based development with git worktrees // ── save helper ───────────────────────────────────────────────────── /** Stage all changes, generate a commit message, and commit. Returns true on success. */ -async function saveChanges(worktree: string, message?: string): Promise { - const spin = spinner("Staging changes") +async function saveChanges(worktree: string, branch: string, message?: string): Promise { + const spin = spinner("Staging changes", branch) await $`git -C ${worktree} add .`.nothrow().quiet() @@ -148,7 +148,7 @@ program process.exit(1) } - const spin = spinner("Creating worktree") + const spin = spinner("Creating worktree", branch) try { await git.createWorktree(branch, worktreeAbs, root) await mkdir(join(root, '.sandlot'), { recursive: true }) @@ -186,7 +186,7 @@ program await vm.claude(worktreeAbs, { prompt, print: opts.print }) } - if (opts.save !== false) await saveChanges(worktreeAbs) + if (opts.save !== false) await saveChanges(worktreeAbs, branch) }) // ── sandlot list ────────────────────────────────────────────────────── @@ -302,7 +302,7 @@ program await state.setSession(root, { ...session, prompt: effectivePrompt }) } - const spin = spinner("Starting container") + const spin = spinner("Starting container", branch) await vm.ensure((msg) => { spin.text = msg }) if (opts.print) { @@ -319,7 +319,7 @@ program await vm.claude(session.worktree, { prompt, print: opts.print }) } - if (opts.save !== false) await saveChanges(session.worktree) + if (opts.save !== false) await saveChanges(session.worktree, branch) }) // ── sandlot review ────────────────────────────────────────── @@ -338,7 +338,7 @@ program process.exit(1) } - const spin = spinner("Starting container") + const spin = spinner("Starting container", branch) await vm.ensure((msg) => { spin.text = msg }) const prompt = "You're a grumpy old senior software engineer. Take a look at the diff between this branch and main, then let me know your thoughts. My co-worker made these changes." @@ -398,7 +398,7 @@ program // Resolve conflicts with Claude console.log(`◆ Merge conflicts in ${conflicts.length} file(s). Resolving with Claude...`) - const spin = spinner("Starting container") + const spin = spinner("Starting container", branch) try { await vm.ensure((msg) => { spin.text = msg }) @@ -462,7 +462,7 @@ program process.exit(1) } - const ok = await saveChanges(session.worktree, message) + const ok = await saveChanges(session.worktree, branch, message) if (!ok) process.exit(1) }) diff --git a/src/spinner.ts b/src/spinner.ts index 34d7e36..4141f45 100644 --- a/src/spinner.ts +++ b/src/spinner.ts @@ -1,9 +1,10 @@ const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] -export function spinner(text: string) { +export function spinner(text: string, prefix?: string) { + const tag = prefix ? `\x1b[2m[${prefix}]\x1b[22m ` : "" let i = 0 const id = setInterval(() => { - process.stderr.write(`\r\x1b[2K${frames[i++ % frames.length]} ${text}`) + process.stderr.write(`\r\x1b[2K${frames[i++ % frames.length]} ${tag}${text}`) }, 80) return { @@ -12,11 +13,11 @@ export function spinner(text: string) { }, succeed(msg: string) { clearInterval(id) - process.stderr.write(`\r\x1b[2K✔ ${msg}\n`) + process.stderr.write(`\r\x1b[2K✔ ${tag}${msg}\n`) }, fail(msg: string) { clearInterval(id) - process.stderr.write(`\r\x1b[2K✖ ${msg}\n`) + process.stderr.write(`\r\x1b[2K✖ ${tag}${msg}\n`) }, stop() { clearInterval(id)