Skip to content

Commit 5432d6a

Browse files
committed
fix(clients): wait for queued messages before enabling steering
1 parent 155d543 commit 5432d6a

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎packages/client-runtime/src/state/threadWorkflows.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ describe("thread workflows", () => {
143143
runs: [
144144
{ id: "goal", status: "queued", userMessageId: "message-goal", ordinal: 1 },
145145
{ id: "plain", status: "queued", userMessageId: "message-plain", ordinal: 2 },
146+
{ id: "loading", status: "queued", userMessageId: "message-loading", ordinal: 3 },
146147
],
147148
messages: [
148149
{ id: "message-goal", text: "/goal finish the refactor", attachments: [] },
@@ -158,6 +159,7 @@ describe("thread workflows", () => {
158159
).toEqual([
159160
["goal", "Goal commands must run as a separate turn."],
160161
["plain", null],
162+
["loading", "Queued message is still loading."],
161163
]);
162164
});
163165
it.each(["completed", "interrupted", "cancelled", "failed"])(

‎packages/client-runtime/src/state/threadWorkflows.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,13 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
158158
// A queued guest message shows the guest's words; the agent still gets the attributed text.
159159
text: message?.context?.guest?.text ?? message?.text ?? "Queued message",
160160
attachments: message?.attachments ?? [],
161-
steerRejectionReason: orchestrationV2SteerRejectionReason({
162-
text: message?.text ?? "",
163-
attachments: message?.attachments ?? [],
164-
}),
161+
steerRejectionReason:
162+
message === undefined
163+
? "Queued message is still loading."
164+
: orchestrationV2SteerRejectionReason({
165+
text: message.text,
166+
attachments: message.attachments ?? [],
167+
}),
165168
messageId: run.userMessageId,
166169
...(message?.context ? { context: message.context } : {}),
167170
...(message ? { message } : {}),

0 commit comments

Comments
 (0)