Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/agent/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ export async function interactiveSession(

// Session persistence — reuse existing session ID when resuming, else create new
const sessionId = config.resumeSessionId || createSessionId();
config.onSessionStart?.(sessionId);
let turnCount = 0;

// Resume: hydrate history from the saved JSONL transcript.
Expand Down
2 changes: 2 additions & 0 deletions src/agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ export interface AgentConfig {
baseModel?: string;
/** Resume an existing session by ID — loads prior history and keeps appending to the same JSONL */
resumeSessionId?: string;
/** Notify callers of the concrete session ID once created/resolved. */
onSessionStart?: (sessionId: string) => void;
/**
* Optional channel tag persisted to SessionMeta. Lets non-CLI drivers
* (Telegram bot, Discord bot, future ingresses) find their own sessions
Expand Down
17 changes: 17 additions & 0 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ async function runWithInkUI(
agentConfig.onAskUser = (question, options) =>
ui.requestAskUser(question, options);
agentConfig.onModelChange = (model) => ui.updateModel(model);
let activeSessionId = agentConfig.resumeSessionId;
agentConfig.onSessionStart = (sessionId) => { activeSessionId = sessionId; };

// Wire up background balance fetch to UI
onBalanceReady?.((bal) => ui.updateBalance(bal));
Expand Down Expand Up @@ -562,6 +564,21 @@ async function runWithInkUI(
}
} catch { /* stats unavailable */ }

let savedSessionId: string | undefined;
if (activeSessionId) {
try {
const { loadSessionMeta } = await import('../session/storage.js');
const meta = loadSessionMeta(activeSessionId);
if ((meta?.messageCount ?? 0) > 0) savedSessionId = activeSessionId;
} catch { /* session hint is best-effort */ }
}

if (savedSessionId) {
console.log(chalk.dim(`\n Session: ${savedSessionId}`));
console.log(chalk.dim(` Resume: franklin --resume ${savedSessionId}`));
console.log(chalk.dim(' Latest: franklin --continue'));
}

console.log(chalk.dim('\nGoodbye.\n'));
}

Expand Down
Loading
Loading