From 8c1f3cb7e014373d8385948d57cb673a1e100937 Mon Sep 17 00:00:00 2001 From: Dotta Date: Sat, 10 Oct 2026 09:52:04 -0500 Subject: [PATCH] Explain when a task dev server is unavailable Co-Authored-By: Paperclip --- .../computers/application/service.test.ts | 14 ++++++++++++++ .../modules/computers/application/service.ts | 19 +++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/server/src/modules/computers/application/service.test.ts b/server/src/modules/computers/application/service.test.ts index 978ca3210cd..fa962a61589 100644 --- a/server/src/modules/computers/application/service.test.ts +++ b/server/src/modules/computers/application/service.test.ts @@ -113,6 +113,20 @@ function fixture() { }; } describe("computer ownership", () => { + it("explains an unavailable dev server without masking provider errors", async () => { + const f = fixture(); + await f.attach(); + const binding = await f.admit(); + const input = { ...f.scope, owner: binding.owner, port: 5173 }; + vi.mocked(f.backend.remote).mockRejectedValueOnce(new ComputerError("conflict", "Computer operation: conflict")); + await expect(f.service.preview(input)).rejects.toMatchObject({ + code: "conflict", message: "No dev server is running on this port for this task. Start it in the task and try again.", + }); + const offline = new ComputerError("provider_error", "Provider unavailable"); + vi.mocked(f.backend.remote).mockRejectedValueOnce(offline); + await expect(f.service.preview(input)).rejects.toBe(offline); + expect(f.backend.preview).not.toHaveBeenCalled(); + }); it("reuses warm process identity and port while fencing stale callbacks", async () => { const f = fixture(); await f.attach(); diff --git a/server/src/modules/computers/application/service.ts b/server/src/modules/computers/application/service.ts index 988798b6da9..44e4d7602d0 100644 --- a/server/src/modules/computers/application/service.ts +++ b/server/src/modules/computers/application/service.ts @@ -591,12 +591,19 @@ finally: "forbidden", "Runner ports are not application previews", ); - await backend.remote(record, { - root: base(record), - action: "owned-port", - port: input.port, - ownerId: owner.id, - }); + try { + await backend.remote(record, { + root: base(record), + action: "owned-port", + port: input.port, + ownerId: owner.id, + }); + } catch (error) { + if (error instanceof ComputerError && error.code === "conflict") { + throw new ComputerError("conflict", "No dev server is running on this port for this task. Start it in the task and try again."); + } + throw error; + } return backend.preview(record, input.port); } async function withFiles(