open-standards/wai/examples/watch-together
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science b4f33410cb watch-together test: the example as a person runs it first, then a held page, held to the room's log
Review of b01681570, the example's test. It had replaced the example's own run with the hold:
Ada's play always went through take-for-gone and re-entry, never the path a present viewer's
control takes. And it passed defects the old test failed: it let either page re-enter any
number of times uncounted (only Ada's `rejoins >= 1` was read, Ben's never), a `not_present`
refusal went nowhere, and "the room refused no page's event" held while the test had Ada's
events refused. Moving app.js's statements back after `begin()` passed (Ada was held either
way; a Ben slow past 4 s just re-entered), as did a page that stopped stating, or a room whose
silence limit shrank. And it checked the play against the instant Ada first signed it for, not
the one the room carried after re-signing moved it.

Now:

1. As before, both pages enter; Ada plays and Ben pauses, each while present; both apply each
   control at its instant within a quarter second of the room and pause at one position.
2. Ben's page is held until the room's log carries his `leave`; Ada seeks back to 2 s
   meanwhile; Ben's play is signed as the hold ends, before his page can enter again. The
   test reads the room's log until Ben's play is carried after his second `join`, takes the
   instant the room carried (at least that join's `t` plus the lead, and no earlier than first
   asked), and both pages must play from the seek at it within the bound, then pause at one
   position again when Ada pauses 3 s later.
3. The room's log, read once and every record verified (`roomTest.watchLog`): exactly one
   `leave`, Ben's, after his hold began; Ada joined once, Ben twice, the second after the
   `leave`; every slot wholly within each stretch of each page's presence holds a statement of
   it (co-watch §7.3), but Ben's hold; and each page's first statement comes before the instant
   it began to follow the log, which it does only once it has its relay session. That last is
   ordering, not timing: with the statements started after `begin()` it cannot hold.
4. Each page's own counts: Ada never taken for gone and never entering again, Ben taken for
   gone once (`stats.gone`), entering again once with his play signed again; no other event of
   either refused, and no page stopped.

A wait still ends at once when a page stops and says each page's counts.

Verified on the build host, the room client and the archive built as wai-examples.yml builds
them (load 62-73): watch-together through run-examples.sh passed 5 of 5, every check held.
Falsified, each built and run the same way: statements started after `begin()` again fails the
first-statement check; a page that stops stating once it has entered again fails the slot and
`leave` checks; a room silence limit of 400 ms fails the `leave` count and the pages' counts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 08:13:11 -05:00
..
test watch-together test: the example as a person runs it first, then a held page, held to the room's log 2026-11-04 08:13:11 -05:00
.gitignore wai: the developer's path, hello, create, dev and verify, a floor build with no system library, and nine examples 2026-10-26 22:58:39 -04:00
index.html wai: the developer's path, hello, create, dev and verify, a floor build with no system library, and nine examples 2026-10-26 22:58:39 -04:00
LICENSE wai/examples: every template Apache-2.0, its LICENSE carried into the project 2026-10-27 04:52:31 -04:00
README.md wai/examples: every template Apache-2.0, its LICENSE carried into the project 2026-10-27 04:52:31 -04:00
wai.json wai: the developer's path, hello, create, dev and verify, a floor build with no system library, and nine examples 2026-10-26 22:58:39 -04:00

Watch together

What it shows. A room in which everyone watches one file in sync. The room service names the file by its content hash in the room's signed policy; each page fetches it, checks it, and keeps it at the room's position. Play, pause, seek and speed are controls each page signs; each applies at one instant on the room's clock, for everyone. Every few seconds the room's clock states how far each viewer is from the room.

Run it.

wai create my-watch --template watch-together
cd my-watch
wai dev

Open http://127.0.0.1:8080/ in two tabs, press Watch in each, then Play in one.

What you see. Both tabs play the sample tone (tone.wav, made by wai create, a pitch that steps up each second), pause together and jump together. Below the player, each page shows its own offset from the room and whether everyone is in sync.

Make it yours. Put a .webm, .mp4, .ogg, .mp3 or .wav file in the project and name it in wai.json ("watch"), with its length in milliseconds ("watch_ms") for anything but a WAV file. Or run wai dev --watch film.webm --watch-ms 90000.

With a coding assistant. Run wai setup-agent in this directory: it writes the instructions an assistant reads and connects it to WAI's tools.

License. Apache-2.0: the text is in LICENSE, and a project wai create makes from this example carries it.