Slides: resync keeps a waiting paste, the projector ignores stale answers, saves are counted
Astra's re-review of #27 at c1d2f4d. A resync no longer discards a change that waited for its font. The resync waits for it, keeps every local update made while diverged, and applies them once to the rebuilt document and saves them through its queue. From divergence the tab writes under a fresh Yjs client id: Yjs integrates one client's updates only in clock order, so a paste written after the refused batch under the old id was held as pending forever. The projector cannot be rolled back by a late answer. Streamed slides, link/form/popstate pages and whole-state events share one counter in present.js; a request takes its number when it starts and is applied only while it is still the newest, before and after its fonts. A streamed slide swaps the stage and the bar together from the surface's own ?slide=n page, so the counter moves with it. The save queue has one save on the wire at a time, numbers every update and counts the batch on the wire until it is answered, so pendingBytes() is exact. flush() resolves only when every earlier update is answered: true if saved, false if refused, waiting through retries. A new slide goes up only after a true flush. After an in-place change focus stays on the control used, or goes to the slide when that control is gone; "Slide N of M: title" is said through a polite status region present from the first render. races_browser_test.go and six save-queue unit tests, each failing on c1d2f4d.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 files changed,
+734
−141
AGENTS.md+27 −5fixtures/commands.mjs+6 −2fixtures/editor-entry.js+65 −5fixtures/save-queue.mjs+104 −61fixtures/save-queue.test.mjs+128 −0fixtures/viewer-nav.mjs+33 −7internal/slides/credits/assets.json+3 −3internal/slides/locales/en.toml+3 −0internal/slides/presentation.go+5 −0internal/slides/static/{editor.32cedc10927dae66.js => editor.6f20169670d59132.js}+15 −15internal/slides/static/fontsgate.358bdc2e9398e6da.js+0 −1internal/slides/static/fontsgate.3753849cb5b94339.js+1 −0internal/slides/static/present.js+85 −39internal/slides/templates/present.html+4 −0internal/slides/templates/viewer.html+8 −2internal/slides/viewer.go+7 −1internal/slidestest/fonts_browser_test.go+8 −0internal/slidestest/races_browser_test.go+232 −0
CI passed — run details
AGENTS.mdLoading diff…
fixtures/commands.mjsLoading diff…
fixtures/editor-entry.jsLoading diff…
fixtures/save-queue.mjsLoading diff…
fixtures/save-queue.test.mjsLoading diff…
fixtures/viewer-nav.mjsLoading diff…
internal/slides/credits/assets.jsonLoading diff…
internal/slides/locales/en.tomlLoading diff…
internal/slides/presentation.goLoading diff…
internal/slides/static/{editor.32cedc10927dae66.js => editor.6f20169670d59132.js}Loading diff…
internal/slides/static/fontsgate.358bdc2e9398e6da.jsLoading diff…
internal/slides/static/fontsgate.3753849cb5b94339.jsLoading diff…
internal/slides/static/present.jsLoading diff…
internal/slides/templates/present.htmlLoading diff…
internal/slides/templates/viewer.htmlLoading diff…
internal/slides/viewer.goLoading diff…
internal/slidestest/fonts_browser_test.goLoading diff…
internal/slidestest/races_browser_test.goLoading diff…