Repository navigation
This release adds retry logic and sanitised error messages when the LLM API fails.
Problem:
When the OpenAI API returned a transient error (e.g. Cloudflare 520), the raw HTML error page was dumped directly into the chat, producing a wall of unreadable markup for the user.
Changes:
- HTML error detection:
sanitizeApiError()detects HTML responses (Cloudflare, nginx, etc.) and extracts the<title>for a concise one-line message - Automatic retries: Transient errors (429, 500, 502, 503, 504, 520-522, 524) now retry up to 2 times with exponential back-off (3s, 6s)
- User status updates: During retries the chat shows "AI service temporarily unavailable — retrying (1/2)…" so users know what's happening
- Friendly catch-all errors: Timeout and connection-refused errors now show human-readable messages instead of raw
Error: <message> - Error text capping: Non-HTML errors longer than 400 chars are truncated to avoid flooding the UI
Result: Users now see a short, actionable message like "The AI service returned an error (api.openai.com | 520: Web server is returning an unknown error). This is usually a temporary issue — please try again in a moment." — and in most cases the retry succeeds transparently.