Instant message echo + strict send ordering (connects move to beforeTurn) - #14
Merged
Merged
Conversation
Since the hibernation fix, send() awaited a setup(connect) round-trip (DO wake + engine MCP connect, 1-3s) before sendMessage — so a sent message vanished from the composer with nothing echoed on screen, and two quick sends could invert: the first paid the slow connect while the second found connections open and overtook it on the wire. Connections now open server-side in Think's beforeTurn (which returns the freshly connected MCP tools to merge into the turn, since Think assembles its automatic toolset before the hook while nothing is connected). The client sends immediately; sends are additionally serialized through a promise chain so ordering can never invert, with the first-message settings push bounded at 4s so it can't swallow a message. Retry no longer needs a pre-connect either, and plain settings pushes on chats skip Google entirely (the consent flow is desk-only). Claude-Session: https://claude.ai/code/session_01MKLJUWk6biNAKXupHTTWn5
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.
Fixes the vanishing-message feel (send awaited a 1–3s MCP connect before echoing) and the out-of-order sends it caused (a fast second setup could overtake a slow first one). Connections open server-side in beforeTurn, which merges the fresh MCP tools into the turn; client sends immediately and serializes through a chain.
Note: the main-branch deploy job will fail until the CLOUDFLARE_API_TOKEN repo secret is refreshed (token expired 2026-08-29).
https://claude.ai/code/session_01MKLJUWk6biNAKXupHTTWn5