fix(orchestrator): scope Stop button to the active thread#46
Merged
Conversation
The Stop button issued a runner-wide abort regardless of which thread the user was viewing. Pre PR #45 this was harmless because the orchestrator only ran one turn at a time. With cross-thread concurrent drain enabled, the same global abort kills every in-flight turn. Three call paths needed channel scoping: - packages/client/src/components/chat/chat-container.tsx: pass ('thread', activeThreadId) to abort() instead of an empty call. - packages/worker/src/durable-objects/session-agent.ts WebSocket 'abort' case: forward msg.channelType / msg.channelId to handleAbort. - packages/worker/src/durable-objects/session-agent.ts HTTP /prompt interrupt path: derive abortChannelType/abortChannelId from body.threadId (or body.channelType/body.channelId) so /stop-style HTTP interrupts also target the right thread. The runner's handleAbort already supports per-channel scoping (prompt.ts:2428) — it just wasn't receiving the channel info. Regression tests verify both the WebSocket and HTTP paths send a scoped abort frame.
|
Preview deployment: https://pr-46.dev-valet-turnkey-client.pages.dev |
yourbuddyconner
added a commit
that referenced
this pull request
Jun 12, 2026
…r their own stop button After PR #46 the stop button correctly aborted only the active thread, but switching to a still-running parallel thread showed no stop button. Root cause: the chat state stored a single global agentStatus, so whichever thread emitted the most recent agentStatus event clobbered every other thread's busy indicator — and the abort handler optimistically cleared that single field session-wide. Track agent status per-thread: - ChatState now carries threadStatuses: Record<threadId, {status, detail}>. - The agentStatus WebSocket handler updates threadStatuses[msg.threadId] alongside the legacy global fields. - The abort handler clears only the targeted thread's slot when scoped to ('thread', channelId); other threads' busy indicators stay intact. - chat-container derives activeThreadStatus from threadStatuses[ activeThreadId] (with a fallback to the legacy agentStatus for sessions whose first event predates this map), and computes isAgentActive / isAgentThinkingInThread from that. MessageList now receives the thread- scoped status rather than the global one. Net effect: clicking Stop on thread A leaves thread B's stop button visible while thread B is still running.
Closed
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #45. The Stop button issued a runner-wide abort regardless of which thread the user was viewing. Pre-#45 that was harmless because the orchestrator ran one turn at a time; with cross-thread concurrent drain enabled, the same global abort kills every in-flight turn.
The runner's `handleAbort` already supports per-channel scoping (`packages/runner/src/prompt.ts:2428`) — it just wasn't receiving the channel info from the client/DO.
Changes
The `/stop` slash command at `session-agent.ts:1422` and the broader empty-args `handleAbort()` paths are intentionally left as session-wide aborts.
Test plan