#13902: fix: auto-recover on event gap instead of showing error
app: web-ui
stale
## Problem
When WebSocket events arrive with a sequence gap (missed events), the UI and TUI previously showed an error message asking the user to refresh manually. This was disruptive and unnecessary.
## Solution
Auto-recover by reloading chat history instead of showing an error.
### Changes
- **UI (app-gateway.ts)**: Call `loadChatHistory()` instead of setting `lastError`
- **TUI (tui.ts)**: Call `loadHistory()` with a brief 'resyncing...' status (2s instead of 5s)
### Before
- UI: Error banner "event gap detected... refresh recommended"
- TUI: Status "event gap: expected X, got Y" for 5 seconds
### After
- UI: Silently reloads chat history (logs to console only for debugging)
- TUI: Brief "resyncing (event gap X→Y)" status while reloading
The gap is logged to console for debugging but no longer surfaces as a user-visible error.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR changes how the UI and TUI react to WebSocket sequence gaps: instead of surfacing an error prompting a manual refresh, both clients attempt to self-heal by reloading chat history (`loadChatHistory()` in the web UI and `loadHistory()` in the TUI). The web UI also logs a console info line for debugging, while the TUI shows a short-lived “resyncing…” status message during the reload.
These changes plug into the existing gateway client gap callback (`onGap`) alongside the existing reconnect logic in `connectGateway()` and the TUI’s `GatewayChatClient` event loop.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge, but there is one correctness concern around TUI state consistency during mid-stream gap recovery.
- The changes are small and localized to gap handling, and the recovery path reuses existing history-loading code. The main risk is the TUI leaving in-flight run/status state intact while replacing history, which can produce inconsistent UI behavior when gaps occur during streaming.
- src/tui/tui.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9218: Fix Control UI chat resync on gaps and terminal events
by figitaki · 2026-02-05
87.9%
#16767: fix: auto-resync webchat on reconnect and prevent message flicker o...
by alewcock · 2026-02-15
84.1%
#14309: fix(ui): resolve chat event session key mismatch
by justonlyforyou · 2026-02-11
80.7%
#9195: Fix: Control UI fails to render new messages after chat.history Web...
by vishaltandale00 · 2026-02-05
79.3%
#15564: fix: webchat messages disappear during concurrent session activity
by Automatedcapitalist · 2026-02-13
79.2%
#14966: fix(webchat): preserve user message visibility after chat.send
by BenediktSchackenberg · 2026-02-12
78.4%
#14993: fix(webchat): add heartbeat detection to prevent zombie WebSocket c...
by BenediktSchackenberg · 2026-02-12
78.3%
#19343: Refactor chat state management: reset chat messages and queue on se...
by saurav470 · 2026-02-17
77.5%
#3721: fix(ui): webchat not displaying chat responses
by maxmaxrouge-rgb · 2026-01-29
77.2%
#9220: Fix: TUI drops API responses silently when runID already finalized
by vishaltandale00 · 2026-02-05
77.0%