Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: let a closed stream reconnect and a failed caps read retry

When the server answers an event stream with an error status the browser
gives up and the badge stayed on disconnected with nothing to press. The
terminal, its state header and the messages page now offer a reconnect,
and the one rule for the state after an error moved into a tested helper.
The resource caps panel gets a retry beside its error, and its loading
state announces itself.
This commit is contained in:
iris 2026-10-21 23:16:04 +02:00 • committed by mara
commit 31b7452e56

View file

@ -0,0 +1,14 @@
// The state of an `EventSource` as the swarm UI's stream hooks report it.
export type ConnectionState = "connecting" | "open" | "reconnecting" | "closed";
/** `EventSource.CONNECTING`: the browser is retrying by itself. */
const CONNECTING = 0;
/** The state after an `error` event. While the browser is still retrying
* (`readyState` 0), the stream is "reconnecting". Any other state means the
* browser gave up, which it does when the server answers with a non-200 status
* or a wrong content type, so nothing reopens the stream unless the page does. */
export function connectionAfterError(readyState: number): ConnectionState {
return readyState === CONNECTING ? "reconnecting" : "closed";
}