brauliogusmao stops the chat from failing silently

When the AI errored mid-reply, users just saw the spinner vanish. This fork makes the system tell them what actually went wrong.

chat-uiinfrastructure

Before this change, if the underlying AI provider hit a problem mid-stream - an expired API key, a rate limit, a context that was too long - the assistant simply stopped typing. No message, no warning, nothing to act on. brauliogusmao's fork now digs the real error message out of the provider's response and pipes it back into the chat bubble where the reply would have been.

A follow-up commit goes further: instead of just passing the raw text through, the backend classifies the error into a small set of categories - out of credits, bad key, rate-limited, context too long, timed out, overloaded - and the frontend shows a clean explanation for each. There's a fair-warning caveat here: the classification relies on matching words in the provider's error text, which can change without notice.

So what Legal teams piloting AI chat tools should care: silent failures destroy trust faster than honest error messages, and this is the kind of polish that separates a demo from a tool people actually rely on.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

2 commits from brauliogusmao/mike, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
ed833e17 fix: exibe mensagem de erro da API no balão do chat Braulio Gabriel Gusmao 2026-05-12 ↗ GitHub
commit body
Antes o backend enviava "Stream error" genérico e o frontend
ignorava o evento silenciosamente - o usuário via apenas o
spinner desaparecer sem explicação.

Backend: extrai a mensagem real do erro (ex: "Your credit balance
is too low...") da estrutura aninhada do SDK Anthropic/OpenAI e a
envia no evento SSE { type: "error", message: "..." }.

Frontend: trata o evento type="error" lançando a mensagem como
exceção, que é capturada pelo bloco catch existente e exibida
no balão do assistente como mensagem de erro.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4896b8c3 Traduz mensagens de erro do chat para português Braulio Gabriel Gusmao 2026-05-12 ↗ GitHub
commit body
Backend emite código de erro estruturado (code + message) para erros
conhecidos (saldo insuficiente, chave inválida, rate limit, etc.).
Frontend traduz pelo código; fallback para mensagem bruta ou genérica.
Corrige também o bug em que o throw dentro do try/catch interno era
silenciado - agora usa variável streamError propagada após o loop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-389.md from inside the repo you want the changes in.

⬇ Download capture-thread-389.md