fix(flow-chat): settle dialog turn completion unconditionally (light-tested) - #2657
Open
1688mengdie wants to merge 1 commit into
Open
fix(flow-chat): settle dialog turn completion unconditionally (light-tested)#26571688mengdie wants to merge 1 commit into
1688mengdie wants to merge 1 commit into
Conversation
handleDialogTurnComplete gates settlement on eventOwnsLatestSessionTurn, which requires the completed turn to be the latest dialog turn. When an optimistic follow-up turn exists, the completion event for the older turn is dropped and the session stays PROCESSING forever. Ownership matching now prefers the machine's currentDialogTurnId, the failure path settles with a single FINISHING_SETTLED transition instead of ERROR_OCCURRED→RESET (which clears currentDialogTurnId and desynchronizes later ownership checks), and completion events settle unconditionally (BACKEND_STREAM_COMPLETED while PROCESSING plus an unconditional beginTurnCompletion). The ownsSessionSettlement mechanism stays in place at all other consumption points. Test: pnpm vitest run src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts (48 passed, 0 failed) + pnpm run type-check (0 errors) AI: This change was assisted by AI and lightly tested.
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.
Closes #2656
Summary
handleDialogTurnComplete gates settlement on eventOwnsLatestSessionTurn, which requires the completed turn to be the last dialog turn; when an optimistic follow-up turn exists (or the machine context was reset by the failure path), the completion event is dropped and the session stays PROCESSING forever.
Ownership matching now prefers the machine's currentDialogTurnId, the failure path settles with a single FINISHING_SETTLED transition instead of ERROR_OCCURRED→RESET (which clears currentDialogTurnId and desynchronizes later ownership checks), and completion events settle unconditionally (BACKEND_STREAM_COMPLETED while PROCESSING plus an unconditional beginTurnCompletion). The ownsSessionSettlement mechanism stays in place at all other consumption points (:2703 failure cleanup, :2762 error unread, :2808 cancelled, :2871/:2929 interrupted, :2968).
Changes
Testing
Environment
All platforms (frontend state machine); baseline 32f2427.
AI-assisted change, reviewed and verified as described above (light-tested locally).