Dashboard: eliminate REST fleet refresh with SSE-pushed snapshots#388
Conversation
Implementation PlanProblem analysisThe current turn-boundary path is confirmed: runtime events pass through The proposed event mapping needs two corrections from the current types:
The implementation should therefore seed each runtime's complete baseline state from the existing initial/create/resync snapshot, update only event-derivable fields in memory, and refresh stats/context usage on the slower stats cadence. Initial and recovery fleet reads remain authoritative but become exceptional rather than turn-boundary traffic. The issue explicitly requires evidence before committing to the architecture. Implementation is therefore split by an empirical checkpoint: land privacy-safe measurement support first, post aggregate baseline results on the PR, and proceed with the SSE replacement only if the measurements confirm that fleet REST work materially contributes to the weak-mobile path. DeliverablesStage 1 — Measurement and go/no-go checkpoint
Stage 2 — SSE-pushed fleet state
Stage 3 — Single-call session hydration
Stage 4 — Documentation and validation
Acceptance criteria
Files to create or modifyMeasurement and harness
Server and protocol
Client
Tests
Documentation
Testing approach
Risks and open questions
Plan created by mach6 |
Vitest coverage
|
Baseline measurement checkpointThe measurement gate confirms the fleet REST path is the dominant weak-mobile bottleneck, so implementation can proceed to the SSE snapshot stages. Sanitized local workload:
Results:
At 1.5 Mbps, one uncompressed fleet response has a transfer-time floor of roughly 83 seconds before RTT or contention. The current Express response had no content encoding, and the server/client byte measurements matched exactly. Even allowing for a compressing proxy, the roughly 15.6 MB repeated inventory response and roughly 0.9 seconds of local server work dominate the measured SSE traffic by several orders of magnitude. The trace did not exercise model text deltas, so it is not a complete upper bound on active-stream SSE bandwidth. That does not change the go decision: removing lifecycle-triggered fleet reads is strongly supported by the measured payload and processing cost. |
After-change measurementRepeated the sanitized five-runtime, 687-disk-session, 60-second local profile after building the implementation. The workload produced 55 session-name events in 12 bursts, causing 12 coalesced fleet snapshots.
The authoritative fleet endpoint remains intentionally expensive because it is still used for initial load and exceptional recovery. The improvement is removing it from the lifecycle path: one five-runtime snapshot is roughly 1,370 times smaller than the measured full fleet body, and the entire minute of after-change SSE traffic was roughly 110 times smaller than one fleet response. The real Chromium acceptance test passed with 100 ms latency and 1.5 Mbps throughput: exactly one initial |
Progress UpdateFull implementation pushed — all four stages:
Review findings from code-reviewer, error-auditor, test-reviewer, and completeness-checker were addressed: monotonic message count now allows fork/rewind decreases, hydration uses barrier-ordered replay, disk inventory converges across tabs on membership changes and Commit: Progress tracked by mach6 |
Code ReviewCriticalNo critical findings. ImportantFinding 1 — Hydration queue overflow path is untested
Finding 2 — Superseding hydration for the same key is untested
Finding 3 — Stale hydrate overwrites newer fleet snapshot state
Finding 4 —
Finding 5 —
Finding 6 —
Finding 7 — Browser test has a CI-flaky wall-clock timing assertion
SuggestionsFinding 8 — Unhandled promise rejection from the stats interval
Strengths
Agents run: code-reviewer, error-auditor, test-reviewer, completeness-checker, simplifier (pending) Reviewed by mach6 |
Review AssessmentReview comment: #388 (comment) Classifications
Action Plan
Deferred: Mobile PWA SSE reconnection latency — pre-existing Everything else (findings 2, 7–12) requires no action before merge. Assessment by mach6 |
…g tests - capture fleetMutationGeneration at hydrate start and skip setHydratedRuntimeState if fleet mutated mid-flight (findings 1+3) - add hydration queue overflow tests (count and bytes) (finding 4) - add superseding-hydration test (finding 5) - add fleet_snapshot race regression test (finding 1+3) - add agent_end with errorMessage test (finding 6) - pre-commit hook now runs dashboard tests only (fast, no live APIs)
Review Fixes AppliedFixed all 5 genuine findings from the review:
Verification: All 708 dashboard tests pass, biome clean, Also: The pre-commit hook now runs Commit: |
Every describe.skipIf/it.skipIf block gated on provider credentials now also checks process.env.DREB_SKIP_LIVE_API === "1" so live-API tests can be skipped en masse without unseting env vars or maintaining a key list. test.sh accepts --no-live-api which exports DREB_SKIP_LIVE_API=1. .husky/pre-commit passes --no-live-api so the hook runs the full suite minus live-API tests. Manual full runs (bash test.sh) still hit APIs. 340 skipIf conditions across 29 files guarded. Commented-out code left untouched.
|
24h testing on mobile network, and I can honestly say this fix has already made a huge impact. Stability and speed are both much improved, usability is way up in a lower data environment. Solid 5G signal now behaves about as well as localhost. |
Code ReviewCriticalNo critical findings. ImportantFinding 1 —
SuggestionsFinding 2 —
Finding 3 — One stalled stats request freezes every future fleet stats poll
Finding 4 — Unrelated fleet mutations suppress hydrated state for the target runtime
Finding 5 — Files-screen session creation lacks behavior-level regression coverage
Finding 6 — Read-only hydration advances the fleet card's activity timestamp
Finding 7 — Filter surviving fleet snapshots once
Finding 8 — Remove unreachable synchronous error wrapper around
Finding 9 — Consolidate duplicate runtime-state patch functions
Strengths
Agents run: code-reviewer, error-auditor, test-reviewer, completeness-checker, simplifier Reviewed by mach6 |
Review AssessmentReview comment: #388 (comment) Classifications
Action Plan
Counts: 7 genuine, 2 nitpicks, 0 false positives, 0 deferred. Assessment by mach6 |
Remaining Review Findings FixedAddressed all seven genuine findings from the latest assessment:
Validation passed: Biome, build, Commit: Progress tracked by mach6 |
Code ReviewCriticalNo critical findings. ImportantNo high-severity findings. SuggestionsFinding 1 — Successful stop actions rely entirely on SSE to remove the runtime locally
Finding 2 — The first snapshot for a created/resumed runtime can remain fallback-only
Finding 3 — Unrelated fleet mutations can suppress authoritative lower stats counts
Finding 4 — A pre-barrier fleet snapshot can suppress a newer hydrate card baseline
Finding 5 — Runtime-stop controls lack behavior-level regression tests
Finding 6 — The fork test still mocks the removed full-fleet behavior
Finding 7 — The error snapshot test does not assert the projected error state
Finding 8 — The mobile profiler's production byte-stream path is untested
Finding 9 —
Finding 10 — Runtime model and thinking-level setters duplicate the same patch mechanics
Strengths
Agents run: code-reviewer, error-auditor, test-reviewer, completeness-checker, simplifier Reviewed by mach6 |
Review AssessmentReview comment: #388 (comment) Classifications
Action Plan
Counts: 8 genuine, 2 nitpicks, 0 false positives, 0 deferred. Assessment by mach6 |
Final Review Findings FixedAddressed all eight genuine findings from the latest assessment:
Validation passed: build, TypeScript, Biome, workspace-link verification, all 734 dashboard tests, and the full no-live suite with 4,942 passed and 706 skipped. Commit: Progress tracked by mach6 |
Closes #387
Measure the dashboard's mobile fleet-refresh bottleneck, then—if the baseline confirms the diagnosis—replace lifecycle-triggered full fleet reads with debounced SSE snapshots and consolidate session hydration into one request/RPC call.
Implementation plan posted as a comment below.