Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand Down Expand Up @@ -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: {
Expand Down
18 changes: 18 additions & 0 deletions apps/server/src/peer/PeerLinkRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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* () {
Expand Down
Loading