Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

Bring back bare --resume and the /resume command (#1280)

Sebastian Müller2ea5ae091087
diff --git a/README.md b/README.md
index b5646bd6cb..971a5d6ff6 100644
--- a/README.md
+++ b/README.md
@@ -70,7 +70,7 @@ Useful commands:
```bash
prime-agent agents # Browse running, idle, and saved sessions
prime-agent attach <agent> # Reattach to a running session
-prime-agent --resume <path|id> # Resume a saved session
+prime-agent --resume [path|id] # Browse sessions or resume one directly
prime-agent status # Inspect background service state
prime-agent doctor [--fix] # Inspect or repair background services
prime-agent update [--force] # Update Prime Agent
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index 622cc90e32..08322c0f15 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -5,6 +5,7 @@
- Changed the agents view to sort idle and inactive sessions by last message time, newest first, while keeping running agents in stable creation order.
- Fixed `openai-codex` models being invisible to `rlm` subagents and `find_models` because model discovery reported Prime Agent's own version as the Codex client version ([#1375](https://github.com/PrimeIntellect-ai/prime-agent/pull/1375) by [@bilelrais](https://github.com/bilelrais)).
- Added a working hint that recommends sharing traces with Prime Intellect to help train open-source LLMs.
+- Restored bare `prime-agent --resume` opening the agents view and the `/resume [id|path]` slash command; bare commands open the agents view and an argument resumes that session in place.
- Fixed URLs not opening on click in fullscreen mode on terminals such as Ghostty; clicking a link in the transcript, dock, or overlays now opens it in the browser.
- Fixed ctrl+p ("Toggle agent message expansion") only toggling received agent messages; it now expands and collapses sent agent messages together with received ones.
diff --git a/packages/coding-agent/README.md b/packages/coding-agent/README.md
index 4a07d4de1f..8788fe95de 100644
--- a/packages/coding-agent/README.md
+++ b/packages/coding-agent/README.md
@@ -150,7 +150,7 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist
| `/effort` | Set reasoning/thinking level |
| `/scoped-models` | Enable/disable models for Ctrl+P cycling |
| `/settings` | Thinking level, theme, message delivery, transport |
-| `/resume` | Open the searchable session view |
+| `/resume [id\|path]` | Open the agents view, or resume a session directly |
| `/new`, `/clear` | Start a new session |
| `/name <name>` | Set session display name |
| `/session` | Show session info (file, ID, messages) |
diff --git a/packages/coding-agent/docs/usage.md b/packages/coding-agent/docs/usage.md
index 196ac8b9e5..3884659334 100644
--- a/packages/coding-agent/docs/usage.md
+++ b/packages/coding-agent/docs/usage.md
@@ -42,7 +42,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
| `/effort` | Set the reasoning/thinking level |
| `/scoped-models` | Enable/disable models for Ctrl+P cycling |
| `/settings` | Thinking level, theme, message delivery, transport |
-| `/resume` | Pick from previous sessions |
+| `/resume [id\|path]` | Open the agents view, or resume a session directly |
| `/new` | Start a new session |
| `/name <name>` | Set session display name |
| `/session` | Show session file, ID, and message counts |
diff --git a/packages/coding-agent/src/cli/command-registry.ts b/packages/coding-agent/src/cli/command-registry.ts
index dff1ee4e3d..c11a4de382 100644
--- a/packages/coding-agent/src/cli/command-registry.ts
+++ b/packages/coding-agent/src/cli/command-registry.ts
@@ -186,7 +186,7 @@ const TOP_LEVEL_OPTION_GROUPS: ReadonlyArray<{ heading: string; options: readonl
heading: "Session options",
options: [
["-c, --continue", "Continue the previous session"],
- ["-r, --resume <path|id>", "Resume a saved session"],
+ ["-r, --resume [path|id]", "Open the agents view, or resume a saved session"],
["--fork <path|id>", "Fork a saved session into a new session"],
["--session-dir <dir>", "Use a custom session directory"],
["--no-session", "Do not save the session"],
diff --git a/packages/coding-agent/src/core/slash-commands.ts b/packages/coding-agent/src/core/slash-commands.ts
index a3478361b3..70351384dc 100644
--- a/packages/coding-agent/src/core/slash-commands.ts
+++ b/packages/coding-agent/src/core/slash-commands.ts
@@ -186,6 +186,12 @@ const CANONICAL_BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [
takesArgument: true,
},
{ name: "heartbeats", description: "View and manage all user and agent heartbeats" },
+ {
+ name: "resume",
+ description: "Open the agents view, or resume a session by id or path",
+ argumentHint: "[id|path]",
+ takesArgument: true,
+ },
{ name: "reload", description: "Reload keybindings, extensions, skills, prompts, and themes" },
{
name: "fullscreen",
diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts
index 6315d0ad7e..adb9a1a028 100644
--- a/packages/coding-agent/src/main.ts
+++ b/packages/coding-agent/src/main.ts
@@ -166,8 +166,8 @@ export function shouldRejectNonInteractiveAttach(attachAgent: string | undefined
return attachAgent !== undefined && appMode !== "interactive";
}
-export function shouldRejectBareResume(resume: true | string | undefined): boolean {
- return resume === true;
+export function shouldRejectNonInteractiveBareResume(resume: true | string | undefined, appMode: AppMode): boolean {
+ return resume === true && appMode !== "interactive";
}
function resolveAppMode(parsed: Args, stdinIsTTY: boolean): AppMode {
@@ -253,13 +253,12 @@ export interface AgentsViewStartupDecision {
}
export function shouldOpenAgentsViewForDaemonInteractive(options: AgentsViewStartupDecision): boolean {
+ const bareResume = options.resume === true;
+ const requestsAgentsView = bareResume || (options.explicitAgentsView && !options.needsOnboarding);
return (
options.useDaemonInteractive &&
- // `prime-agent` opens a new chat by default; the unified agents view is reached via
- // left-arrow from a session or requested explicitly (`agents`).
- !!options.explicitAgentsView &&
- !options.needsOnboarding &&
- // A resume selector resolves and opens its target directly.
+ // A selector, continuation, or fork must open its target directly rather than the agents view.
+ !!requestsAgentsView &&
typeof options.resume !== "string" &&
!options.continue &&
!options.fork
@@ -276,7 +275,12 @@ export interface DaemonInteractiveSessionManagerDecision {
export function shouldUseEphemeralSessionManagerForDaemonInteractive(
options: DaemonInteractiveSessionManagerDecision,
): boolean {
- return !options.hasActiveDaemonSession && options.resume === undefined && !options.continue && !options.fork;
+ return (
+ !options.hasActiveDaemonSession &&
+ (options.resume === undefined || options.resume === true) &&
+ !options.continue &&
+ !options.fork
+ );
}
export interface DaemonActiveSessionLookupDecision {
@@ -1077,10 +1081,8 @@ export async function main(args: string[], options?: MainOptions) {
console.error(chalk.red("Error: attach requires an interactive terminal"));
process.exit(1);
}
- if (shouldRejectBareResume(parsed.resume)) {
- console.error(
- chalk.red("Error: --resume requires a session id or path; browse sessions with left-arrow from a chat"),
- );
+ if (shouldRejectNonInteractiveBareResume(parsed.resume, appMode)) {
+ console.error(chalk.red("Error: --resume without a session selector requires an interactive terminal"));
process.exit(1);
}
setLogContext({ mode: appMode });
@@ -1640,7 +1642,7 @@ export async function main(args: string[], options?: MainOptions) {
printTimings();
await runAcpMode(runtime);
} else if (appMode === "interactive") {
- if (explicitAgentsView) {
+ if (explicitAgentsView || parsed.resume === true) {
console.error(chalk.yellow("Warning: the agents view needs the daemon; opening a normal chat instead"));
}
if (scopedModels.length > 0 && (parsed.verbose || !settingsManager.getQuietStartup())) {
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index 0353004eeb..db3d89d006 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -116,6 +116,7 @@ import { resolvePrimeInferencePostLoginModelAction } from "../../core/prime-infe
import { parseCommandArgs } from "../../core/prompt-templates.js";
import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
import { SessionImportFileNotFoundError } from "../../core/session-import-errors.js";
+import { resolveSessionPath, SessionSelectorError, SessionSelectorNotFoundError } from "../../core/session-resolver.js";
import { parseSkillBlock } from "../../core/skill-blocks.js";
import {
BUILTIN_SLASH_COMMANDS,
@@ -4849,6 +4850,11 @@ export class InteractiveMode {
await this.handleClearCommand(options);
return;
}
+ if (commandName === "resume") {
+ this.editor.setText("");
+ await this.handleResumeCommand(commandArgs);
+ return;
+ }
if (commandName === "reload" && !commandArgs) {
this.editor.setText("");
await this.handleReloadCommand();
@@ -8447,6 +8453,30 @@ export class InteractiveMode {
});
}
+ private async handleResumeCommand(args: string): Promise<void> {
+ const selector = args.trim();
+ if (!selector) {
+ await this.requestAgentsView();
+ return;
+ }
+ let sessionPath: string;
+ try {
+ sessionPath = (await resolveSessionPath(selector, this.getCurrentCwd(), this.connectionState?.sessionDir))
+ .path;
+ } catch (error) {
+ if (error instanceof SessionSelectorError) {
+ const suggestion =
+ error instanceof SessionSelectorNotFoundError && error.suggestion
+ ? ` Did you mean '${error.suggestion}'?`
+ : "";
+ this.showError(`${error.message}.${suggestion}`);
+ return;
+ }
+ throw error;
+ }
+ await this.handleResumeSession(sessionPath);
+ }
+
private async handleResumeSession(
sessionPath: string,
options?: Parameters<ExtensionCommandContext["switchSession"]>[1],
diff --git a/packages/coding-agent/test/interactive-mode-resume-command.test.ts b/packages/coding-agent/test/interactive-mode-resume-command.test.ts
new file mode 100644
index 0000000000..b2d7ed84ba
--- /dev/null
+++ b/packages/coding-agent/test/interactive-mode-resume-command.test.ts
@@ -0,0 +1,69 @@
+import { mkdtempSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { afterAll, describe, expect, it, vi } from "vitest";
+import { InteractiveMode } from "../src/modes/interactive/interactive-mode.js";
+
+type InteractiveModePrototype = {
+ handleResumeCommand(this: ResumeCommandContext, args: string): Promise<void>;
+};
+
+type ResumeCommandContext = {
+ requestAgentsView: () => Promise<void>;
+ handleResumeSession: (sessionPath: string) => Promise<{ cancelled: boolean }>;
+ showError: (message: string) => void;
+ getCurrentCwd: () => string;
+ connectionState: { sessionDir?: string } | undefined;
+};
+
+const interactiveModePrototype = InteractiveMode.prototype as unknown as InteractiveModePrototype;
+
+const emptySessionDir = mkdtempSync(join(tmpdir(), "resume-command-test-"));
+
+afterAll(() => {
+ rmSync(emptySessionDir, { recursive: true, force: true });
+});
+
+function makeContext() {
+ return {
+ requestAgentsView: vi.fn<() => Promise<void>>(async () => undefined),
+ handleResumeSession: vi.fn<(sessionPath: string) => Promise<{ cancelled: boolean }>>(async () => ({
+ cancelled: false,
+ })),
+ showError: vi.fn<(message: string) => void>(),
+ getCurrentCwd: () => emptySessionDir,
+ connectionState: { sessionDir: emptySessionDir },
+ } satisfies ResumeCommandContext;
+}
+
+describe("InteractiveMode /resume command", () => {
+ it("opens the agents view for bare /resume", async () => {
+ const context = makeContext();
+
+ await interactiveModePrototype.handleResumeCommand.call(context, " ");
+
+ expect(context.requestAgentsView).toHaveBeenCalledTimes(1);
+ expect(context.handleResumeSession).not.toHaveBeenCalled();
+ expect(context.showError).not.toHaveBeenCalled();
+ });
+
+ it("resumes a session path argument in place", async () => {
+ const context = makeContext();
+
+ await interactiveModePrototype.handleResumeCommand.call(context, "/tmp/session.jsonl");
+
+ expect(context.handleResumeSession).toHaveBeenCalledWith("/tmp/session.jsonl");
+ expect(context.requestAgentsView).not.toHaveBeenCalled();
+ expect(context.showError).not.toHaveBeenCalled();
+ });
+
+ it("shows a non-fatal error for an unknown session selector", async () => {
+ const context = makeContext();
+
+ await interactiveModePrototype.handleResumeCommand.call(context, "no-such-session");
+
+ expect(context.showError).toHaveBeenCalledWith(expect.stringContaining("No session found matching"));
+ expect(context.handleResumeSession).not.toHaveBeenCalled();
+ expect(context.requestAgentsView).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.ts
index 55c9551d03..3d8ae677ec 100644
--- a/packages/coding-agent/test/interactive-mode-status.test.ts
+++ b/packages/coding-agent/test/interactive-mode-status.test.ts
@@ -623,6 +623,7 @@ type SubmitHandlerHarness = {
isBashRunning: () => boolean;
patchConnectionState: (patch: Record<string, unknown>) => void;
requestAgentsView: () => Promise<void>;
+ handleResumeCommand: (args: string) => Promise<void>;
agentConnection: {
prompt: (message: string) => Promise<void>;
executeBash: (command: string, options?: { excludeFromContext?: boolean }) => Promise<void>;
@@ -642,6 +643,7 @@ function createSubmitHandlerHarness(overrides: Partial<SubmitHandlerHarness> = {
patchConnectionState: vi.fn(),
promptStashState: {},
requestAgentsView: vi.fn(async () => {}),
+ handleResumeCommand: vi.fn(async () => {}),
promptStash: undefined,
pastedImages: new Map(),
getPromptStashImages: vi.fn(() => []),
@@ -1538,13 +1540,14 @@ describe("InteractiveMode connection events", () => {
expect(flushPendingBashComponents).toHaveBeenCalledOnce();
});
- test("sends /resume as plain prompt text now that the command is retired", async () => {
+ test("routes /resume to the resume command handler", async () => {
const fakeThis = createSubmitHandlerHarness();
- await fakeThis.defaultEditor.onSubmit?.("/resume unexpected");
+ await fakeThis.defaultEditor.onSubmit?.("/resume abc123");
+ expect(fakeThis.handleResumeCommand).toHaveBeenCalledWith("abc123");
expect(fakeThis.showError).not.toHaveBeenCalled();
- expect(fakeThis.requestAgentsView).not.toHaveBeenCalled();
+ expect(fakeThis.agentConnection.prompt).not.toHaveBeenCalled();
});
test("renderCurrentSessionState waits for replacement handling before rendering", async () => {
diff --git a/packages/coding-agent/test/main-interactive-routing.test.ts b/packages/coding-agent/test/main-interactive-routing.test.ts
index 8486582f0f..5393a358b3 100644
--- a/packages/coding-agent/test/main-interactive-routing.test.ts
+++ b/packages/coding-agent/test/main-interactive-routing.test.ts
@@ -16,8 +16,8 @@ import {
shouldEnsureDaemonBeforeActiveSessionLookup,
shouldEnsureInteractiveDaemonForStartup,
shouldOpenAgentsViewForDaemonInteractive,
- shouldRejectBareResume,
shouldRejectNonInteractiveAttach,
+ shouldRejectNonInteractiveBareResume,
shouldUseDaemonClient,
shouldUseDaemonClientRuntime,
shouldUseDaemonInteractive,
@@ -127,9 +127,10 @@ describe("interactive startup routing", () => {
expect(shouldRejectNonInteractiveAttach("worker", "print")).toBe(true);
expect(shouldRejectNonInteractiveAttach("worker", "interactive")).toBe(false);
expect(shouldRejectNonInteractiveAttach(undefined, "print")).toBe(false);
- expect(shouldRejectBareResume(true)).toBe(true);
- expect(shouldRejectBareResume("session-id")).toBe(false);
- expect(shouldRejectBareResume(undefined)).toBe(false);
+ expect(shouldRejectNonInteractiveBareResume(true, "print")).toBe(true);
+ expect(shouldRejectNonInteractiveBareResume(true, "rpc")).toBe(true);
+ expect(shouldRejectNonInteractiveBareResume("session-id", "print")).toBe(false);
+ expect(shouldRejectNonInteractiveBareResume(true, "interactive")).toBe(false);
});
test("does not start the daemon for attach", () => {
@@ -183,14 +184,14 @@ describe("daemon-backed interactive session manager routing", () => {
expect(shouldOpenAgentsViewForDaemonInteractive(decision)).toBe(false);
});
- test("bare --resume no longer routes to the agents view (it is rejected at startup)", () => {
+ test.each([false, true])("opens the agents view for bare --resume (onboarding=%s)", (needsOnboarding) => {
expect(
shouldOpenAgentsViewForDaemonInteractive({
useDaemonInteractive: true,
- needsOnboarding: false,
+ needsOnboarding,
resume: true,
}),
- ).toBe(false);
+ ).toBe(true);
});
test("ensures daemon is available before probing non-path session selectors", () => {
@@ -278,8 +279,8 @@ describe("daemon-backed interactive session manager routing", () => {
expect(shouldUseEphemeralSessionManagerForDaemonInteractive(decision)).toBe(false);
});
- test("keeps bare --resume off the ephemeral local session manager", () => {
- expect(shouldUseEphemeralSessionManagerForDaemonInteractive({ resume: true })).toBe(false);
+ test("uses an ephemeral local session manager for bare --resume", () => {
+ expect(shouldUseEphemeralSessionManagerForDaemonInteractive({ resume: true })).toBe(true);
});
test("finds an active daemon session by resolved session file", () => {