oficina / docs Public

docs: the live stream owns its page lifecycle; check coverage by logical family

Review on #86.

P2: the editor registered its pagehide/pageshow handlers after the
fonts were ready and two animation frames, but started the stream
before. A page left in between, or hidden and so running no frames,
went into the back/forward cache with its stream open; Astra saw two
streams held in full Chrome, and cached restores with no handlers in an
occluded WKWebView. live-updates.mjs now owns the page's lifecycle: one
pagehide/pageshow listener installed when the module loads, before any
subscriber or stream can exist, which closes every stream on pagehide,
refuses to open one in a page that has been left, and reopens on
pageshow from the cache, on the next task (WebKit fails a stream opened
inside pageshow, then reconnects one the module no longer holds). The
editor's own handlers are gone.

P2: the coverage test no longer subtracts committed families. Each
element and text node's logical family (its font mark's class, code or
pre, or the default) is checked before any fallback: the gate's
families are exactly the DOM's logical families and every logical face
is one the gate waited for; a committed family must be one the gate
waited for and is drawn only in its declared fallback; what is drawn is
the gate's families less those committed. A second pass makes every
face late past the deadline, so committed families are exercised.

Tests, failing first:
- TestLeavingADocumentEarlyLetsGoOfItsStream: Chromium with its
  back/forward cache on (fixtures/engines/leaving.mjs) and a hidden
  WKWebView (fixtures/engines/leaving-webkit.swift), no animation
  frames, leaving the moment the stream opens; a collaborator edits
  while it is away. On 6b2a727 and on main a0dd33a, Chromium keeps the
  stream open in the cache, and WebKit never reconnects or catches up.
- live-updates.test.mjs: leaving closes and coming back reopens and
  catches up; a page left before its subscriber starts opens nothing.
- The coverage test under late fonts catches two gate mutations (an
  extra family, and italics left out) that the old subtraction let
  through.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 6955cf261ba5a40954edd2bb9c154c1d8f893f28 parent 220e82e
8 files changed, +659 −121
  • fixtures/editor-entry.js +2 −7
  • fixtures/engines/leaving-webkit.swift +115 −0
  • fixtures/engines/leaving.mjs +59 −0
  • fixtures/live-updates.mjs +65 −14
  • fixtures/live-updates.test.mjs +34 −5
  • internal/docs/fonts_browser_test.go +159 −85
  • internal/docs/leaving_browser_test.go +215 −0
  • internal/docs/static/{editor.a987940e8957731f.js => editor.196c375f7a6a7ab9.js} +10 −10

CI passed — run details

fixtures/editor-entry.js

Loading diff…

fixtures/engines/leaving-webkit.swift

Loading diff…

fixtures/engines/leaving.mjs

Loading diff…

fixtures/live-updates.mjs

Loading diff…

fixtures/live-updates.test.mjs

Loading diff…

internal/docs/fonts_browser_test.go

Loading diff…

internal/docs/leaving_browser_test.go

Loading diff…

internal/docs/static/{editor.a987940e8957731f.js => editor.196c375f7a6a7ab9.js}

Loading diff…