From 4a2be2d116259b3974184da3d851136cf25b91d5 Mon Sep 17 00:00:00 2001 From: scotttong Date: Wed, 25 Nov 2026 11:39:33 -0800 Subject: [PATCH] fix(workspaces): point the repository-mismatch repair at the recorded URL and set the notice's next action Changing the project's repository URL to the folder's origin does not repair a workspace that recorded a third URL: the check still needs the origin or the project URL to equal the recorded one. The text now says to restore the recorded URL in the project or the folder's origin, or to save the work and choose another workspace. The workspace-validation notice seed now sets nextAction from the same text, so its next-action row no longer falls back to a bare Retry. Co-Authored-By: Claude Opus 5.5 --- .../workspace-validation-recovery-notice.test.ts | 16 +++++++++++----- server/src/services/recovery/stranded-notice.ts | 14 +++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/server/src/__tests__/workspace-validation-recovery-notice.test.ts b/server/src/__tests__/workspace-validation-recovery-notice.test.ts index 1509063514e..e2b116e33e5 100644 --- a/server/src/__tests__/workspace-validation-recovery-notice.test.ts +++ b/server/src/__tests__/workspace-validation-recovery-notice.test.ts @@ -10,11 +10,17 @@ describe("workspace validation recovery text", () => { it("explains a repository address mismatch and says Retry alone will not fix it", () => { const payload = { reason: "persisted_workspace_source_conflict", reasonCode: "source_repository_mismatch" }; const text = workspaceValidationNextAction(payload); - expect(text).toContain("repository URL"); - expect(text).toContain("git origin"); - expect(text).toContain("Retrying without that change fails the same way"); + // Repair restores the RECORDED URL: changing the project URL to the + // folder's origin would leave the recorded URL unmatched. + expect(text).toContain("Set the project's repository URL back to the URL this workspace recorded"); + expect(text).toContain("make the folder's git origin (`git remote get-url origin`) equal to it"); + expect(text).toContain("save any work in this workspace first"); + expect(text).toContain("Retrying without one of these changes fails the same way"); expect(text).not.toContain("Press Retry to start it again."); - expect(buildWorkspaceValidationRecoveryNoticeSeed(payload).body).toBe(text); + // The notice's next-action row must not fall back to a bare "Press Retry". + expect(buildWorkspaceValidationRecoveryNoticeSeed(payload)).toMatchObject({ + body: text, nextAction: text, title: "Workspace validation failed", tone: "danger", + }); }); it("explains any other unverifiable original repository instead of the generic text", () => { @@ -36,6 +42,6 @@ describe("workspace validation recovery text", () => { it("falls back to the generic text when the reason is unknown or missing", () => { expect(workspaceValidationNextAction(null)).toBe(GENERIC); expect(workspaceValidationNextAction({ reason: "configured_workspace_unavailable" })).toBe(GENERIC); - expect(buildWorkspaceValidationRecoveryNoticeSeed().body).toBe(GENERIC); + expect(buildWorkspaceValidationRecoveryNoticeSeed()).toMatchObject({ body: GENERIC, nextAction: GENERIC }); }); }); diff --git a/server/src/services/recovery/stranded-notice.ts b/server/src/services/recovery/stranded-notice.ts index bafc15bf615..93d502efa15 100644 --- a/server/src/services/recovery/stranded-notice.ts +++ b/server/src/services/recovery/stranded-notice.ts @@ -136,10 +136,12 @@ export function workspaceValidationNextAction(payload: Record | } if (reason === "persisted_workspace_source_conflict") { if (readNonEmptyStringField(payload, "reasonCode") === "source_repository_mismatch") { - return "The agent did not start: this task's workspace records a repository URL that does not match the git origin " - + "of the project's folder, so Paperclip could not confirm it is the same repository. Make the repository URL in " - + "the project's workspace settings match the folder's git origin (`git remote get-url origin`), then press Retry. " - + "Retrying without that change fails the same way."; + return "The agent did not start: this task's workspace recorded a repository URL that no longer matches the " + + "project's repository URL or the git origin of the project's folder, so Paperclip could not confirm it is " + + "the same repository. Set the project's repository URL back to the URL this workspace recorded, or make the " + + "folder's git origin (`git remote get-url origin`) equal to it, then press Retry. To use a different " + + "repository instead, save any work in this workspace first, then choose another workspace for the task. " + + "Retrying without one of these changes fails the same way."; } return "The agent did not start: this task's workspace's original repository could not be found or verified. " + "Check the project's workspace folder and repository URL in the project settings, then press Retry."; @@ -150,8 +152,10 @@ export function workspaceValidationNextAction(payload: Record | export function buildWorkspaceValidationRecoveryNoticeSeed( payload?: Record | null, ): StrandedRecoveryNoticeSeed { + const nextAction = workspaceValidationNextAction(payload); return { - body: workspaceValidationNextAction(payload), + body: nextAction, + nextAction, title: "Workspace validation failed", tone: "danger", };