From cf28eec718d525fb6c80dce30378032f30fcd6b0 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 19 Feb 2026 11:19:07 -0800 Subject: [PATCH] Store and display prompt in session; improve list formatting with tilde paths and prompt column --- src/cli.ts | 16 ++++++++++++++-- src/state.ts | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 219118c..bddf148 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -124,10 +124,12 @@ program process.exit(1) } + const effectivePrompt = opts.print || prompt await state.setSession(root, { branch, worktree: worktreeAbs, created_at: new Date().toISOString(), + ...(effectivePrompt ? { prompt: effectivePrompt } : {}), }) if (opts.print) { @@ -167,10 +169,15 @@ program return } + const home = homedir() + const tilde = (p: string) => p.startsWith(home) ? "~" + p.slice(home.length) : p + const branchWidth = Math.max(6, ...sessions.map((s) => s.branch.length)) - console.log(`${"BRANCH".padEnd(branchWidth)} WORKTREE`) + const worktreeWidth = Math.max(8, ...sessions.map((s) => tilde(s.worktree).length + 1)) + console.log(`${"BRANCH".padEnd(branchWidth)} ${"WORKTREE".padEnd(worktreeWidth)} PROMPT`) for (const s of sessions) { - console.log(`${s.branch.padEnd(branchWidth)} ${s.worktree}/`) + const wt = tilde(s.worktree) + "/" + console.log(`${s.branch.padEnd(branchWidth)} ${wt.padEnd(worktreeWidth)} ${s.prompt ?? ""}`) } }) @@ -191,6 +198,11 @@ program process.exit(1) } + const effectivePrompt = opts.print || prompt + if (effectivePrompt) { + await state.setSession(root, { ...session, prompt: effectivePrompt }) + } + const spin = spinner("Starting container") await vm.ensure((msg) => { spin.text = msg }) diff --git a/src/state.ts b/src/state.ts index 09c34f6..40bb41c 100644 --- a/src/state.ts +++ b/src/state.ts @@ -4,6 +4,7 @@ export interface Session { branch: string worktree: string created_at: string + prompt?: string } export interface State {