Repository navigation
fix: clear the 15-item code sweep backlog - #4
Conversation
Six items from #3. Each one is a rule this codebase states somewhere and did not apply everywhere. A rejected caller no longer leaves a room behind. Every write handler validates the name and checks the token first. It creates the room only after that. Reads were already guarded. A command that changes nothing sends no frame. Room::apply_all publishes and marks the snapshot only when the state moved. docs/architecture.md already said so. The autopilot re-checks its decision under the write lock. It reads four fields through Room::peek rather than cloning the whole room five times a second per room. It then hands the same condition to Room::apply_if. An operator who disarms inside that window wins. Ctrl-C and TERM now stop the server in order. It closes every room and lets the sockets send a 1001 close frame. It waits up to five seconds for connections. It then writes what was still inside the debounce window. Snapshot writes run on a blocking thread. A slow state directory no longer stalls the runtime that serves every socket. Every part of a room has a ceiling. A room holds 500 cues. A message takes 280 characters, a title or a cue line 120, a cue note 500. The parser refuses an import over the cue ceiling rather than cutting it in silence. Adds GET /api/auth, which answers 401 without a valid token. The console uses it to tell an expired token from a dropped network. Refs #3
Seven items from #3, all of them in the pages rather than the server. The console strips the operator token from the address bar and from browser history. `web/unlock.js` already did this after a failure. The console header links back to the room picker. Switching rooms takes one click rather than an edit to the URL. A focused button or link keeps Space and Enter. Tabbing to a rundown control and pressing Space started or paused the show, and the control never fired. The letter shortcuts still reach the transport. Deleting a cue asks first, and says when the cue is on air. Clearing a room and deleting one both asked already. The agenda signature rounds to the minute the table prints. Before a show every projected time tracks the wall clock. The table therefore rebuilt itself twice a second forever. A refused edit socket reports the token rather than reconnecting. The console says so and reopens the token form. It no longer sits on offline with no way back in. The viewer asks for the screen wake lock again whenever the tab returns. The browser drops the lock every time the document hides. A screen reader now gets the state that was CSS only. Every toggle and tone carries aria-pressed. The icon buttons carry labels. The toast and both status badges are live regions. Refs #3
The wake lock entry promised something the documented deployment cannot do. The API needs a secure context. It is absent on the plain http://<lan-ip>:8080 this server is usually reached at. The entry now says so, and says what to do instead. Also documents the state ceilings and the new /api/auth endpoint. Adds what a stop writes, and the JavaScript suites that cover the socket. Refs #3
Six findings, in the order they would bite an operator. Space goes back to the transport after a mouse click. A click leaves the button focused, so the last commit handed Space to that button. An operator who pressed Blackout and then Space toggled the screen rather than pausing the show. A click on a button now returns focus to the page. Only a control the operator tabbed to keeps Space and Enter. `detail` tells the two apart, so keyboard activation still works. Two snapshot writers no longer share one temporary file. The final flush at a stop can run beside the debounced writer. Both used `<room>.json.tmp`, so one could rename the other's file away and lose the snapshot. Each write now names its own file. A mutex orders a write against a delete. A write in flight can no longer resurrect a deleted room. The writer keeps the room it read and skips one the hub has retired. The stop sequence writes before it closes the rooms. Otherwise the writer takes a closing room for a deleted one and skips it. A serving error no longer returns early past that write. A server task that ends on its own no longer leaves the process waiting for a signal. Nothing would send one. The agenda drops the seconds in 12-hour mode. `slice(0, undefined)` kept the whole string, and the minute-rounded signature froze those seconds. The clock format now also belongs to what the table repaints on. Three smaller ones. `AuxSet` caps its label like every other line. The console fields carry `maxlength`, so the operator sees a limit rather than losing text to the server. The autopilot checks that the cue it read still follows the active one. The viewer asks for one wake lock at a time. Refs #3
|
Reviewed the first three commits and fixed six findings in Space after a mouse click. A click leaves the button focused, so the Two writers, one temporary file. The final flush at a stop can run A write in flight could resurrect a deleted room. The writer now The agenda kept the seconds in 12-hour mode. Three smaller ones. One finding I did not fix. |
Summary
Clears all 15 items in #3. Six were small and self-contained. Four were
correctness problems under load or at the edges. Two were features. The
last three were larger: the wake lock, the missing ARIA, the test gaps.
Confirmed the eleven unverified items against the code before starting.
All 15 were real.
Why
One pattern runs through most of the list, as the issue says. The
intended behavior was already written down, or already implemented one
file over. Nobody applied it everywhere.
The auth check guarded reads and not writes. The architecture doc
described the no-op broadcast this PR now implements. Presets already
capped their text while messages and cues did not. Those fixes are small
and hard to argue with, so they came first.
The rest are real gaps rather than inconsistencies. The autopilot read
state and then acted on it. Nothing stopped the server cleanly. The
socket retried a refused handshake forever. One layer of test coverage
was missing under all of it.
Small and self-contained
validates the name, checks the token, and creates the room only after
that.
room_of()is gone, andnamed()carries the comment for bothcases.
tests/routes.rsassertsroom_count()on all three writeroutes, and
tests/api.rsasserts the picker's room list stays emptyafter three 401s.
Room::apply_allpublishes and marks the snapshot only when the state moved, which is
what
docs/architecture.md:24always claimed. Client counts, roomclose and the keepalive still publish unconditionally.
with
history.replaceState, the wayweb/unlock.jsalready did aftera failure.
duplicate
id="viewerLink"inweb/unlock.htmlis nowpickerLink,and a test asserts no page repeats an id.
targetOwnsKey()gives a focused button or link Space and Enter. Theletter shortcuts still reach the transport. Anchors are in scope
because the header now has one.
the cue is on air and the stage title will blank.
Correctness under load and at the edges
through the new
Room::peek. It then hands the same condition to thenew
Room::apply_if, which re-checks it under the write lock. Anoperator who disarms or reloads inside that window wins.
agendaSignaturerounds start and end to the minute the table prints. Measured in a
browser on a pre-show room: 5 rebuilds per 2.5 s before, 0 after.
the sockets send a 1001 close frame. The server waits up to five
seconds for connections, then flushes the debounce window. Measured:
exit in 102 ms with a live edit socket. A command sent 200 ms before
the signal reached disk.
GET /api/authseparates a bad token from a dead network. The socketreports
unauthorizedand stops retrying, and the console reopens thetoken form. A viewer socket never probes, so it still retries.
Room::peekreplaces the five-per-second clone ofevery cue. Snapshot writes moved to
spawn_blocking, so a networkmounted
--state-dircannot stall the runtime serving every socket.message takes 280 characters, a title or a cue line 120, a cue note
500. Text past a limit is cut, matching what presets already did. An
import over 500 cues gets an error instead.
Larger
viewer re-requests on
visibilitychange, because the spec drops thelock whenever the document hides. It also stops hiding a missing API
behind optional chaining. I took the documentation branch of the
issue's either-or.
docs/operations.mdnow states that the API needsa secure context, and that it is absent on
http://<lan-ip>:8080. Itsays to turn off system sleep instead. A muted-video fallback is a
bigger change than this backlog wants.
aria-pressednow rides on all ten screentoggles, plus auto-advance, aux and the tones. One
pressed()helpersets it, so the class and the attribute cannot drift. The icon-only
buttons carry labels, including the cue rows the console builds at
runtime. The toast and both status badges are live regions.
web/agenda_signature.test.mjsnow feeds two consecutiveprojectAgendaoutputs through the signature rather than building rowsby hand.
web/socket.test.mjscovers reconnect, backoff doubling tothe cap, the reset on a fresh open, the refused handshake and the
viewer's exemption.
RoomSockettakes its socket, auth probe and timeras options so a test can drive it.
Testing
make lintandmake testare clean: 337 Rust tests, 102 JavaScriptassertions. New files:
tests/limits.rs,tests/markup.rs,web/keys.test.mjs,web/socket.test.mjs.Drove a real browser against a debug build for the parts no assertion
covers. The token leaves the URL. The picker link works.
aria-pressedtracks blackout. Space on a focused Load button loads that cue and
leaves the timer stopped.
The delete confirm blocks, then deletes on accept. The agenda holds
still with no cue active. The viewer asks for the wake lock again after
a release, and asks once while it holds one. No console errors on any
page.
Notes
Hubstill has no room ceiling. The item's defect was the ordering, andan open server creating rooms on demand is the product. A ceiling is a
separate decision.
Closes #3