@devries-cameron20 / t3code-1 / commits / 871b00907d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(pi): a steer Pi has not read yet shows as waiting, not steered (#33982)

Julius Marminge committed Nov 10, 2026 at 11:20 UTC 871b00907d0bcf2705224de6c6e90de925c7cbb9
9 files changed +232 -9
apps/mobile/src/features/threads/ThreadFeed.tsx
+4 -1
@@ -1914,7 +1914,10 @@ function renderFeedEntry(
1914 const bubbleBodyVisible = foldRowId === null || foldExpanded;
1915 const intentBadge = props.userMessageGrouping.continuesSteer
1916 ? null
1917 - : resolveUserMessageIntentBadge(message.inputIntent);
1917 + : resolveUserMessageIntentBadge(
1918 + message.inputIntent,
1919 + message.projectedItem?.item.status === "pending",
1920 + );
1921 const referenceIds = new Set(
1922 collectComposerContextReferences(message.text).map((reference) => reference.contextId),
1923 );
apps/mobile/src/features/threads/userMessageIntentBadge.ts
+8
@@ -7,7 +7,15 @@ export interface UserMessageIntentBadgePresentation {
7
8 export function resolveUserMessageIntentBadge(
9 intent: OrchestrationV2UserMessageInputIntent | undefined,
10 + unread = false,
11 ): UserMessageIntentBadgePresentation | null {
12 + if (unread && (intent === "steer" || intent === "promoted_queued_to_steer")) {
13 + return {
14 + label: "Steer · waiting to be read",
15 + accessibilityLabel:
16 + "Steer waiting for the agent to read it after the running command finishes",
17 + };
18 + }
19 switch (intent) {
20 case "steer":
21 return {
apps/server/src/orchestration-v2/ProviderEventIngestor.test.ts
+67
@@ -1642,6 +1642,73 @@ layer("ProviderEventIngestorV2", (it) => {
1642 }),
1643 );
1644
1645 + it.effect("keeps a steered message pending until the provider reports it read", () =>
1646 + Effect.gen(function* () {
1647 + const now = yield* DateTime.now;
1648 + const eventSink = yield* EventSink.EventSinkV2;
1649 + const projectionStore = yield* ProjectionStore.ProjectionStoreV2;
1650 + const ingestor = yield* ProviderEventIngestor.ProviderEventIngestorV2;
1651 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
1652 + const threadEvent = yield* threadCreatedEvent(now);
1653 + const providerSessionId = yield* idAllocator.allocate.providerSession({
1654 + providerInstanceId: modelSelection.instanceId,
1655 + threadId: threadEvent.threadId,
1656 + });
1657 + const runId = RunId.make("run:steer-read");
1658 + const messageId = MessageId.make("message:steer-read");
1659 + const steer: OrchestrationV2TurnItem = {
1660 + id: idAllocator.derive.userTurnItem({ messageId }),
1661 + threadId: threadEvent.threadId,
1662 + runId,
1663 + nodeId: null,
1664 + providerThreadId: null,
1665 + providerTurnId: null,
1666 + nativeItemRef: null,
1667 + parentItemId: null,
1668 + ordinal: 1,
1669 + status: "completed",
1670 + title: null,
1671 + startedAt: now,
1672 + completedAt: now,
1673 + updatedAt: now,
1674 + type: "user_message",
1675 + createdBy: "user",
1676 + creationSource: "web",
1677 + messageId,
1678 + inputIntent: "steer",
1679 + text: "Steer behind a command",
1680 + attachments: [],
1681 + };
1682 + yield* eventSink.write({ events: [threadEvent] });
1683 + const ingest = (event: ProviderAdapter.ProviderAdapterV2Event) =>
1684 + ingestor.ingestNormalized({
1685 + providerSessionId,
1686 + providerInstanceId: modelSelection.instanceId,
1687 + threadId: threadEvent.threadId,
1688 + event,
1689 + });
1690 + const projected = projectionStore.getTurnItem({
1691 + threadId: threadEvent.threadId,
1692 + itemId: steer.id,
1693 + });
1694 + const steerUpdated = (status: "pending" | "completed") =>
1695 + ingest({
1696 + type: "steer.updated",
1697 + driver: CODEX_DRIVER,
1698 + threadId: threadEvent.threadId,
1699 + runId,
1700 + messageId,
1701 + status,
1702 + });
1703 +
1704 + yield* ingest({ type: "turn_item.updated", driver: CODEX_DRIVER, turnItem: steer });
1705 + yield* steerUpdated("pending");
1706 + assert.deepInclude(yield* projected, { status: "pending", completedAt: null });
1707 + yield* steerUpdated("completed");
1708 + assert.equal((yield* projected)?.status, "completed");
1709 + }),
1710 + );
1711 +
1712 it.effect("stores a bounded copy of a large file-change diff in both SQLite tables", () =>
1713 Effect.gen(function* () {
1714 const now = yield* DateTime.now;
apps/server/src/orchestration-v2/ProviderEventIngestor.ts
+29
@@ -616,6 +616,35 @@ export const layer: Layer.Layer<
616 }),
617 ];
618 }
619 + case "steer.updated": {
620 + const item = yield* projections.getTurnItem({
621 + threadId: input.event.threadId,
622 + itemId: idAllocator.derive.userTurnItem({ messageId: input.event.messageId }),
623 + });
624 + if (
625 + item?.type !== "user_message" ||
626 + item.status === input.event.status ||
627 + (item.status !== "pending" && item.status !== "completed")
628 + ) {
629 + return [];
630 + }
631 + const occurredAt = yield* DateTime.now;
632 + return [
633 + yield* makeDomainEvent(input, {
634 + type: "turn-item.updated",
635 + threadId: item.threadId,
636 + payload: {
637 + ...item,
638 + status: input.event.status,
639 + completedAt: input.event.status === "pending" ? null : occurredAt,
640 + updatedAt: occurredAt,
641 + },
642 + runId: item.runId,
643 + nodeId: item.nodeId,
644 + occurredAt,
645 + }),
646 + ];
647 + }
648 case "background_work.updated":
649 return [];
650 case "command_output.delta":
apps/server/src/orchestration-v2/RunExecutionService.ts
+2
@@ -488,6 +488,8 @@ export function routeProviderEvent(
488 }
489 case "message.updated":
490 return [ownsRun(event.message.runId) || ownsChildThread(event.message.threadId), state];
491 + case "steer.updated":
492 + return [ownsRun(event.runId), state];
493 case "turn_item.updated": {
494 if (ownsRun(event.turnItem.runId) || ownsChildThread(event.turnItem.threadId)) {
495 return [true, state];
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+16 -6
@@ -296,7 +296,10 @@ function AutomationMessageRow({ row }: { row: Extract<TimelineRow, { kind: "mess
296 <div className="group flex flex-col items-end gap-1" data-user-message-attribution="automation">
297 {row.message.inputIntent === "steer" ||
298 row.message.inputIntent === "promoted_queued_to_steer" ? (
299 - <UserMessageIntentMarker intent={row.message.inputIntent} />
299 + <UserMessageIntentMarker
300 + intent={row.message.inputIntent}
301 + unread={row.projectedItem?.item.status === "pending"}
302 + />
303 ) : null}
304 <div
305 className={cn(
@@ -845,7 +848,10 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
848 {(row.message.inputIntent === "steer" ||
849 row.message.inputIntent === "promoted_queued_to_steer") &&
850 !row.continuesSteer ? (
848 - <UserMessageIntentMarker intent={row.message.inputIntent} />
851 + <UserMessageIntentMarker
852 + intent={row.message.inputIntent}
853 + unread={row.projectedItem?.item.status === "pending"}
854 + />
855 ) : null}
856 {mediaAboveText ? (
857 <div className="flex max-w-[80%] justify-end">
@@ -1048,8 +1054,10 @@ const ACTIONS_REVEAL_CLASS_NAME =
1054
1055 function UserMessageIntentMarker({
1056 intent,
1057 + unread,
1058 }: {
1059 readonly intent: "steer" | "promoted_queued_to_steer";
1060 + readonly unread: boolean;
1061 }) {
1062 return (
1063 <Tooltip>
@@ -1062,12 +1070,14 @@ function UserMessageIntentMarker({
1070 }
1071 >
1072 <Redo2Icon aria-hidden="true" className="size-3" />
1065 - Steer
1073 + {unread ? "Steer · waiting to be read" : "Steer"}
1074 </TooltipTrigger>
1075 <TooltipPopup side="top">
1068 - {intent === "promoted_queued_to_steer"
1069 - ? "Originally queued, then promoted to steer the active turn"
1070 - : "Steered the active turn"}
1076 + {unread
1077 + ? "Waiting for the agent to read this. It reads steers between steps, after a running command finishes."
1078 + : intent === "promoted_queued_to_steer"
1079 + ? "Originally queued, then promoted to steer the active turn"
1080 + : "Steered the active turn"}
1081 </TooltipPopup>
1082 </Tooltip>
1083 );
packages/provider-core/src/server/ProviderAdapter.ts
+9
@@ -126,6 +126,15 @@ export const ProviderAdapterV2Event = Schema.Union([
126 driver: ProviderDriverKind,
127 turnItem: OrchestrationV2TurnItem,
128 }),
129 + /** A steer the provider queued stays `pending` until the agent reads it; `cancelled` if dropped unread. */
130 + Schema.Struct({
131 + type: Schema.Literal("steer.updated"),
132 + driver: ProviderDriverKind,
133 + threadId: ThreadId,
134 + runId: RunId,
135 + messageId: MessageId,
136 + status: Schema.Literals(["pending", "completed", "cancelled"]),
137 + }),
138 // Start before the root terminal; clear only after the final covered projection.
139 // Consumer lifetime cannot depend on a producer probe that runs ahead of its queue.
140 Schema.Struct({
packages/provider-pi/src/server/adapter.test.ts
+59 -1
@@ -306,7 +306,9 @@ const makeFakePi: Effect.Effect<FakePi> = Effect.gen(function* () {
306 "Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.",
307 };
308 }
309 - return base;
309 + return promptDisposition && isStreaming
310 + ? { ...base, data: { disposition: "queued" } }
311 + : base;
312 case "get_available_models":
313 return { ...base, data: { models } };
314 case "new_session": {
@@ -5225,6 +5227,62 @@ describe("PiAdapterV2", () => {
5227 }).pipe(Effect.scoped, Effect.provide(layerTest)),
5228 );
5229
5230 + it.effect.each([
5231 + { outcome: "Pi reads it", status: "completed" },
5232 + { outcome: "Stop clears it unread", status: "cancelled" },
5233 + ] as const)("reports a queued steer unread until $outcome", ({ status }) =>
5234 + Effect.gen(function* () {
5235 + const fake = yield* makeFakePi;
5236 + fake.setClearQueue({ steering: ["Steer behind a command"], followUp: [] });
5237 + fake.setStreaming(false);
5238 + const { runtime, takeEvent } = yield* openRuntime(fake);
5239 + const providerThread = yield* runtime.ensureThread({
5240 + threadId: THREAD_ID,
5241 + modelSelection: modelSelection("default"),
5242 + runtimePolicy,
5243 + });
5244 + yield* startTurn(runtime, providerThread);
5245 + yield* fake.takeRequest("prompt");
5246 + const running = yield* takeEvent(
5247 + (event) =>
5248 + event.type === "provider_turn.updated" && event.providerTurn.status === "running",
5249 + );
5250 + const providerTurnId =
5251 + running.type === "provider_turn.updated" ? running.providerTurn.id : undefined;
5252 + assert.isDefined(providerTurnId);
5253 + fake.setStreaming(true);
5254 + yield* fake.emit({ type: "agent_start" });
5255 +
5256 + const messageId = "message:thread-pi-test:queued-steer" as never;
5257 + yield* runtime.steerTurn({
5258 + threadId: THREAD_ID,
5259 + runId: RunId.make("run:thread-pi-test:1"),
5260 + providerThread,
5261 + providerTurnId: providerTurnId!,
5262 + message: {
5263 + messageId,
5264 + text: "Steer behind a command",
5265 + attachments: [],
5266 + createdBy: "user",
5267 + creationSource: "web",
5268 + },
5269 + });
5270 + const queued = yield* takeEvent((event) => event.type === "steer.updated");
5271 + assert.deepInclude(queued, { messageId, status: "pending" });
5272 +
5273 + if (status === "completed") {
5274 + yield* fake.emit({ type: "message_start", message: { role: "user" } });
5275 + } else {
5276 + yield* runtime.interruptTurn({ providerThread, providerTurnId: providerTurnId! });
5277 + yield* fake.takeRequest("abort");
5278 + fake.setStreaming(false);
5279 + yield* fake.emit({ type: "agent_settled", aborted: true });
5280 + }
5281 + const settled = yield* takeEvent((event) => event.type === "steer.updated");
5282 + assert.deepInclude(settled, { messageId, status });
5283 + }).pipe(Effect.scoped, Effect.provide(layerTest)),
5284 + );
5285 +
5286 it.effect("ignores an idle snapshot made stale by a steer", () =>
5287 Effect.gen(function* () {
5288 const fake = yield* makeFakePi;
packages/provider-pi/src/server/adapter.ts
+38 -1
@@ -21,6 +21,7 @@ import {
21 type OrchestrationV2UserInputQuestion,
22 type ProviderApprovalDecision,
23 type ProviderInstanceId,
24 + type MessageId,
25 type OrchestrationV2ProviderTurnTokenUsage,
26 } from "@t3tools/contracts";
27 import { PiSettings } from "../settings.ts";
@@ -374,6 +375,8 @@ interface ActivePiTurn {
375 activeProviderRetry: PiProviderRetryState | null;
376 failure: ReturnType<typeof makeProviderFailure> | null;
377 rejectedPromptFailure: ReturnType<typeof makeProviderFailure> | null;
378 + /** Steers Pi queued in send order; it reads them at a step boundary, after running tools return. */
379 + readonly unreadSteers: Array<MessageId>;
380 stopTreeRefs?: PiTurnTreeRefs | null;
381 }
382
@@ -411,6 +414,7 @@ interface PiPromptSend {
414 readonly providerTurnId: OrchestrationV2ProviderTurn["id"];
415 readonly kind: "turn_start" | "steer";
416 readonly record: PiRpcRecord;
417 + readonly messageId?: MessageId;
418 }
419
420 interface PiThreadState {
@@ -625,6 +629,20 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
629 const emit = (event: ProviderAdapter.ProviderAdapterV2Event) =>
630 Queue.offer(events, event).pipe(Effect.asVoid);
631
632 + const emitSteerStatus = (
633 + turn: ActivePiTurn,
634 + messageId: MessageId,
635 + status: "pending" | "completed" | "cancelled",
636 + ) =>
637 + emit({
638 + type: "steer.updated",
639 + driver: PI_PROVIDER,
640 + threadId: turn.turnInput.threadId,
641 + runId: turn.turnInput.runId,
642 + messageId,
643 + status,
644 + });
645 +
646 const updateProviderSession =
647 /* Provider events include streaming deltas; avoid a span for each update. */
648 Effect.fnUntraced(function* (
@@ -1713,6 +1731,10 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
1731 }
1732 }
1733 yield* cancelPendingPrompts(completedAt);
1734 + // Stop clears Pi's queue, so an unread steer was dropped; otherwise Pi read it before settling.
1735 + for (const messageId of turn.unreadSteers.splice(0)) {
1736 + yield* emitSteerStatus(turn, messageId, interrupted ? "cancelled" : "completed");
1737 + }
1738 const treeRefs =
1739 turn.stopTreeRefs !== undefined ? turn.stopTreeRefs : yield* captureTurnTreeRefs();
1740 const tokenUsage = readUsage
@@ -1931,10 +1953,15 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
1953 return;
1954 }
1955 case "message_start": {
1934 - if (turn !== null && recordString(event["message"], "role") === "assistant") {
1956 + const role = recordString(event["message"], "role");
1957 + if (turn !== null && role === "assistant") {
1958 turn.sawAgentActivity = true;
1959 turn.messageOrdinal += 1;
1960 }
1961 + const readSteer = role === "user" ? turn?.unreadSteers.shift() : undefined;
1962 + if (turn !== null && readSteer !== undefined) {
1963 + yield* emitSteerStatus(turn, readSteer, "completed");
1964 + }
1965 return;
1966 }
1967 case "message_update": {
@@ -2227,6 +2254,14 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
2254 yield* scheduleSettleProbe(responseTurn, true);
2255 }
2256 if (event["success"] === true) {
2257 + if (
2258 + pendingPrompt?.messageId !== undefined &&
2259 + responseTurn !== null &&
2260 + recordString(recordField(event, "data"), "disposition") === "queued"
2261 + ) {
2262 + responseTurn.unreadSteers.push(pendingPrompt.messageId);
2263 + yield* emitSteerStatus(responseTurn, pendingPrompt.messageId, "pending");
2264 + }
2265 // Command-only prompts emit no agent_settled; probe idle and re-queue behind preceding native events.
2266 if (
2267 pendingPrompt?.kind === "turn_start" &&
@@ -2802,6 +2837,7 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
2837 activeProviderRetry: null,
2838 failure: null,
2839 rejectedPromptFailure: null,
2840 + unreadSteers: [],
2841 };
2842 // Lock only install/send/start events; correlated setup must leave the pump free for dialogs.
2843 yield* Effect.gen(function* () {
@@ -2928,6 +2964,7 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
2964 yield* sendPrompt({
2965 providerTurnId: turn.providerTurn.id,
2966 kind: "steer",
2967 + messageId: steerInput.message.messageId,
2968 record: {
2969 type: "prompt",
2970 message: payload.message,