Plan 5, tasks 4-5: the subscriber, and wiring it into the editor
live-updates.mjs owns the cursor, the connection policy and fetch serialization, with everything injected so it runs under plain Node like the two client modules beside it. editor-entry.js gets wiring only: a currentLive replaced wholesale on every resync exactly as the save queue and the view already are, a cursor seeded from the initial GET's Docs-Seq, and the POST's own seq read inside the post closure so save-queue.mjs stays untouched. Two rules in here look like fussiness and are not. The module owns every open and every close, because EventSource reconnects natively on any server close — including the idle close the module just chose and the server's own TTL — so relying on it would have a parked tab reopening its stream forever and holding a hibernating instance awake. And "activity" means pointermove and scroll as much as keydown, because visibility, focus and typing all miss the same case: someone READING a long document on a tab that is already visible and already focused fires none of them, and that tab is the watching half of the whole feature. A dead stream is logged and nothing else. [docs-save-status] means "your edit did not save", which stays false — POST is a separate path and is unaffected. What is lost is freshness, and it heals on the next activity.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
6 files changed,
+600
−20
.amadan/ci.d/10-gate+12 −0fixtures/editor-entry.js+116 −6fixtures/live-updates.mjs+192 −0fixtures/live-updates.test.mjs+266 −0internal/docs/static/editor.8a89ccea195affe8.js+14 −0internal/docs/static/editor.98af6ed37bba8906.js+0 −14
CI passed — run details
Intent
Attributed to this commit: 312 g CO₂e (37968705 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on worktree-live-sync, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
.amadan/ci.d/10-gateLoading diff…
fixtures/editor-entry.jsLoading diff…
fixtures/live-updates.mjsLoading diff…
fixtures/live-updates.test.mjsLoading diff…
internal/docs/static/editor.8a89ccea195affe8.jsLoading diff…
internal/docs/static/editor.98af6ed37bba8906.jsLoading diff…