Skip to content

[Bug]: A failed action import wipes out a new action draft #39311

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 a thread in a project that shares an action through t3.json.
  2. Choose that action from the Project actions menu to import it.
  3. Reopen the actions menu while the import is pending.
  4. Choose Add project script.
  5. Enter a name and command for a different action.
  6. Wait for the earlier import to fail.

Expected behavior

The manual action form stays open with its name and command intact.

Actual behavior

The form switches to the failed import and discards the new action draft.

action draft after import fails

failure

Impact

Major degradation or frequent failure. People who start a manual action while an import is pending lose their unsaved input if the import fails before they save.

Version or commit

main at 80cf4f7945. The cause is at apps/web/src/components/ProjectScriptsControl.tsx:153.

Environment

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

Logs or stack traces

The failed import preserves the manual action name
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/project-action-draft-survives-failed-import.e2e.ts b/scripts/scenarios/project-action-draft-survives-failed-import.e2e.ts
new file mode 100644
index 0000000000..e201ec8dc4
--- /dev/null
+++ b/scripts/scenarios/project-action-draft-survives-failed-import.e2e.ts
@@ -0,0 +1,95 @@
+/// <reference lib="dom" />
+import { expect } from "e2e";
+
+import { test, WEB } from "./t3.ts";
+
+declare global {
+  interface Window {
+    projectActionImportFailure?: Promise<() => void>;
+  }
+}
+
+test(
+  "A failed project action import preserves a manual action draft",
+  WEB,
+  async ({ t3, app, browser, screen }) => {
+    const project = await t3.project("demo", {
+      "t3.json": JSON.stringify({
+        scripts: [{ name: "Shared build", command: "echo build" }],
+      }),
+    });
+    const thread = await t3.thread({ project, title: "Action import", messages: ["Start"] });
+    await browser.setViewport({ width: 1920, height: 1000 });
+
+    await browser.addInitScript(() => {
+      const pending = Promise.withResolvers<() => void>();
+      window.projectActionImportFailure = pending.promise;
+      const send = WebSocket.prototype.send;
+      WebSocket.prototype.send = function (data) {
+        const request: { _tag: string; id: string; tag: string } | null =
+          typeof data === "string" ? JSON.parse(data) : null;
+        if (
+          typeof data !== "string" ||
+          request?._tag !== "Request" ||
+          request.tag !== "server.updateSettings" ||
+          !data.includes("Shared build")
+        ) {
+          return send.call(this, data);
+        }
+        // Delay a settings write failure until the user has started a different action.
+        WebSocket.prototype.send = send;
+        pending.resolve(() => {
+          this.dispatchEvent(
+            new MessageEvent("message", {
+              data: JSON.stringify({
+                _tag: "Exit",
+                requestId: request.id,
+                exit: {
+                  _tag: "Failure",
+                  cause: [
+                    {
+                      _tag: "Fail",
+                      error: {
+                        _tag: "ServerSettingsError",
+                        operation: "write-file",
+                        settingsPath: "settings.json",
+                      },
+                    },
+                  ],
+                },
+              }),
+            }),
+          );
+        });
+      };
+    });
+
+    await t3.open(thread);
+    const actions = screen.getByRole("button", "Choose project action", { exact: true });
+    await actions.tap();
+    await screen.getByRole("menuitem", /Shared build/).tap();
+    await browser.evaluate(async () => {
+      await window.projectActionImportFailure;
+    });
+
+    await actions.tap();
+    await screen.getByRole("menuitem", "Add project script", { exact: true }).tap();
+    const draftName = "My local check";
+    await browser.locator("#script-name").fill(draftName);
+    await browser.locator("#script-command").fill("echo local");
+    await browser.evaluate(async () => {
+      const release = await window.projectActionImportFailure!;
+      release();
+      // Let the RPC failure and React's resulting update reach the screen before sampling it.
+      await new Promise<void>((resolve) => {
+        requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
+      });
+    });
+
+    await app.screenshot("action-draft-after-import-fails");
+    const name = await browser.evaluate(
+      () => document.querySelector<HTMLInputElement>("#script-name")?.value,
+    );
+    expect(name, "The failed import preserves the manual action name").toBe(draftName);
+  },
+);
pnpm scenarios:prove scripts/scenarios/project-action-draft-survives-failed-import.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