Skip to content

[Bug]: Refreshing native ACP sessions can bring back a deleted row #39330

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open Settings → Providers for an ACP agent that supports listing and deleting native sessions.
  2. Select a project with an unimported native session.
  3. Click List sessions.
  4. Click Refresh.
  5. Click Delete on the session while the refresh is still loading.
  6. Confirm the deletion.
  7. Wait for the refresh to finish.

Expected behavior

The deleted session stays off the list.

Actual behavior

The deleted row disappears and then comes back when the refresh returns an earlier list.

after deletion and refresh

failure

Impact

Minor bug or occasional failure. Users can see a deleted session again whenever a refresh reads the list before deletion and returns after deletion succeeds.

Version or commit

main at 2ab3b7f59c. The cause is at apps/web/src/components/settings/AcpSessionManagementSection.tsx:207.

Environment

Linux x64 boat.dev default machine, a fresh checkout.

Logs or stack traces

The deleted native session stays off the list
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/scripts/scenarios/acp-refresh-keeps-deleted-session-removed.e2e.ts b/scripts/scenarios/acp-refresh-keeps-deleted-session-removed.e2e.ts
new file mode 100644
index 0000000000..ae250ea008
--- /dev/null
+++ b/scripts/scenarios/acp-refresh-keeps-deleted-session-removed.e2e.ts
@@ -0,0 +1,133 @@
+// @effect-diagnostics nodeBuiltinImport:off -- The scenario supplies a local ACP agent with a gated list.
+import * as NodeHttp from "node:http";
+import * as NodePath from "node:path";
+
+import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts";
+import { expect } from "e2e";
+import * as Effect from "effect/Effect";
+
+import { T3_HOME } from "../e2e.config.ts";
+import { rpcClient, runPromise, test, WEB } from "./t3.ts";
+
+const SESSION_TITLE = "Native draft to delete";
+const ACP = `
+import { createInterface } from "node:readline";
+
+const [origin] = process.argv.slice(2);
+for await (const line of createInterface({ input: process.stdin })) {
+  const { id, method, params } = JSON.parse(line);
+  if (id === undefined) continue;
+  let result;
+  if (method === "initialize") {
+    result = {
+      protocolVersion: 1,
+      agentInfo: { name: "session-scenario", version: "1.0.0" },
+      agentCapabilities: { sessionCapabilities: { list: {}, delete: {} } },
+      authMethods: [],
+    };
+  } else if (method === "session/new") {
+    result = { sessionId: "health-probe" };
+  } else if (method === "session/list") {
+    const response = await fetch(origin + "/list");
+    const { present, title } = await response.json();
+    result = { sessions: present ? [{ sessionId: "native-draft", cwd: params.cwd, title }] : [] };
+  } else if (method === "session/delete") {
+    if (params.sessionId === "native-draft") await fetch(origin + "/delete");
+    result = {};
+  } else {
+    process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, error: { code: -32601, message: "Method not found" } }) + "\\n");
+    continue;
+  }
+  process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, result }) + "\\n");
+}
+`;
+
+test(
+  "Refreshing native ACP sessions does not bring back a session deleted during the refresh",
+  WEB,
+  async ({ t3, app, screen }) => {
+    const instanceId = ProviderInstanceId.make("scenario-session-agent");
+    const snapshotTaken = Promise.withResolvers<void>();
+    const releaseSnapshot = Promise.withResolvers<void>();
+    let present = true;
+    let holdNextList = false;
+    const state = NodeHttp.createServer((request, response) => {
+      if (request.url === "/list") {
+        const snapshot = JSON.stringify({ present, title: SESSION_TITLE });
+        const reply = () =>
+          response.writeHead(200, { "Content-Type": "application/json" }).end(snapshot);
+        if (holdNextList) {
+          holdNextList = false;
+          snapshotTaken.resolve();
+          void releaseSnapshot.promise.then(reply);
+        } else {
+          reply();
+        }
+      } else if (request.url === "/delete") {
+        present = false;
+        response.writeHead(204).end();
+      } else {
+        response.writeHead(404).end();
+      }
+    });
+
+    try {
+      await new Promise<void>((resolve) => state.listen(0, "127.0.0.1", resolve));
+      const address = state.address();
+      if (address === null || typeof address === "string") throw new Error("No fixture port");
+      const project = await t3.project("demo", { "session-agent.mjs": ACP });
+      await runPromise(
+        Effect.gen(function* () {
+          const client = yield* rpcClient(T3_HOME, app.baseUrl ?? "");
+          yield* client["server.updateSettings"]({
+            patch: {},
+            providerInstanceMutation: {
+              operation: "upsert",
+              instanceId,
+              instance: {
+                driver: ProviderDriverKind.make("acpRegistry"),
+                displayName: "Session scenario agent",
+                enabled: true,
+                config: {
+                  source: "local",
+                  commandPath: process.execPath,
+                  commandArgs: [
+                    NodePath.join(project, "session-agent.mjs"),
+                    `http://127.0.0.1:${address.port}`,
+                  ],
+                },
+              },
+            },
+          });
+        }).pipe(Effect.scoped),
+      );
+      await t3.open(`/settings/providers?instanceId=${instanceId}`);
+      await screen.getByRole("button", "List sessions", { exact: true }).tap({ timeout: 60_000 });
+      const entry = screen.getByText(SESSION_TITLE, { exact: true });
+      await entry.waitFor();
+
+      holdNextList = true;
+      await screen.getByRole("button", "Refresh", { exact: true }).tap();
+      await snapshotTaken.promise;
+      const remove = screen.getByRole("button", "Delete", { exact: true });
+      const loading = screen.getByRole("button", "Loading", { exact: true });
+      if (!(await remove.isVisible()) || !(await remove.isEnabled())) {
+        releaseSnapshot.resolve();
+        await loading.waitFor({ state: "hidden" });
+      }
+      await remove.tap();
+      const confirm = screen.getByRole("alertdialog");
+      await confirm.getByRole("button", "Confirm", { exact: true }).tap();
+      await entry.waitFor({ state: "hidden" });
+
+      releaseSnapshot.resolve();
+      await loading.waitFor({ state: "hidden" });
+      await app.screenshot("after-deletion-and-refresh");
+      expect(await entry.isVisible(), "The deleted native session stays off the list").toBe(false);
+    } finally {
+      releaseSnapshot.resolve();
+      state.close();
+      state.closeAllConnections();
+    }
+  },
+);
pnpm scenarios:prove scripts/scenarios/acp-refresh-keeps-deleted-session-removed.e2e.ts --base main

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions