fix(chat-widget): retry health check so the widget doesn't vanish on a blip#450
Conversation
🔐 Commit Signature Verification✅ All 1 commit(s) passed verification
Summary
Required key type: Last verified: 2026-07-09 10:35 UTC |
Greptile SummaryThis PR makes the chat widget retry its health check instead of hiding after one failed request. The main changes are:
Confidence Score: 5/5The changed flow looks safe to merge after a small cleanup to avoid duplicate polling.
src/components/ChatWidget.tsx Important Files Changed
Reviews (1): Last reviewed commit: "fix(chat-widget): retry health check so ..." | Re-trigger Greptile |
✅ Retry logic unit-tested (faithful port, delays ÷100 to run fast)Confirms: retries on the front-loaded schedule (0/2/7/20/50/110s, then 60s poll), stops immediately when This is frontend-only; the backend keepalive (devex-ai-bot#63, verified live: cold query 12.4s → 7.0s warmed) reduces how often these retries even fire. @kkkk666 could you review? 🙏 |
…a blip The AI chat entry points (floating bubble + header button) were gated on a single, no-retry /health fetch that defaults to hidden and fails closed: one slow/failed/timed-out response (a cold pod, a 503 during warmup, a rolling deploy, or any transient) left `isApiHealthy=false` and the whole widget rendered null until a full page reload. This is the "sometimes it doesn't load at all" symptom. Now the health check retries on a front-loaded schedule — attempts at 0, +2s, +7s, +20s, +50s, +110s (6 checks within ~110s, under 2 min), then a slow 60s poll while still unhealthy — and stops immediately once /health responds. Also re-checks on tab focus (visibilitychange) so a pod that recovers while the tab was backgrounded un-hides the widget without a reload. Per-attempt timeout tightened 5s -> 4s; retries cancelled on unmount. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d04e22b to
9528107
Compare
|
Addressed Greptile review (commit
Re-signed with YubiKey. tsc passes with no ChatWidget errors. |
Why
Users report the AI chat widget sometimes doesn't load at all (needs a page refresh). Root cause: both entry points (the floating bubble and the header "Ask Babylon AI" button) are gated on a single, no-retry
/healthfetch that defaults to hidden and fails closed:isApiHealthystartsfalse; onefetch('/health')with a 5s abort runs on mount.isApiHealthystaysfalseandif (!isApiHealthy) return nullrenders nothing (and the header button's reveal-CSS is never injected).503during warmup, a rolling deploy of the single replica, or any transient blip hides the widget until a full reload.What
/healthresponds OK.visibilitychange) so a pod that recovers while the tab was backgrounded shows the widget without a reload.Frontend-only; ships independently of the backend keepalive work (devex-ai-bot#63, actions#60), which reduces how often these retries even fire.
Notes
🤖 Generated with Claude Code