fix(chat): clear stuck 'typing...' cursor on empty/hung streaming responses (#228)#349
Open
Guciolek wants to merge 1 commit into
Open
fix(chat): clear stuck 'typing...' cursor on empty/hung streaming responses (#228)#349Guciolek wants to merge 1 commit into
Guciolek wants to merge 1 commit into
Conversation
|
@Guciolek is attempting to deploy a commit to the Darshan's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
Closes #228 — fixes the bug where the assistant's "typing..." cursor and blinking caret remain visible forever when the streaming response is empty or the server hangs.
Root cause
In
App.jsx, whenuseStreamis true:aiMsgis created withstreaming: trueapi.streamMessage()is awaitedfinallyblock runssetStreaming(false)If the server returns
200 OKwith no tokens (empty body), the awaited promise resolves successfully, butstreamingon the message itself is only cleared by theonTokencallback (which never fires). Combined with no clear-time error, the user sees a permanent "typing..." + blinking cursor.What's changed
frontend/src/App.jsx:setTimeoutsafety net that forces the cursor away and shows(empty response)as a fallback if the stream never produces a tokenfinallysafety net that double-checks thestreamingflag on the message object — if it's stilltrueafter the await returns, it's forced tofalseand the message gets a(empty response)fallback if it has no contentTest plan
Manual:
Risk: Low. The new code is purely defensive — it only runs in
finallyand on timeout. Normal flow is unchanged.Closes #228