fix: deliver steering after worktree setup #34581
MergedYash-Singh1(GitHub profile, opens in a new tab)merged 0 commits into
main fromrefs/pull/34581/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/orchestration-v2/Orchestrator.ts line 6563Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -6525,0 +6531,21 @@6531+ target?.status === "preparing" ||6532+ target?.status === "starting" ||6533+ (target?.status === "running" &&6534+ !projection.providerTurns.some(6535+ (turn) => turn.runAttemptId === target.activeAttemptId && turn.status === "running",6536+ ))6537+ ) {6538+ const adapter = yield* providerAdapters6539+ .get(target.providerInstanceId)6540+ .pipe(mapDispatchError(command));6541+ const capabilities = yield* adapter.getCapabilities().pipe(mapDispatchError(command));6542+ yield* commandPolicy6543+ .decideSteeringExecution({6544+ commandId: command.commandId,6545+ threadId: command.threadId,6546+ providerInstanceId: target.providerInstanceId,6547+ capabilities,6548+ })6549+ .pipe(mapDispatchError(command));6550+ steerWhenReadyRunId = target.id;6551+ dispatchMode = { type: "queue_after_active" };apps/server/src/orchestration-v2/Orchestrator.ts lines 14667 to 14667OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -14575,0 +14647,21 @@14647+ if (stored.event.type !== "provider-turn.updated") return;14648+ const threadId = stored.event.threadId;14649+ const turn = stored.event.payload;14650+ const projection = yield* projectionStore.getThreadRecords(threadId, ["runs"]);14651+ const run = projection.runs.find(14652+ (candidate) =>14653+ candidate.activeAttemptId === turn.runAttemptId && candidate.status === "running",14654+ );14655+ if (run === undefined) return;14656+ const pending = projection.runs14657+ .filter(14658+ (queued) => queued.status === "queued" && queued.steerWhenReadyRunId === run.id,14659+ )14660+ .toSorted(14661+ (left, right) =>14662+ (left.queuePosition ?? left.ordinal) - (right.queuePosition ?? right.ordinal),14663+ );14664+ for (const queued of pending) {14665+ yield* dispatchWithReceiptEffect({14666+ type: "queued-message.promote-to-steer",14667+ commandId: CommandId.make(`command:deferred-steer:${queued.id}:${run.id}`),apps/server/src/orchestration-v2/Orchestrator.ts line 10447Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -10375,0 +10412,21 @@10412+ ) {10413+ const adapter = yield* providerAdapters10414+ .get(target.providerInstanceId)10415+ .pipe(mapDispatchError(command));10416+ const capabilities = yield* adapter.getCapabilities().pipe(mapDispatchError(command));10417+ yield* commandPolicy10418+ .decideSteeringExecution({10419+ commandId: command.commandId,10420+ threadId: command.threadId,10421+ providerInstanceId: target.providerInstanceId,10422+ capabilities,10423+ })10424+ .pipe(mapDispatchError(command));10425+ yield* emitEvent({10426+ type: "run.updated",10427+ threadId: command.threadId,10428+ runId: queuedRun.id,10429+ nodeId: queuedRootNode.id,10430+ providerInstanceId: queuedRun.providerInstanceId,10431+ occurredAt: now,10432+ payload: { ...queuedRun, steerWhenReadyRunId: target.id },
- apps/server/src/orchestration-v2/Orchestrator.ts line 14680Resolvedby Yash-Singh1(GitHub profile, opens in a new tab)@@ -14575,0 +14645,21 @@14645+ Effect.fn("Orchestrator.deliverDeferredSteers")(14646+ function* (stored) {14647+ if (stored.event.type !== "provider-turn.updated") return;14648+ const threadId = stored.event.threadId;14649+ const turn = stored.event.payload;14650+ const projection = yield* projectionStore.getThreadRecords(threadId, ["runs"]);14651+ const run = projection.runs.find(14652+ (candidate) =>14653+ candidate.activeAttemptId === turn.runAttemptId && candidate.status === "running",14654+ );14655+ if (run === undefined) return;14656+ const pending = projection.runs14657+ .filter(14658+ (queued) => queued.status === "queued" && queued.steerWhenReadyRunId === run.id,14659+ )14660+ .toSorted(14661+ (left, right) =>14662+ (left.queuePosition ?? left.ordinal) - (right.queuePosition ?? right.ordinal),14663+ );14664+ for (const queued of pending) {14665+ yield* dispatchWithReceiptEffect({apps/server/src/orchestration-v2/Orchestrator.ts line 14667OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -14575,0 +14647,21 @@14647+ if (stored.event.type !== "provider-turn.updated") return;14648+ const threadId = stored.event.threadId;14649+ const turn = stored.event.payload;14650+ const projection = yield* projectionStore.getThreadRecords(threadId, ["runs"]);14651+ const run = projection.runs.find(14652+ (candidate) =>14653+ candidate.activeAttemptId === turn.runAttemptId && candidate.status === "running",14654+ );14655+ if (run === undefined) return;14656+ const pending = projection.runs14657+ .filter(14658+ (queued) => queued.status === "queued" && queued.steerWhenReadyRunId === run.id,14659+ )14660+ .toSorted(14661+ (left, right) =>14662+ (left.queuePosition ?? left.ordinal) - (right.queuePosition ?? right.ordinal),14663+ );14664+ for (const queued of pending) {14665+ yield* dispatchWithReceiptEffect({14666+ type: "queued-message.promote-to-steer",14667+ commandId: CommandId.make(`command:deferred-steer:${queued.id}:${run.id}`),
- apps/server/src/orchestration-v2/Orchestrator.ts lines 6540 to 6548Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -6523,3 +6533,15 @@65236533 payload: { ...sourcePlan, status: "completed" },65246534 });652565356536+ let steerWhenReadyRunId: RunId | undefined;6537+ if (dispatchMode.type === "steer_active") {6538+ const targetRunId = dispatchMode.targetRunId;6539+ const target = projection.runs.find((run) => run.id === targetRunId);6540+ if (6541+ target?.status === "preparing" ||6542+ target?.status === "starting" ||6543+ (target?.status === "running" &&6544+ !projection.providerTurns.some(6545+ (turn) => turn.runAttemptId === target.activeAttemptId && turn.status === "running",6546+ ))6547+ ) {
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed