Bugfix/chat send preflight delay - #141
Merged
douglasware merged 15 commits intoAug 30, 2026
Merged
Conversation
…turn_created observation point
…ght failures as SSE errors
Reset SET_CANCELLING/SET_STREAMING_ERROR/pendingStopRef/activeStreamTurnId before the optimistic dispatches (which flip isStreaming true and make the Stop button clickable) instead of after the runtime preflight resolves. Previously a Stop click during the preflight queued a pending stop that clearPendingStop() then wiped out once the preflight finished, before onTurnIdAssigned ever got to replay it against the real turn id. Also reset SET_CANCELLING inside rollbackOptimisticSend so a Stop-then-runtime-not-ready sequence can't leave _isCancelling true. Closes the stale-active-stream-turn-id gap on the sendMessage success path as a side effect: setActiveStreamTurnId(null) now runs before the optimistic dispatches, not just on later error/teardown paths.
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
Reduces the delay between a user sending a chat message and the request reaching the LLM (the "preflight" path in
ConversationService.SendMessageStreamCoreAsync). The bottlenecks were query-shape/N+1/round-trip issues, not missing indexes — this branch fixes those directly:"streaming"status, dropping a redundant DB round trip.AsNoTracking()+.AsSplitQuery(), removing a cartesian-product jointurn_createdbefore preflight history/attachment setup finishes, so the client isn't blocked on it, with proper failure handling if preflight fails after that early yield29f1ae9d)(fileId, lastModifiedTicks)instead of re-rendering the same attachment on every sendAlso: removes a redundant conversation-snapshot GET after sending a message, and adds preflight timing instrumentation.
Measured impact
main(before)