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:
@@ -810,3 +810,55 @@ code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
Transport: the persistent connection banner (T5) and the live badge. The
|
||||
banner is in normal flow directly under the header, so it can never cover the
|
||||
content; its container colours follow ConnectionBanner.kt's Material roles
|
||||
(surfaceVariant idle/connecting, errorContainer disconnected, primary
|
||||
connected). Hand-written, on the app's dark palette.
|
||||
--------------------------------------------------------------------------- */
|
||||
|
||||
.conn-banner {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 8px 16px;
|
||||
font-size: 13px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--surface-2);
|
||||
color: var(--text);
|
||||
}
|
||||
.conn-banner[hidden] { display: none; }
|
||||
.conn-banner-dot::before { content: "\25cf"; }
|
||||
.conn-banner-text { font-weight: 500; }
|
||||
.conn-build { margin-left: auto; color: var(--muted); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
||||
.conn-warning { color: var(--warn); font-weight: 600; }
|
||||
|
||||
/* Idle: surfaceVariant (never an error colour — nothing is wrong yet). */
|
||||
.conn-idle { background: var(--surface-2); color: var(--muted); }
|
||||
.conn-idle .conn-banner-dot::before { color: var(--muted); }
|
||||
|
||||
/* Connecting: surfaceVariant with a warm dot, matching the state badge. */
|
||||
.conn-connecting { background: var(--surface-2); color: var(--muted); }
|
||||
.conn-connecting .conn-banner-dot::before { color: var(--warn); }
|
||||
|
||||
/* Disconnected: errorContainer. */
|
||||
.conn-error { background: #2c1616; color: var(--bad); }
|
||||
.conn-error .conn-banner-dot::before { color: var(--bad); }
|
||||
.conn-error .conn-build { color: var(--muted); }
|
||||
|
||||
/* Connected: an explicit green (primary) state, the page's one visible
|
||||
difference from ConnectionBanner.kt, which renders nothing once connected. */
|
||||
.conn-ok { background: #12251b; color: var(--ok); }
|
||||
.conn-ok .conn-banner-dot::before { color: var(--ok); }
|
||||
|
||||
/* Live-stream badge (LiveBadge.kt): a dot plus the honest word, so colour is
|
||||
never the only signal. */
|
||||
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
|
||||
.live-badge .live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
|
||||
.live-live { color: var(--ok); }
|
||||
.live-reconnecting { color: var(--warn); }
|
||||
.live-reconnecting .live-dot { opacity: 0.4; }
|
||||
.live-not-live { color: var(--muted); }
|
||||
.live-not-live .live-dot { opacity: 0.4; }
|
||||
|
||||
Reference in New Issue
Block a user