Skip to content

Commit 3449c52

Browse files
committed
fix(threads): wake blocking questions for newer input cards
1 parent 900272a commit 3449c52

2 files changed

Lines changed: 38 additions & 33 deletions

File tree

‎apps/server/src/orchestration-v2/ProjectionStore.test.ts‎

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5500,38 +5500,43 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
55005500
},
55015501
});
55025502

5503-
for (const fresh of [true, false]) {
5504-
yield* projectionStore.apply({
5505-
id: EventId.make("event:" + suffix + ":fresh-" + fresh),
5506-
type: "runtime-request.updated",
5507-
threadId,
5508-
runId,
5509-
nodeId,
5510-
driver,
5511-
occurredAt: now,
5512-
payload: {
5513-
id: requestId,
5503+
for (const responseCapability of [
5504+
{ type: "live", providerSessionId: ProviderSessionId.make("session:pending-secret") },
5505+
{ type: "message" },
5506+
] as const) {
5507+
for (const fresh of [true, false]) {
5508+
yield* projectionStore.apply({
5509+
id: EventId.make("event:" + suffix + ":fresh-" + fresh),
5510+
type: "runtime-request.updated",
5511+
threadId,
5512+
runId,
55145513
nodeId,
5515-
providerTurnId: null,
5516-
nativeRequestRef: null,
5517-
kind: "user_input",
5518-
status: "pending",
5519-
responseCapability: { type: "message" },
5520-
createdAt: fresh
5521-
? DateTime.add(now, { seconds: 5 })
5522-
: DateTime.subtract(now, { seconds: 1 }),
5523-
resolvedAt: null,
5524-
},
5525-
});
5526-
for (const shell of [
5527-
(yield* projectionStore.getShellSnapshot()).threads.find(
5528-
(thread) => thread.id === threadId,
5529-
),
5530-
ProjectionStore.threadShellFromProjection(
5531-
yield* projectionStore.getThreadProjection(threadId),
5532-
),
5533-
]) {
5534-
assert.equal(shell?.pendingRuntimeRequest?.id, fresh ? requestId : "secret:b");
5514+
driver,
5515+
occurredAt: now,
5516+
payload: {
5517+
id: requestId,
5518+
nodeId,
5519+
providerTurnId: null,
5520+
nativeRequestRef: null,
5521+
kind: "user_input",
5522+
status: "pending",
5523+
responseCapability,
5524+
createdAt: fresh
5525+
? DateTime.add(now, { seconds: 5 })
5526+
: DateTime.subtract(now, { seconds: 1 }),
5527+
resolvedAt: null,
5528+
},
5529+
});
5530+
for (const shell of [
5531+
(yield* projectionStore.getShellSnapshot()).threads.find(
5532+
(thread) => thread.id === threadId,
5533+
),
5534+
ProjectionStore.threadShellFromProjection(
5535+
yield* projectionStore.getThreadProjection(threadId),
5536+
),
5537+
]) {
5538+
assert.equal(shell?.pendingRuntimeRequest?.id, fresh ? requestId : "secret:b");
5539+
}
55355540
}
55365541
}
55375542

‎apps/server/src/orchestration-v2/ProjectionStore.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ export function threadShellFromProjection(
14821482
);
14831483
const latestUserAuthoredMessageAt =
14841484
userMessages.find((message) => message.createdBy === "user")?.updatedAt ?? null;
1485-
if (pendingRuntimeRequest === null || pendingRuntimeRequest.blocking === false) {
1485+
if (pendingRuntimeRequest === null || pendingRuntimeRequest.kind === "user_input") {
14861486
const waitingCard = secretRequestAsPendingInput(
14871487
projection.turnItems
14881488
.filter(
@@ -6543,7 +6543,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
65436543
)
65446544
: null;
65456545
if (
6546-
(pendingRuntimeRequest === null || pendingRuntimeRequest.blocking === false) &&
6546+
(pendingRuntimeRequest === null || pendingRuntimeRequest.kind === "user_input") &&
65476547
waitingCards.length > 0
65486548
) {
65496549
const waitingCard = secretRequestAsPendingInput(

0 commit comments

Comments
 (0)