web: connection banner, reconnect, foreground recovery and live badge (T3/T4/T5)
Close T3, T4 and T5 of web/PARITY.md (the "Transport and connection" table). T1/T2/T6 are untouched beyond wiring. - src/connection.js (new): the pure, DOM/socket/timer-free helpers behind every new state — `bannerState` (the persistent banner's copy and tone), `stateBadge` (the compact header indicator, which is also where the retry attempt is named), `foregroundAction` (the return-to-foreground policy from ConnectionRecovery.kt), `protocolMismatch`, `serverBuildLabel` and `liveBadgeState`. Wording and colour roles mirror ConnectionBanner.kt, LiveBadge.kt/RunStream.kt and SettingsScreen.kt. - src/app.js: wiring only. The banner sits in normal document flow under the header (never overlaying content); a Reconnect control appears beside the URL field whenever `bannerState` offers one and re-opens the same validated endpoint through `client.connect`, resetting the backoff; `visibilitychange`/`online` drive the foreground recovery; the ping reply records the server build and protocol for the banner. - src/protocol.js: `PROTOCOL_VERSION = 1`, citing internal/protocol/ identity.go and Message.kt. - styles.css: the .conn-* banner and .live-badge rules in the app's dark palette, on the existing :root variables. - test/connection.test.mjs (new): 18 focused unit tests for the pure helpers, including source-parity assertions against the Android files. - test/ui-smoke.mjs: assert the connected banner + build line + live badge and capture them, then point the page at a closed port to capture the disconnected retry banner and recover via the browser's `online` event. - PARITY.md: T3/T4/T5 done with their captures. Checks: `node --check` on all five touched JS/MJS files; `node --test test/` 190 pass / 0 fail (18 new); `node test/ui-smoke.mjs --out ... /web/captures` UI SMOKE PASS against ws://127.0.0.1:8080/connect, writing 28-connected-banner.png, 29-disconnected-banner.png and 30-reconnect-recovered.png.
This commit is contained in:
@@ -25,6 +25,15 @@ export const Protocol = Object.freeze({
|
||||
FAILURE_END: "#failure",
|
||||
});
|
||||
|
||||
/**
|
||||
* The integer wire protocol this page speaks. Mirrors `ProtocolVersion` in
|
||||
* internal/protocol/identity.go and the value the Android client compares in
|
||||
* `data/protocol/Message.kt` (the `protocol` field of the `pong` reply). It is
|
||||
* compared as a number, never a string; a differing server value is surfaced as
|
||||
* a warning rather than silently misread.
|
||||
*/
|
||||
export const PROTOCOL_VERSION = 1;
|
||||
|
||||
export function isTerminal(target) {
|
||||
return target === Protocol.SUCCESS_END || target === Protocol.FAILURE_END;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user