The web UI
The web UI is one page that runs in three modes: live against the real pipeline, replay of a recorded run from a local server, and static in the browser with no server at all.
Three modes, one page#
The web UI is one page, ui/swarms.html: vanilla JavaScript, no framework, no build step and no request to any other site. Its two fonts are served by swarmlabre serve or copied next to the static demo. The page asks GET api/mode which mode it is in and sets body[data-mode]; the style sheet hides New run, Delete, Export clip, Pause, Stop and the hint forms outside live mode.
| Mode | Started by | What answers the page's api calls | What the page offers |
|---|---|---|---|
| live | swarmlabre serve | the real pipeline: Docker and a model | everything: the launch sheet, the Live tab, the report, delete, and a clip export when ffmpeg is on the PATH |
| replay | serve --replay RUN | a recorded run played through a virtual clock: no model, no Docker | the same views over the recording, plus the replay controls: speed, Pause, Restart and Skip to end |
| static | tools/build-demo.py | a script inside the page that answers the calls from the recording embedded in it | the same as replay; nothing is sent anywhere |
Live#
$ python3 -m swarmlabre serveLive mode needs Docker, the two images and a model, the same as Analyse a file. The launch sheet takes a sample, the roles, the marking and a brief, and shows the plan before the run starts: the time, the memory and the model. It names the reason when a run cannot start. These are two of the reasons it gives:
No model is configured. Set [model] in swarmlabre.toml. Choose a sample.
Replay#
$ python3 -m swarmlabre serve --replay demo/sfaef16e6 --speed 8--replay takes a sealed run folder or an exported bundle. --speed is real or a number: 8 plays the run eight times faster than it happened. --paused starts the clock stopped. The command needs no model and no Docker. It refuses a recording that does not replay byte for byte, the check swarmlabre replay makes.
The clock#
In replay and static mode every elapsed time and age on the page comes from the recorded clock and never from the browser's, so "running for 14 s" matches what was recorded at any speed. GET api/replay returns the clock and POST api/replay sets it: speed from 0.1 to 10000, paused, restart, end to skip to the end, and at to seek, in seconds from the start.
Static#
$ python3 tools/build-demo.py demo/sfaef16e6 --out site/demoThe command writes a folder that can be hosted anywhere: index.html with the recording embedded in it, the two fonts with their licence and build.json, which lists the SHA-256 of each file. The page wraps fetch and answers every api/* call from the embedded recording, so it loads with the network blocked. The build is deterministic and, like serve --replay, refuses a recording that does not replay byte for byte. The demo on the one-pager is this build.
The player behind serve --replay and the shim inside the static page are the same fold over the recorded events, written twice, in Python and in JavaScript. A test runs the shim in node and compares both at every cursor of the recorded runs.
What a recording does not hold#
A sealed run keeps the board's inputs, the events, the layout, the outputs and the model exchanges. A bundle keeps less, so replay and the static demo answer "not recorded" for these:
- what the agents were thinking: the list of thoughts is empty;
- the per-task transcripts and tool-call lists: the agent drawer shows the task rows, the goals and the final answers only;
- the model's request timings and slot statistics;
- the memory peaks while the run was going: zero until the run ends;
- a finding's manifest lines, which are the calls it cites: empty.
A replayed or static view is a view of a recording and adds no evidence. The byte-for-byte promise belongs to swarmlabre replay, described in Reproducibility.
The server and the token#
swarmlabre serve listens on 127.0.0.1, port 8810, so only this machine reaches it. --host, --port and [serve] in the configuration change that. A host that is not loopback prints a warning, because the token is then the only protection and the traffic is not encrypted. There are no user accounts and no HTTPS, and the page is meant for one person on one machine.
Every api/* call needs Authorization: Bearer TOKEN. The token is created on first use and kept in the state folder, in a file only the owner can read. serve prints an address that ends in #token= and the token; open that address. The page moves the token into sessionStorage and removes it from the address bar. A call without it gets 401, "Bearer token needed.". When the server is bound to loopback, a request whose Host header does not name loopback gets 421, "Unexpected Host header.", which stops a web page from reaching it through DNS rebinding.
JSON bodies are capped at 1 MiB. The two raw upload routes, POST swarm/stage and POST swarm/<run>/clip/frame, are routed before the JSON parse and keep their own caps. Text over 1400 bytes is gzipped. The page is sent with default-src 'none', connect-src 'self' and frame-ancestors 'none', among other directives.
Changing the page#
Page rules#
- One global rule that hides every element with the
hiddenattribute, and one document-level Escape handler that closes the top layer: the modal, then the inspect drawer, then the launch sheet. - Anything the polling repaints must not replace its DOM when nothing changed. It keeps a signature in
dataset.sig, and nothing time-varying goes into a compared signature. - No
backdrop-filterand no animatedbox-shadow. Motion marks a state change, andprefers-reduced-motionis respected. - Inputs are 16 px, touch targets are 44 px, and safe-area insets are used. Copy is in sentence case, memory is in GiB and file sizes are in MB.
- Anything an agent, a sample, a tool or a recording produced is untrusted. It is set with
textContentoresc()and nothing else, and values that look like network indicators are shown defanged. - Colour marks the evidence level: mint is byte-checked, blue is call-cited and dashed is claimed. The role colours appear only on the map.
Checks#
| Script | What it proves |
|---|---|
tests/test_shim.py | the in-page shim and the player answer identically at hundreds of cursors |
tests/test_demo_build.py | the static build is deterministic, fetches nothing and refuses a recording that does not replay |
tests/ui/parity.py [BUNDLE] | text parity at 1280 and 500 px in live, replay and static: every finding on the Findings tab equals the API's, and the cards of report.html equal the page's verified and disputed findings, both ways |
tests/ui/tour.py [BUNDLE] | every tab, the map and the graph, the hex peek, the three inspect drawers, the replay controls, every download and the history picker, in replay and in static with the network blocked, with no page error |
tests/ui/live.py | live mode with real containers and the mock model: the launch sheet, the upload, a run to done, the same parity checks and the clip export |
Pass the committed recording to run the first two UI scripts on it: python3 tests/ui/parity.py demo/sfaef16e6. The scripts drive headless Firefox through tests/ui/wd.py, a small WebDriver client in the standard library. They need geckodriver and Firefox. A snap Firefox can only use folders under the home directory, so the scripts keep their profiles and screenshots in ~/swarmlabre-uitmp and delete them afterwards.