Repository navigation
fix(server): wake queued message dispatch on interrupted turn reaching idle - #3189
Closed
panysaurusrex wants to merge 1 commit into
Closed
panysaurusrex wants to merge 1 commit into
panysaurusrex wants to merge 1 commit into
Conversation
…le regardless of completion status Previously, turn completion only scheduled queued-message-dispatch follow-up if event.status === 'completed'. When a turn was interrupted (e.g. by steering or a user stop), reaching idle status did not wake queued-message-dispatch, leaving queued messages stranded in the database until an explicit turn request occurred.
Contributor
|
Thanks @panysaurusrex for the PR. This repo needs approval before a PR. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ) and explain what you want to open a PR for and why. A maintainer then adds you to the allow list. This PR now closes on its own. Reopen it or open a new one after approval. |
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
When a turn completed with
event.status === 'interrupted'(for example, when steered during execution or interrupted by a cancellation),turnCompleted.nextStatustransitioned the thread to'idle', but the server never scheduled aqueued-message-dispatchfollow-up. This was because the wake condition was strictly gated on:As a result, any messages queued while waiting for the thread to be idle (or steers waiting in the queue) remained stranded in
queued_thread_messageswithwaitingOn: { kind: 'thread-busy' }until the user manually triggered another turn.Changes
apps/server/src/internal/events.tsto schedulequeued-message-dispatchwheneverturnCompleted.nextStatus === 'idle', regardless of whetherevent.statuswas'completed'or'interrupted'.apps/server/test/internal/internal-events-turn-interrupted-queue-wake.test.tsverifying that an interrupted turn transitioning to idle immediately wakes the queue and dispatches the queued message.Verification
@bb/server:internal-events-turn-interrupted-queue-wake.test.tspasses.test/internal/suite (17 files, 107 tests) passes.test/threads/requested-queue-drain.test.ts&thread-send-dispatch.test.tspass.tsc --noEmitandoxlintpass with 0 errors.