Skip to content

fix(chat): clear stuck 'typing...' cursor on empty/hung streaming responses (#228)#349

Open
Guciolek wants to merge 1 commit into
imDarshanGK:mainfrom
Guciolek:nabu-empty-response-fix
Open

fix(chat): clear stuck 'typing...' cursor on empty/hung streaming responses (#228)#349
Guciolek wants to merge 1 commit into
imDarshanGK:mainfrom
Guciolek:nabu-empty-response-fix

Conversation

@Guciolek

@Guciolek Guciolek commented Jun 6, 2026

Copy link
Copy Markdown

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, when useStream is true:

  1. An aiMsg is created with streaming: true
  2. api.streamMessage() is awaited
  3. The finally block runs setStreaming(false)

If the server returns 200 OK with no tokens (empty body), the awaited promise resolves successfully, but streaming on the message itself is only cleared by the onToken callback (which never fires). Combined with no clear-time error, the user sees a permanent "typing..." + blinking cursor.

What's changed

frontend/src/App.jsx:

  • Added a 60s setTimeout safety net that forces the cursor away and shows (empty response) as a fallback if the stream never produces a token
  • Added a finally safety net that double-checks the streaming flag on the message object — if it's still true after the await returns, it's forced to false and the message gets a (empty response) fallback if it has no content
  • The original error path (catch) is preserved
  • The success path (onSources callback) is preserved — this PR is purely additive

Test plan

Manual:

  • Send a query that the LLM responds to normally → "typing..." disappears, response shows
  • Simulate empty response (mock backend) → after max 60s, "(empty response)" appears
  • Force an error → error message appears, cursor disappears
  • Type and send a query, then close the network tab mid-stream → after 60s, cursor clears

Risk: Low. The new code is purely defensive — it only runs in finally and on timeout. Normal flow is unchanged.

Closes #228

@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

@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.

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.

Fix: empty assistant response still shows typing cursor

1 participant