From ff086cd4d2f21cf62f7d5305cea100fcb50a2298 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 19 Feb 2026 13:05:12 -0800 Subject: [PATCH] Enrich session list with prompts from Claude history for sessions missing one --- src/cli.ts | 21 +++++++++++++++++++++ src/vm.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 41a34ce..3cd6e2f 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -160,6 +160,27 @@ program const st = await state.load(root) const sessions = Object.values(st.sessions) + // Discover prompts from Claude history for sessions that lack one + const needsPrompt = sessions.filter(s => !s.prompt) + if (needsPrompt.length > 0 && (await vm.status()) === "running") { + try { + const result = await vm.exec(homedir() + "/.sandlot", "cat /home/ubuntu/.claude/history.jsonl 2>/dev/null") + if (result.exitCode === 0 && result.stdout) { + const entries = result.stdout.split("\n").filter(Boolean).map(line => { + try { return JSON.parse(line) } catch { return null } + }).filter(Boolean) + + for (const s of needsPrompt) { + const cPath = vm.containerPath(s.worktree) + const match = entries.find((e: any) => e.project === cPath) + if (match?.display) { + s.prompt = match.display + } + } + } + } catch {} + } + if (opts.json) { console.log(JSON.stringify(sessions, null, 2)) return diff --git a/src/vm.ts b/src/vm.ts index 7978a75..72aa6b1 100644 --- a/src/vm.ts +++ b/src/vm.ts @@ -6,7 +6,7 @@ const USER = "ubuntu" const CLAUDE_BIN = `/home/${USER}/.local/bin/claude` /** Translate a host path to its corresponding container path. */ -function containerPath(hostPath: string): string { +export function containerPath(hostPath: string): string { const home = homedir() if (hostPath.startsWith(`${home}/.sandlot`)) { return "/sandlot" + hostPath.slice(`${home}/.sandlot`.length)