Repository navigation
feat(frontend): add SSE recovery banner with reconnect countdown - #387
Merged
VarshithReddy2006 merged 1 commit intoNov 17, 2026
Conversation
Show a polite status banner when the realtime connection drops, with a countdown to the next retry, a Reconnect Now button, a short Connected! message on recovery and a refetch of the runtime-state query. useSse now exposes nextReconnectAt and a reconnectNow() helper. Its store snapshot is also a fresh copy per change now, because the in-place mutated object meant useSyncExternalStore never re-rendered subscribers. Closes VarshithReddy2006#364 Signed-off-by: Abhishek <abhishekcse2004@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the SSE connection drops the user currently gets no feedback at all. This adds a small status banner with a retry countdown and a Reconnect Now button, and refreshes the runtime state once the stream is back.
Closes #364
What changed
RecoveryOverlay.tsx: newConnectionRecoveryBanner(rendered byRecoveryOverlaynext to the existing comeback dialog, which is unchanged).role="status"+aria-live="polite"region that stays mounted so screen readers pick up changes. The per-second countdown isaria-hiddenso it does not get announced every second.useSsegave up (5 consecutive failures).['runtime-state']query (the hook behindGET /runtime-state).useSse.ts:nextReconnectAt(epoch ms) in the store and in the hook result, set inscheduleReconnectand cleared when the timer fires, on open and on disconnect.reconnectNow(): cancels the pending backoff timer and connects right away. No-op while connected or already connecting (double click opens one stream). After the hook gave up it also resets the failure counter and the degraded flag so the manual retry gets a fresh budget.getSnapshotreturned the same mutatedstoreobject, anduseSyncExternalStoreonly re-renders when the snapshot identity changes, soconnectionStatusfromuseSse()never updated on its own.emitChangenow takes a fresh copy of the store as the snapshot.How I tested
From
frontend/, one file at a time:With the two source files stashed the new tests fail (9 of 10 in
RecoveryOverlay.test.tsx, 5 of 5 inuseSse.reconnect.test.ts). The one that passes on main is the "comeback dialog still renders" regression guard. Reverting only thegetSnapshotfix makes the "exposes when the next attempt happens" hook test fail.tsc --noEmit -p tsconfig.app.jsonshows no errors in the touched files (the remaining errors are unrelated missing modules in my local node_modules).Not tested / notes
/api/v2/runtime/state; on main the hook callsGET /runtime-state, so that is what gets invalidated.