fix(server): keep turn interrupts responsive #6531
ClosedNeilTheFisher(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/6531/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- @@ -1409,4 +1414,5 @@14091414 event.type === "thread.user-input-response-requested" ||14101415 event.type === "thread.session-stop-requested"14111416 ) {1412- return yield* worker.enqueue(event);1417+ return yield* event.type === "thread.turn-interrupt-requested"1418+ ? interruptWorker.enqueue(event)
- apps/server/src/orchestration/Layers/ProviderCommandReactor.ts line 1419Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1409,4 +1414,6 @@14091414 event.type === "thread.user-input-response-requested" ||14101415 event.type === "thread.session-stop-requested"14111416 ) {1412- return yield* worker.enqueue(event);1417+ return yield* event.type === "thread.turn-interrupt-requested"1418+ ? interruptWorker.enqueue(event)1419+ : worker.enqueue(event);
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -1547,11 +1576,20 @@1576+ if (targetTurnId) {15471577 yield* emit({15481578 ...(yield* buildEventBase({15491579 threadId,1550- turnId: turnId ?? context.activeTurnId,1580+ turnId: targetTurnId,15511581 })),15521582 type: "turn.aborted",15531583 payload: {15541584 reason: "Interrupted by user.",15551585 },15561586 });15571587 }1588+ // Publish the local lifecycle transition before waiting on the remote1589+ // abort. OpenCode can sit in a provider retry (for example after a1590+ // monthly usage limit) long enough for session.abort to hang, but the1591+ // user must still be able to stop the turn immediately.1592+ context.activeTurnId = undefined;1593+ context.activeAgent = undefined;1594+ context.activeVariant = undefined;1595+ yield* updateProviderSession(context, { status: "ready" }, { clearActiveTurnId: true });
- @@ -1557 +1587,21 @@15571587 }1588+ // Publish the local lifecycle transition before waiting on the remote1589+ // abort. OpenCode can sit in a provider retry (for example after a1590+ // monthly usage limit) long enough for session.abort to hang, but the1591+ // user must still be able to stop the turn immediately.1592+ context.activeTurnId = undefined;1593+ context.activeAgent = undefined;1594+ context.activeVariant = undefined;1595+ yield* updateProviderSession(context, { status: "ready" }, { clearActiveTurnId: true });1596+1597+ // Best effort: the lifecycle event above is the authoritative UI1598+ // transition, while this request stops the provider's in-flight work1599+ // when the OpenCode server is responsive. Run it in the session scope1600+ // so a later session stop also cancels a hung abort request.1601+ yield* runOpenCodeSdk("session.abort", () =>1602+ context.client.session.abort({ sessionID: context.openCodeSessionId }),1603+ ).pipe(1604+ Effect.mapError(toRequestError),1605+ Effect.ignore({ log: true }),1606+ Effect.forkIn(context.sessionScope),1607+ );@@ -1581,4 +1585,6 @@15811585 const nextActiveTurnId =15821586 event.type === "turn.started"15831587 ? (eventTurnId ?? null)1584- : event.type === "turn.completed" || event.type === "session.exited"1588+ : event.type === "turn.completed" ||1589+ event.type === "turn.aborted" ||1590+ event.type === "session.exited"
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
0ba15257-ad95-4c2a-9509-30ee6c13d3efYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share