xonecas.io
64875
Mc

mini-coder / commit ef0c741

feat(session): show resume command on exit

xonecas2026-03-31 ef0c741a692351a93cfc877523b9a4471b1a7813 parent 4f0311f

4 files changed

src/cli/input-loop.ts+3−3
@@ -1,8 +1,8 @@
1-import * as c from "yoctocolors";
21 import type { AgentReporter } from "../agent/reporter.ts";
32 import type { SessionRunner } from "../agent/session-runner.ts";
43
54 import { getContextWindow } from "../llm-api/providers.ts";
5+import { buildSessionExitMessage } from "../session/resume-command.ts";
66 import { runShellCommand, type ShellOutput } from "../tools/shell.ts";
77 import { handleCommand } from "./commands.ts";
88 import { resolveFileRefs } from "./file-refs.ts";
@@ -75,7 +75,7 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
7575
7676 switch (input.type) {
7777 case "eof":
78- reporter.writeText(c.dim("Goodbye."));
78+ reporter.writeText(buildSessionExitMessage(runner.session.id));
7979 return;
8080
8181 case "interrupt":
@@ -84,7 +84,7 @@ export async function runInputLoop(opts: InputLoopOptions): Promise<void> {
8484 case "command": {
8585 const result = await handleCommand(input.command, input.args, cmdCtx);
8686 if (result.type === "exit") {
87- reporter.writeText(c.dim("Goodbye."));
87+ reporter.writeText(buildSessionExitMessage(runner.session.id));
8888 return;
8989 }
9090 if (result.type === "inject-user-message") {
src/session/manager.ts+2−1
@@ -11,6 +11,7 @@ import {
1111 setSessionTitle,
1212 touchSession,
1313 } from "./db/index.ts";
14+import { buildResumeSessionHint } from "./resume-command.ts";
1415
1516 // ─── Active session ───────────────────────────────────────────────────────────
1617
@@ -74,7 +75,7 @@ function renderSessionTable(footer: string): boolean {
7475
7576 export function printSessionList(): void {
7677 const shown = renderSessionTable(
77- `${c.dim("Use")} mc --resume <id> ${c.dim("to continue a session.")}`,
78+ buildResumeSessionHint("<id>", "to continue a session."),
7879 );
7980 if (!shown) writeln(c.dim("No sessions found."));
8081 }
src/session/resume-command.test.ts+25−0
@@ -0,0 +1,25 @@
1+import { describe, expect, test } from "bun:test";
2+import { stripAnsi } from "../cli/test-helpers.ts";
3+import {
4+ buildResumeSessionCommand,
5+ buildResumeSessionHint,
6+ buildSessionExitMessage,
7+} from "./resume-command.ts";
8+
9+describe("resume command copy", () => {
10+ test("builds a short resume command", () => {
11+ expect(buildResumeSessionCommand("sess_123")).toBe("mc -r sess_123");
12+ });
13+
14+ test("builds a reusable session hint", () => {
15+ expect(
16+ stripAnsi(buildResumeSessionHint("<id>", "to continue a session.")),
17+ ).toBe("Use mc -r <id> to continue a session.");
18+ });
19+
20+ test("builds the interactive exit message", () => {
21+ expect(stripAnsi(buildSessionExitMessage("sess_123"))).toBe(
22+ "Use mc -r sess_123 to continue this session.\nGoodbye.",
23+ );
24+ });
25+});
src/session/resume-command.ts+16−0
@@ -0,0 +1,16 @@
1+import * as c from "yoctocolors";
2+
3+export function buildResumeSessionCommand(sessionId: string): string {
4+ return `mc -r ${sessionId}`;
5+}
6+
7+export function buildResumeSessionHint(
8+ sessionId: string,
9+ detail = "to continue this session.",
10+): string {
11+ return `${c.dim("Use")} ${c.cyan(buildResumeSessionCommand(sessionId))} ${c.dim(detail)}`;
12+}
13+
14+export function buildSessionExitMessage(sessionId: string): string {
15+ return `${buildResumeSessionHint(sessionId)}\n${c.dim("Goodbye.")}`;
16+}