v0.5.1: print a resume hint on exit

Every exit path (Ctrl+C, /exit, SIGTERM/SIGHUP) now prints "Resume this
conversation later with: locode --resume <id>" once Ink has released the
terminal, so the session id isn't lost the moment the process ends.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5 committed 2026-07-13 16:11:07 +09:00
1 parent 0bc9480c1d
commit ba0a7e44d1
3 files changed
+24 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "locode",
"version": "0.5.0",
"version": "0.5.1",
"description": "Agentic coding CLI for local models served via Ollama and LM Studio",
"type": "module",
"bin": {
+8 -2
View File
@@ -80,6 +80,9 @@ export interface AppProps {
resumeSessionId?: string;
interactiveResume?: boolean;
extraToolsPromise: Promise<ToolDef[]>;
/** Reported once a session actually exists, so index.tsx can print a "resume this later" hint
* on exit — it lives outside the Ink render tree, so it has no other way to know the session id. */
onSessionIdChange?: (id: string) => void;
}
interface PendingPermission {
@@ -100,6 +103,7 @@ export function App({
resumeSessionId,
interactiveResume,
extraToolsPromise,
onSessionIdChange,
}: AppProps) {
const { exit } = useApp();
const [staticItems, setStaticItems] = useState<HistoryItem[]>([]);
@@ -271,6 +275,7 @@ export function App({
resolveAutoCompactThreshold(),
projectInstructions,
);
onSessionIdChange?.(sessionRef.current.id);
push({ kind: "banner", cwd, model, backend: baseURLRef.current });
if (projectInstructions) push({ kind: "notice", text: "Loaded project instructions from CLAUDE.md/AGENTS.md." });
notifyIfContextWindowGuessed(model, contextWindow);
@@ -291,7 +296,7 @@ export function App({
}
}
},
[cwd, toolModeOverride, modelList, exit, push, extraToolsPromise, notifyIfContextWindowGuessed],
[cwd, toolModeOverride, modelList, exit, push, extraToolsPromise, notifyIfContextWindowGuessed, onSessionIdChange],
);
const initSessionFromRecord = useCallback(
@@ -321,6 +326,7 @@ export function App({
resolveAutoCompactThreshold(),
projectInstructions,
);
onSessionIdChange?.(sessionRef.current.id);
push({
kind: "banner",
cwd,
@@ -351,7 +357,7 @@ export function App({
fetchModelsForPicker();
}
},
[cwd, push, fetchModelsForPicker, extraToolsPromise, notifyIfContextWindowGuessed],
[cwd, push, fetchModelsForPicker, extraToolsPromise, notifyIfContextWindowGuessed, onSessionIdChange],
);
// Decide the startup path once on mount: resume a specific session, show a resume
+15
View File
@@ -41,6 +41,11 @@ export async function runInkApp(opts: RunInkAppOptions): Promise<void> {
.then((mcpTools) => [...mcpTools, ...pluginTools])
.catch(() => pluginTools);
// Populated once a session actually exists (see onSessionIdChange below) — lives outside the
// Ink render tree so cleanup() can still read it after instance.unmount() has torn everything
// in App.tsx down.
let currentSessionId: string | null = null;
// Start the UI immediately — no blocking network calls before rendering.
// Model listing happens inside the App component so the user sees the UI right away.
//
@@ -59,6 +64,9 @@ export async function runInkApp(opts: RunInkAppOptions): Promise<void> {
resumeSessionId={opts.resumeSessionId}
interactiveResume={opts.interactiveResume}
extraToolsPromise={extraToolsPromise}
onSessionIdChange={(id) => {
currentSessionId = id;
}}
/>,
);
@@ -78,6 +86,13 @@ export async function runInkApp(opts: RunInkAppOptions): Promise<void> {
// Best-effort — fires on every exit path, so there isn't always a specific session id to attach
// (e.g. exiting from the model picker before a session ever started).
await runHooksForEvent("SessionEnd", { sessionId: "", cwd: opts.cwd }, {}).catch(() => {});
// Printed after instance.unmount() has restored the terminal (both the Ctrl+C and SIGTERM/SIGHUP
// paths reach here only once Ink has released the screen), so this lands as a normal trailing
// console line rather than being swallowed by Ink's own rendering. Skipped if no session ever
// started (e.g. the user exited from the model picker) — there's nothing to resume.
if (currentSessionId) {
console.log(`\nResume this conversation later with: locode --resume ${currentSessionId}`);
}
};
const onTerminate = () => {
instance.unmount();