diff --git a/apps/server/src/orchestration-v2/Orchestrator.ts b/apps/server/src/orchestration-v2/Orchestrator.ts index 9ca65a32f3cf8..819aa90c03b98 100644 --- a/apps/server/src/orchestration-v2/Orchestrator.ts +++ b/apps/server/src/orchestration-v2/Orchestrator.ts @@ -5446,6 +5446,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio now, cancelQueuedDelivery: false, }); + } + if (command.type === "thread.archive" || command.type === "thread.settle") { yield* closePendingLinkRequests({ command, events, threadId: command.threadId, now }); } @@ -10828,8 +10830,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio /** * Closes the link cards still waiting for the user. Their agent stopped - * waiting long ago, so nobody is woken: stopping or archiving the thread - * means the user is done with it. + * waiting long ago, so nobody is woken: stopping, settling or archiving the + * thread means the user is done with it. */ const closePendingLinkRequests = Effect.fn("orchestrationV2.closePendingLinkRequests")( function* (input: { diff --git a/apps/server/src/peer/PeerLinkRequests.test.ts b/apps/server/src/peer/PeerLinkRequests.test.ts index 2190e9a50e6a9..2eec22a90bfa0 100644 --- a/apps/server/src/peer/PeerLinkRequests.test.ts +++ b/apps/server/src/peer/PeerLinkRequests.test.ts @@ -888,6 +888,24 @@ it.live("archiving the thread closes its open card", () => ), ); +it.live("settling the thread closes its open card, so it no longer reads as asking", () => + withBoth((a, b) => + Effect.gen(function* () { + yield* seedThread(a); + yield* a.call({ url: b.url }); + yield* pendingCard(a); + yield* endRun(a); + yield* a.orchestrator.dispatch({ + type: "thread.settle", + commandId: CommandId.make("command:settle:laptop"), + threadId, + }); + expect(yield* cardOf(a)).toMatchObject({ status: "cancelled", linkStatus: "cancelled" }); + expect((yield* a.orchestrator.getThreadShell(threadId))?.pendingRuntimeRequest).toBeNull(); + }), + ), +); + it.live("a code the box refuses fails the request with its reason, and links nothing", () => withBoth((a, b) => Effect.gen(function* () {