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", };