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
4 changes: 2 additions & 2 deletions .github/workflows/lazurio-fork-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ jobs:
apps/web/src/components/chat/ChatComposer.tsx
apps/web/src/components/chat/ComposerControlsBar.tsx
apps/web/src/components/chat/QueuedRunsControl.tsx
# Any steer queues while the running turn waits on the person's answer to a question or
# an approval, instead of aborting the provider's pending callback (row 30,
# Any steer or restart queues while the running turn waits on the person's answer to a
# question or an approval, instead of aborting the provider's pending callback (row 30,
# Lazurio/t3code#119, Lazurio/t3code#139): the guard in CommandPolicy.ts, a promoted
# message first in the queue (Orchestrator.ts), and their tests. A follow-up sent
# before the provider turn started notes that run (steersRunId in orchestrationV2.ts)
Expand Down
19 changes: 17 additions & 2 deletions apps/server/src/orchestration-v2/CommandPolicy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ it.each(["/compact", " /LOGOUT "])("queues a steer sent while %s runs", (text) =

// Claude's MCP elicitation (pingdotgg/t3code#21903) waits as a pending mcp-elicitation request.
it.each(["user_input", "command", "mcp-elicitation"] as const)(
"queues every steer while the active turn waits on a pending %s request",
"queues every steer and restart while the active turn waits on a pending %s request",
(kind) => {
const projection = dispatchProjection(baseCapabilities);
const waiting = {
Expand All @@ -302,12 +302,27 @@ it.each(["user_input", "command", "mcp-elicitation"] as const)(
);
assert.deepEqual(
CommandPolicy.resolveMessageDispatchIntent(waiting, { type: "start_immediately" }, "restart"),
{ type: "restart_active", targetRunId: activeRunId },
{ type: "queue_after_active" },
);
assert.deepEqual(
CommandPolicy.resolveMessageDispatchIntent(waiting, {
type: "restart_active",
targetRunId: activeRunId,
}),
{ type: "queue_after_active" },
);
const answered = {
...projection,
runtimeRequests: [{ kind, status: "resolved" }],
} as unknown as OrchestrationV2ThreadProjection;
assert.deepEqual(
CommandPolicy.resolveMessageDispatchIntent(
answered,
{ type: "start_immediately" },
"restart",
),
{ type: "restart_active", targetRunId: activeRunId },
);
for (const deliveryIntent of ["auto", "steer"] as const) {
assert.deepEqual(
CommandPolicy.resolveMessageDispatchIntent(
Expand Down
7 changes: 4 additions & 3 deletions apps/server/src/orchestration-v2/CommandPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export function goalCommandStopsActiveRun(
}

/**
* A steer aborts the provider's pending question or approval callback, so the person
* never sees it; while one is pending, any steer waits behind the turn (Lazurio/t3code#139).
* A steer or restart aborts the provider's pending question or approval callback, so the
* person never sees it; while one is pending, either waits behind the turn (Lazurio/t3code#139).
*/
export function waitsOnPendingRequest(
projection: Pick<OrchestrationV2ThreadProjection, "runtimeRequests">,
Expand All @@ -105,8 +105,9 @@ export function resolveMessageDispatchIntent(
deliveryIntent?: "auto" | "steer" | "restart",
): MessageDispatchMode {
const mode = resolveDeliveryIntent(projection, requestedMode, deliveryIntent);
if (mode.type !== "steer_active") return mode;
if (mode.type !== "steer_active" && mode.type !== "restart_active") return mode;
if (waitsOnPendingRequest(projection)) return { type: "queue_after_active" };
if (mode.type === "restart_active") return mode;
// Compaction and sign-out cannot accept steers; queue follow-ups.
const target = projection.runs.find((run) => run.id === mode.targetRunId);
const targetMessage = projection.messages.find((message) => message.id === target?.userMessageId);
Expand Down
Loading
Loading