From 10c8d12c9faa13ee3d6c6506da9198039f43f784 Mon Sep 17 00:00:00 2001 From: Yashar Niknafs <7563948+yniknafs@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:05:03 -0500 Subject: [PATCH] fix(server): retain sharing recovery after run interruption Extend the existing recovery in pingdotgg/t3code#28962 to interrupted or cancelled runs that already retain the root sharing-rejection item. Preserve native-session binding and the background-work fence. Ordinary interruptions without that error remain unchanged. --- .../orchestration-v2/ProviderTurnStartService.ts | 8 +++++++- .../testkit/ProviderSwitch.integration.test.ts | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts index 742f31d4c1006..93be5dd9cc1a1 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts @@ -1274,7 +1274,13 @@ export const layer: Layer.Layer< source.activeAttemptId !== null && acceptedAttemptIds.has(source.activeAttemptId), ); - if (previous?.status !== "failed") return false; + if ( + previous === undefined || + (previous.status !== "failed" && + previous.status !== "interrupted" && + previous.status !== "cancelled") + ) + return false; const previousAttempt = projection.attempts.find( (source) => source.id === previous.activeAttemptId, ); diff --git a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts index 5e4af84f4b342..1e06d40658aad 100644 --- a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts +++ b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts @@ -1245,6 +1245,8 @@ describe("orchestration v2 provider switching", () => { "live", "detached", "legacy", + "interrupted", + "cancelled", "other-error", "other-provider", "repaired-native", @@ -1364,6 +1366,19 @@ describe("orchestration v2 provider switching", () => { ), }); } + if (scenario === "interrupted" || scenario === "cancelled") { + yield* (yield* EventSink.EventSinkV2).write({ + events: [ + { + id: EventId.make(`rejected:${scenario}`), + type: "run.updated", + threadId, + occurredAt: failed.thread.createdAt, + payload: { ...failed.runs.at(-1)!, status: scenario }, + }, + ], + }); + } if (scenario === "repaired-native") { const providerThread = failed.providerThreads[0]!; yield* (yield* EventSink.EventSinkV2).write({