refactor(fe): trim >30-line comment blocks (second pass, #2077)

This commit is contained in:
iris 2026-06-29 00:55:31 +02:00 committed by mara
commit 95b866a53d
5 changed files with 55 additions and 118 deletions

View file

@ -4,39 +4,26 @@
// account and store its access token, without editing the agent's config
// repo. Companion to the multi-account harness support.
//
// Backend contract (v2 — BE-4 adds live/user_id/as_of from the daemon snapshot):
// Backend contract:
// GET /api/matrix-accounts?agent=<name>
// -> { accounts: [ { name, homeserver: string|null, token_present: bool,
// live: bool, user_id: string|null } ],
// -> { accounts: [{name, homeserver, token_present, live, user_id}],
// as_of_unix: int|null }
// POST /api/matrix-account-login (x-www-form-urlencoded, operator-auth)
// POST /api/matrix-account-login (x-www-form-urlencoded)
// fields: agent, account, homeserver, mode=password|token,
// user_id?, password?, token?
// -> 200 JSON { ok: true, user_id } on success
// -> error body in transition: today a bare plain-text body
// (hive-c0re's error_response), migrating to RFC 9457
// application/problem+json { type, title, detail, … }. The error
// path reads shape-agnostically (text first, then JSON `detail` if
// it parses) so both shapes work regardless of BE/FE merge order.
// The token is NEVER echoed back in any response, and this page never
// re-renders a submitted secret.
// -> 200 { ok: true, user_id }. Error body shape-agnostic: plain text
// today, migrating to RFC 9457 problem+json { detail, … }.
// Token is never echoed; page never re-renders a submitted secret.
//
// Live status dot (coordinated with the BE snapshot + heartbeat): the daemon
// force-rewrites its host-visible snapshot every ~30s (heartbeat, BE), so
// `as_of_unix` advances while the daemon is alive — a stalled `as_of` is now an
// honest "daemon stopped publishing" signal, not just "snapshot is old". We
// render —
// green (live + running + fresh) = online
// dim green (live but as_of stale > ~90s) = heartbeat stopped, likely dead
// amber (live + container DOWN) = stale (container down ⟹ down)
// amber (token_present + !live) = provisioned but offline
// grey (no token) = not provisioned
// The dim-green age case is meaningful only because of the heartbeat: 3 missed
// ~30s beats (>90s) without the container being explicitly down means the
// daemon is up-but-dead or wedged. The container cross-ref still takes
// precedence (a stopped container is definitively stale regardless of age).
// `as_of_unix` is tooltipped throughout so freshness is always legible. When
// `live` is absent (v1 backend) the dot falls back to token-present rendering.
// Live status dot — the daemon heartbeats every ~30s (advances as_of_unix),
// so a stalled as_of = daemon dead, not just stale snapshot:
// green live + running + fresh = online
// dim green live but as_of stale > ~90s = heartbeat stopped
// amber live + container DOWN = definitively stale
// amber token_present + !live = provisioned but offline
// grey no token = not provisioned
// Container state takes precedence; as_of_unix is tooltipped for freshness.
// v1 backend (no `live` field) falls back to token-present rendering.
import { $, el, esc, fmtAgeSecs, renderServerWarnings } from './common.js';