feat(v0.3): O2 — resume past Claude sessions
- src/http/history.ts: listSessions() reads ~/.claude/projects/*/*.jsonl
(mtime-sorted, top 50), parseSessionMeta() extracts cwd + first user prompt
(pure, 4 unit tests); GET /sessions
- terminal-session: opts.initialInput (typed ~700ms after the shell is ready)
- tabs.newTabForResume(cwd,id): new tab in the project dir running
'claude --resume <id>'
- public/history.ts: 🕘 panel listing sessions (project · time · preview) with
Resume buttons
- Verified: /sessions returns 44 real sessions; panel lists project/time/preview.
216 tests green.
This commit is contained in:
@@ -151,7 +151,12 @@ export class TabApp {
|
||||
|
||||
/* ── tab lifecycle ───────────────────────────────────────────── */
|
||||
|
||||
private addEntry(sessionId: string | null, customTitle: string | null, cwd?: string): TabEntry {
|
||||
private addEntry(
|
||||
sessionId: string | null,
|
||||
customTitle: string | null,
|
||||
cwd?: string,
|
||||
initialInput?: string,
|
||||
): TabEntry {
|
||||
const entry: TabEntry = {
|
||||
session: null as unknown as TerminalSession,
|
||||
customTitle,
|
||||
@@ -162,6 +167,7 @@ export class TabApp {
|
||||
entry.session = new TerminalSession({
|
||||
sessionId,
|
||||
...(cwd !== undefined ? { cwd } : {}),
|
||||
...(initialInput !== undefined ? { initialInput } : {}),
|
||||
onSessionId: () => this.persist(),
|
||||
// onActivity only fires for hidden (inactive) panes (see TerminalSession).
|
||||
onActivity: () => {
|
||||
@@ -198,6 +204,14 @@ export class TabApp {
|
||||
this.activate(this.tabs.length - 1)
|
||||
}
|
||||
|
||||
/** O2: open a new tab in `cwd` and run `claude --resume <id>`. */
|
||||
newTabForResume(cwd: string, sessionId: string): void {
|
||||
this.addEntry(null, null, cwd || undefined, `claude --resume ${sessionId}`)
|
||||
this.persist()
|
||||
this.rebuild()
|
||||
this.activate(this.tabs.length - 1)
|
||||
}
|
||||
|
||||
activate(i: number): void {
|
||||
if (i < 0 || i >= this.tabs.length) return
|
||||
this.maybeAskNotify() // first switch is a user gesture — request notif permission
|
||||
|
||||
Reference in New Issue
Block a user