Explain when a task dev server is unavailable

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-10 09:52:21 -05:00
1 parent 52a90ad969
commit 8c1f3cb7e0
2 files changed
+27 -6

No files matched your search

@@ -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();
@@ -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<T>(