Skip to content

fix: surface real chat errors and add a New Chat button#59

Open
madhavcodez wants to merge 1 commit intomainfrom
fix/chat-ux-improvements
Open

fix: surface real chat errors and add a New Chat button#59
madhavcodez wants to merge 1 commit intomainfrom
fix/chat-ux-improvements

Conversation

@madhavcodez
Copy link
Copy Markdown
Contributor

What this does

Stops the chat from silently lying when the backend is down, and gives users a way to start a fresh conversation without refreshing the page.

Error messages, not fake mock replies
Before this PR, any backend 5xx caused the chat to fall back to mock responses — in a demo context that looks like the product is working when it isn't. Now, real failures surface as an in-thread agent message: "Unable to reach the chat service. Please try again later." If the backend sent a Retry-After header on a 503, we parse it safely (integer, clamped to 1–3600 seconds) and append (retry after Ns) so users know when to try again.

New Chat button
A pencil-in-square icon in the chat header spawns a fresh conversation instantly. The handler also clears isThinking, inflightCountRef, and suppressMockRef so a new thread can't inherit a stuck "thinking..." indicator from a request still in flight.

How to verify

  1. Click the pencil icon in the chat header → thread resets to empty
  2. Kill the backend (docker compose stop postgis or Ctrl+C uvicorn), send a message → see the error message, NOT a fake response
  3. Send a message, then immediately click New Chat before the reply arrives → the new thread has no stuck spinner

Closes #41
Closes #55

Replace the silent mock fallback with an in-thread agent message
reading "Unable to reach the chat service. Please try again later."
for real backend failures. Read Retry-After on 503 responses, parse
it as an integer, and only append "(retry after Ns)" when it falls
within 1 to 3600 seconds so malformed headers never reach the UI.

Add a pencil-in-square New Chat icon in the chat header that resets
the active conversation. The handler also clears isThinking,
inflightCountRef, and suppressMockRef so a new thread cannot inherit
a stuck thinking indicator from an in-flight request.

Closes #41
Closes #55
@madhavcodez madhavcodez self-assigned this Apr 14, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontend Ready Ready Preview, Comment Apr 14, 2026 3:57pm

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.

New Chat button If chat fails, display message saying it failed instead of mock fallback

1 participant