Skip to content

fix(flow-chat): settle dialog turn completion unconditionally (light-tested) - #2657

Open
1688mengdie wants to merge 1 commit into
GCWing:mainfrom
BitFun-SIG:fix/flow-chat-unconditional-turn-completion
Open

fix(flow-chat): settle dialog turn completion unconditionally (light-tested)#2657
1688mengdie wants to merge 1 commit into
GCWing:mainfrom
BitFun-SIG:fix/flow-chat-unconditional-turn-completion

Conversation

@1688mengdie

Copy link
Copy Markdown

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

  • src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.ts: eventOwnsLatestSessionTurn prefers currentDialogTurnId; the failure path performs a single FINISHING_SETTLED transition; the two completion-path ownsSessionSettlement gates are removed so completion settles unconditionally.
  • src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts: adds the regression case "settles the state machine when completion arrives for a non-latest turn".
  • Commit: 6012aa4 — fix(flow-chat): settle dialog turn completion unconditionally

Testing

  • pnpm vitest run src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts → 1 test file passed, 48 tests passed, 0 failed (includes the new regression case)
  • pnpm run type-check (tsc --noEmit) → exit 0, no errors

Environment

All platforms (frontend state machine); baseline 32f2427.


AI-assisted change, reviewed and verified as described above (light-tested locally).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: chat UI can stay stuck processing when a dialog turn completion event is dropped

1 participant