A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
show only daemon-resident sessions in the agents view (#295)
ktb03fd3ef03e4
diff --git a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts b/packages/coding-agent/src/modes/agents-view/agents-view-mode.tsindex 216c3e62f0..86319dd648 100644--- a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts+++ b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts@@ -153,17 +153,10 @@ export function createAgentsViewResumeConfig(return resumeConfig;}-export function createAgentsViewListCommand(- config: AgentSessionRuntimeConfig,-): Extract<DaemonCommand, { type: "list" }> {- // `all` makes the daemon merge on-disk sessions with in-memory ones; without it- // only daemon-resident sessions return and live sessions saved to disk are lost- // from the view. No cwd is set so the fleet view spans every directory.- const command: Extract<DaemonCommand, { type: "list" }> = { type: "list", all: true };- if (config.sessionDir) {- command.sessionDir = config.sessionDir;- }- return command;+export function createAgentsViewListCommand(): Extract<DaemonCommand, { type: "list" }> {+ // Omitting `all` returns daemon-resident sessions only; on-disk ones come back+ // via /resume.+ return { type: "list" };}// Status messages render in a single-row hint slot below the editor; embedded@@ -1575,7 +1568,7 @@ class AgentsViewMode implements Component, Focusable {private async refreshSessions(): Promise<void> {const client = this.requireClient();try {- const response = await client.request(createAgentsViewListCommand(this.options.config));+ const response = await client.request(createAgentsViewListCommand());const data = requireDaemonData(response);const sessions = expectSessionList(data);const visibleSessions = sessions.filter((summary) =>diff --git a/packages/coding-agent/src/modes/daemon/daemon-mode.ts b/packages/coding-agent/src/modes/daemon/daemon-mode.tsindex 53f1a4d806..0accec4189 100644--- a/packages/coding-agent/src/modes/daemon/daemon-mode.ts+++ b/packages/coding-agent/src/modes/daemon/daemon-mode.ts@@ -279,43 +279,9 @@ export class AgentDaemon {this.registerSignalHandlers();this.summarizer.start();this.log(`Prime Agent daemon listening on ${this.socketPath}`);- void this.restoreActiveSessions().finally(() => {- if (!this.shuttingDown) {- this.cronScheduler.start();- }- });- }-- /**- * Reload sessions that were daemon-resident when the previous daemon- * exited (clean shutdown or crash). Runs in the background after the- * socket starts listening so startup latency is unaffected; clients see- * restored sessions appear in list results as each one loads.- */- private async restoreActiveSessions(): Promise<void> {- let saved: SessionInfo[];- try {- saved = await SessionManager.listAll(undefined, this.options.defaultSessionConfig.sessionDir);- } catch (error) {- this.log(`Failed to scan sessions for restore: ${error instanceof Error ? error.message : String(error)}`);- return;- }- for (const info of saved) {- // Empty sessions carry no work worth restoring; leaving them out keeps- // abandoned create-and-quit sessions from resurrecting on every restart.- if (info.state?.status !== "active" || info.messageCount === 0) {- continue;- }- if (this.shuttingDown) {- return;- }- try {- await this.createRuntime({ type: "create", sessionPath: info.path });- } catch (error) {- this.log(- `Failed to restore session ${info.path}: ${error instanceof Error ? error.message : String(error)}`,- );- }+ // No startup restore: on-disk sessions return only via /resume or --resume.+ if (!this.shuttingDown) {+ this.cronScheduler.start();}}@@ -353,16 +319,6 @@ export class AgentDaemon {if (name) {state.runtime.session.setSessionName(name);}- if (runtime.metadata.kind !== "subagent") {- // Mark the session as daemon-resident so a restarted daemon can- // restore it. Closes for kill/completed/replaced flip this back to- // sleep; clean shutdowns leave it in place on purpose.- try {- runtime.session.sessionManager.appendSessionState({ status: "active" });- } catch {- // Marking is best-effort; the session still works unrestored.- }- }// Restore the last persisted status so it shows before the first sweep.this.summarizer.seed(state);return state;@@ -1609,6 +1565,7 @@ export class AgentDaemon {// draft closed via kill/completed is never wiped.const isEmptyDraftSession = reason !== "shutdown" && this.isEmptyDraftContent(state);let persistError: unknown;+ // Clean shutdown leaves the session un-archived so it stays in the resume list.if (reason !== "shutdown" && !isEmptyDraftSession) {try {state.runtime.session.sessionManager.appendSessionState({ status: "archived" });diff --git a/packages/coding-agent/test/agents-view-state.test.ts b/packages/coding-agent/test/agents-view-state.test.tsindex 54d287d7ab..0738f73f65 100644--- a/packages/coding-agent/test/agents-view-state.test.ts+++ b/packages/coding-agent/test/agents-view-state.test.ts@@ -506,13 +506,8 @@ describe("agents view state", () => {expect(resumeConfig.cwd).toBe("/tmp/launch");});- test("requests all sessions (in-memory + on-disk) for the agents view refresh", () => {- expect(createAgentsViewListCommand({ cwd: "/tmp/project" })).toEqual({ type: "list", all: true });- expect(createAgentsViewListCommand({ cwd: "/tmp/project", sessionDir: "/tmp/sessions" })).toEqual({- type: "list",- all: true,- sessionDir: "/tmp/sessions",- });+ test("requests only daemon-resident sessions for the agents view refresh", () => {+ expect(createAgentsViewListCommand()).toEqual({ type: "list" });});test("derives the reply headline from the first line of the latest assistant text", () => {