From 02a165dd76678960b58b8f61080f535ac9368235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Wed, 8 Apr 2026 11:57:24 +0100 Subject: [PATCH] feat(cli): add --resume and --continue flags to launch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit claudemesh launch now supports: --resume / -r — resume a previous Claude Code session --continue / -c — continue the most recent conversation When resuming, skips generating a new session ID so the mesh peer identity persists. The detectClaudeSessionId() fallback in ws/client.ts picks up the existing session UUID from the .jsonl file. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/cli/package.json | 2 +- apps/cli/src/commands/launch.ts | 19 ++++++++++++------- apps/cli/src/index.ts | 11 +++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/apps/cli/package.json b/apps/cli/package.json index dead8e3..8d7fa87 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -1,6 +1,6 @@ { "name": "claudemesh-cli", - "version": "0.8.2", + "version": "0.8.3", "description": "Claude Code MCP client for claudemesh — peer mesh messaging between Claude sessions.", "keywords": [ "claude-code", diff --git a/apps/cli/src/commands/launch.ts b/apps/cli/src/commands/launch.ts index b3eb065..d1ad664 100644 --- a/apps/cli/src/commands/launch.ts +++ b/apps/cli/src/commands/launch.ts @@ -32,6 +32,8 @@ export interface LaunchFlags { mesh?: string; "message-mode"?: string; "system-prompt"?: string; + resume?: string; + continue?: boolean; yes?: boolean; quiet?: boolean; } @@ -171,6 +173,8 @@ export async function runLaunch(flags: LaunchFlags, rawArgs: string[]): Promise< ? flags["message-mode"] as "push" | "inbox" | "off" : null), systemPrompt: flags["system-prompt"] ?? null, + resume: flags.resume ?? null, + continueSession: flags.continue ?? false, quiet: flags.quiet ?? false, skipPermConfirm: flags.yes ?? false, claudeArgs: claudePassthrough, @@ -422,16 +426,17 @@ export async function runLaunch(flags: LaunchFlags, rawArgs: string[]): Promise< // passes -y / --yes. Without it, claudemesh tools still work because // `claudemesh install` pre-approves them via allowedTools in settings.json. // This keeps permissions tight for multi-person meshes. - // Generate a stable session ID for this launch. Used by the broker to: - // - detect reconnections (same session ID = restore state) - // - disambiguate multiple peers in the same project - // - persist identity across --resume (Claude reuses the session ID) - const claudeSessionId = randomUUID(); + // Session identity: --resume reuses existing session, otherwise generate new. + // When resuming, Claude Code reuses the session ID so the mesh peer identity persists. + const isResume = args.resume !== null || args.continueSession; + const claudeSessionId = isResume ? undefined : randomUUID(); const claudeArgs = [ "--dangerously-load-development-channels", "server:claudemesh", - "--session-id", claudeSessionId, + ...(claudeSessionId ? ["--session-id", claudeSessionId] : []), + ...(args.resume ? ["--resume", args.resume] : []), + ...(args.continueSession ? ["--continue"] : []), ...(args.skipPermConfirm ? ["--dangerously-skip-permissions"] : []), ...(args.systemPrompt ? ["--system-prompt", args.systemPrompt] : []), ...filtered, @@ -445,7 +450,7 @@ export async function runLaunch(flags: LaunchFlags, rawArgs: string[]): Promise< ...process.env, CLAUDEMESH_CONFIG_DIR: tmpDir, CLAUDEMESH_DISPLAY_NAME: displayName, - CLAUDEMESH_SESSION_ID: claudeSessionId, + ...(claudeSessionId ? { CLAUDEMESH_SESSION_ID: claudeSessionId } : {}), MCP_TIMEOUT: process.env.MCP_TIMEOUT ?? "30000", MAX_MCP_OUTPUT_TOKENS: process.env.MAX_MCP_OUTPUT_TOKENS ?? "50000", ...(role ? { CLAUDEMESH_ROLE: role } : {}), diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts index 38e2091..1021072 100644 --- a/apps/cli/src/index.ts +++ b/apps/cli/src/index.ts @@ -71,6 +71,17 @@ const launch = defineCommand({ description: "Skip the --dangerously-skip-permissions confirmation", default: false, }, + resume: { + type: "string", + alias: "r", + description: "Resume a previous Claude Code session by ID, or pass `true` for interactive picker", + }, + continue: { + type: "boolean", + alias: "c", + description: "Continue the most recent conversation in this directory", + default: false, + }, quiet: { type: "boolean", description: "Suppress banner and interactive prompts",