fix(app): automatically send queued messages - #2695
Draft
MikoyChinese wants to merge 2 commits into
Draft
Conversation
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.
Linked issue
Closes #2693
Type of change
What does this PR do
Queued follow-up messages could remain pending after the active turn completed. A timeline
turn_completedevent optimistically updated the shared UI agent state to idle before the authoritative directory update arrived, so the later directory update no longer observed a running-to-idle transition and did not drain the queue.This change keeps the last authoritative daemon state inside
AgentDirectoryReplica. Timeline state remains available for optimistic UI updates, while queue draining is triggered only by authoritative running-to-non-running transitions. Archived agents do not drain. The existing FIFO, one-message-per-turn, failure restoration, attachment, snapshot, reconnect, remove, and re-add behavior is preserved.How did you verify it
Reproduction before the fix
The regression test applies the same event order as the report:
turn_completedoptimistically changes the shared UI state to idle.agent_updatearrives.Against the old implementation, the test failed with:
The same test passes after the fix and observes exactly one stopped-running callback.
Automated checks
Run from
packages/appwhere noted:The Playwright test uses a real isolated daemon and deterministic provider. It holds the authoritative idle update until after
turn_completedhas optimistically changed the UI state, then verifies that releasing the update automatically sends the queued message, removes the queue row, and starts the next turn.Run from the repository root:
HostRuntime coverage also checks FIFO order, one message per turn, original message IDs, duplicate-drain prevention, failed-send restoration, image encoding, uploaded files, modern Forge attachments, and legacy GitHub attachments.
Platform coverage
This is a draft because post-fix Windows desktop manual QA and interaction video are still pending.
Checklist
npm run typecheckpassesnpm run lintpassesnpm run formatpasses