Repository navigation
feat(docs): the Settings gear and sound (#352) - #354
Conversation
…se 1) Ports GMT's lib/theme.ts (d6031ecd) as docs/src/lib/theme.ts and points the header toggle at it: a press shows the opposite of the theme on screen, and starlight-theme holds a theme only while it differs from the system's. Before, a press with a saved theme equal to the system's removed the key and left the screen unchanged. theme-toggle.ts and its test are gone; their cases live in theme.test.ts. The README's Theme paragraph says the new rule. Commits the settings-gear sound audition (prototypes/settings-gear/), the source of the plan's voice numbers, unchanged. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1319 passed, markers clean. Gate 2: reviewer PASS WITH NOTES after one loopback (the click flipped storage, not the screen); notes in context/notes.md.
The header's sun/moon toggle becomes GMT's gear (its exact SVG), last in the right group after Dox, GitHub and Discord, opening a native popover with one "Dark theme" switch drawn as the Turning leaf (D3) and wired to theme.ts. No copy in the mobile menu; ThemeSelect.astro and its override are gone, and the provider keeps its inline first-paint rule. The landing entrance follows D16: title, search and Dox fade in, every chip starts grey, then Dox, GitHub, Discord and the gear are painted in that order, with an audit rule over the built CSS. Audit, contrast, web-vitals, README and stack.md updated. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1356 passed, markers clean. Gate 2 deferred to the end of the run at the owner's request.
…phase 3) Ports GMT's lib/sound/settings.ts (d6031ecd): the reader's level and mute in dox:sound, shared with GMT and northguild.dev, failing closed to muted at level 5. This site writes level and muted only and carries the stored aura and track through untouched (D5). Its own aura lives in worktree:aura, off with Forest air by default (D6). ThemeProvider sets data-sound on <html> before first paint by the same rule, held equal to readSound() by a test. Nothing plays yet. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1404 passed, markers clean. Gate 2 deferred to the end of the run at the owner's request.
Ports kit, engine, cue and loops from GMT's lib/sound (d6031ecd) with D7's cuts: no press hooks, link hold, panel, list, scroll, entrance or appear cues. The kit's noise buffer is 3 s (D8). cue.ts loads on every page from Head.astro; the engine is a separate chunk reached only by import(), once a reader has unmuted, and audit-dist now fails a page that names it. No AudioContext while muted or before a gesture; master gain level/11 x 0.6 through the ceiling. voices.ts is empty: nothing sounds yet. stack.md names lib/sound/. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1459 passed, markers clean. Gate 2 deferred to the end of the run at the owner's request.
Below the theme switch, the gear's panel gets a silent mute button and an 11-notch "Volume" range drawn as the Growing stem (D9). Each change of value plays one Leaf brush notch at the new level; moving it while muted unmutes there; nothing plays on mount or on another tab's change. Ported from GMT's control.ts without its press cue, aura or gmt-range. The stem's rail is --gmt-ice-dim at 70% (the board's 38% falls under 3:1 against the panel). audit-dist names the range and the button; theme-contrast holds the speaker, stem and rail at 3:1. README gains a Sound section. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), docs:test 1487 passed, markers clean. pnpm test first timed out 3 spawned-CLI tests in src/agent-mode.test.ts under load (no file outside docs/ changed); re-run 23/23 alone and 3826/3826 in full. Gate 2 deferred to the end of the run at the owner's request.
Each enter() in particles.ts computes flight curves from the leaves' own delays and durations (hero/flight.ts: share in flight and mean x every 50 ms, each leaf weighted sin(pi p), every 3rd leaf sampled; about 1.4 ms for 9,200 leaves in Node) and cues the opening gust or each change with them. Voices, ported from the audition board unchanged, live in lib/sound/leaves.ts, a chunk the engine imports only where [data-hero-art] exists: Soft canopy for the gust, Sweep and grains for each change, nothing on a picture forming, every one silent at its last landing (D11). The pointer feeds one continuous Soft rustle for a drag (D12). cue.ts gains the flight and rustle events and the "loading" cue name Phase 8 uses. README and stack.md describe the leaves' sounds. Gate 1 (with Phase 8 in the tree): check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1544 passed, markers clean. No browser frame-time measurement yet. Gate 2 deferred to the end of the run at the owner's request.
Ports GMT's Dox voices verbatim (voices.ts at d6031ecd): Data blip under typing in the composer (lib/sound/typing.ts; never Enter, a password field, a chord, a repeat or a composition), Sonar launch on send, the Sonar idle loop until the first words, a Morse beep per streamed chunk, the Ice bell on a completed answer only, the Low double buzz on a failure, and Servo spin-up on "Try again" (D13, the owner's choice). Wired in DoxChat.tsx from isStreaming, the answer's length and the warning; DoxChat.sound.test.tsx pins each rule. README's Sound section describes them. Gate 1 (with Phase 6 in the tree): check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1544 passed, markers clean. Gate 2 deferred to the end of the run at the owner's request.
…#352 phase 2, review) Gate 2 loopback 1 for phase 2: the module comment still said the header's toggle changes the theme. Comment only. Gate 1 passed on the tree (the one failing docs test is phase 7's, in progress).
…e 8, review) Gate 2 loopback 1 for phase 8: watchTyping listened to every text field on /dox, so the header's search box blipped too. It now takes the composer and ignores every other field; a new test types in a text field outside the chat and hears nothing (red before the fix). Gate 1 passed on the tree (the one failing docs test is phase 7's, in progress).
…ase 7) On the landing alone (HeroLeaves sets data-aura), the gear's panel shows an "Aura" switch, off by default, and while it is on an "Aura track" pair: Forest air (the default) and Leaves overhead, the audition board's BEDS A and B. The choice is worktree:aura; dox:sound's aura and track are never touched (D5, D6). lib/sound/aura.ts is a chunk the engine imports only with data-aura, unmuted and the aura on: its own bus 12 dB under the cues, a 2 s fade in, a 1.5 s crossfade between tracks, stopped on switch-off, mute, hide and pagehide. audit-dist holds the controls' names and the landing-only mark. README's Sound section describes it. context/notes.md records the review notes so far. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1585 passed after loopback 1 (settings-control.test.ts still said the panel held nothing past the volume row), markers clean.
…ase 7, review) Gate 2 loopback 1 for phase 7: README said the aura fades out over 0.6 s when the reader mutes; engine.ts stops it at once then (a fade would finish after the context resumes and blip). Tracks are 'ported with their numbers unchanged' (the board's own envelope gave way to the bus). Gate 1 passed on the tree with phase 9.
The owner heard the changes but never the leaves gathering on load. The gust was cued as the particles started, before the engine had loaded the leaves' voices, and a flight cue before the chunk was dropped. cue.ts now remembers the latest stage; once the engine and leaves.ts are ready while its leaves are still in flight, it joins from its offset (only the grains still to come, silent at the last landing), and plays nothing once they have landed. The opening plays the changes' Sweep and grains, as the owner asked; Soft canopy is gone. README says so, and that no sound can start before a gesture or an in-site arrival. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1588 passed, markers clean. In Chromium, arriving by a link with sound on: the gust cue fires at 161 ms, the sweep starts at once and 48 leaf ticks land between 1.8 and 3.0 s.
… phase 9, review) Gate 2 loopback 1 for phase 9: cue.ts's header still said the file reads only the audio clock and that a cue before the engine is dropped; cueFlight now stamps its stage with performance.now() and the engine joins it from its offset. Comments only; lint passed.
…phase 10) On a refresh or a direct visit the browser keeps a context made without a gesture suspended. When the reader's first press resumed it, cue.ts handed it to the engine again and attach() returned early for the same context, so the aura and the remembered leaves stage were never taken up (#353 on Safari has the same cause). cue.ts now tells the engine when the context turns running, and attach() with that running context syncs the aura and joins the stage still in flight; the aura no longer schedules onto a suspended context. No sound before a gesture on such a page: that is the browser's rule. README says so. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1595 passed, markers clean. A Chromium probe of the built site with the autoplay rule modelled (suspended without activation, resume only inside a gesture): refresh with sound and aura on, silent; one click resumes it 70 ms later, the gesture listeners go, and 84 sources start (aura, the rest of the opening, the next change at 9.3 s).
…352 phase 10, review) Gate 2 loopback 1 for phase 10: no test failed if cue.ts's onstatechange stopped calling attach(), the line that makes a late resume work in real browsers (the fake resumed synchronously). cue.test and engine.test now let the context run after a refused press has returned, as WebKit and Chromium do; both go red with that call deleted. docs:test 1597 passed, lint and markers clean.
The sound audition board moves from prototypes/settings-gear/ to context/reference/settings-gear/: the shipped voices cite it as the source of their numbers, as northguild.dev keeps context/reference/huginn-sound-audition.html. Its NOTES.md, absorbed by the plan in #352, goes. Every citation is repointed. context/notes.md, the branch's gate notes, is deleted as /feature-close does.
…ld.dev page plays (#352 phase 11) The owner saw Chrome's "The AudioContext was not allowed to start" on a refresh. The arrival rule made a context at load on a refresh, and Chrome carries a click across a link navigation but never across a refresh. cue.ts now makes the context at load only on an arrival by a link: navigation.activation.navigationType "push" or "replace" from a page of this origin, so northguild.dev's root, /gmt and other /worktree pages play at once (the owner's requirement). A refresh, back or forward, or no Navigation API waits for the first click, tap or key, with no warning. README and the cue.ts header say so. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1610 passed, markers clean. Chromium, built site, stub northguild.dev root on the same origin, sound on: contexts made at load were 1 for a link from "/", 0 for a bare refresh, 0 for a refresh after a click, 0 for a second refresh, 1 for a link to a docs page, 0 for back; no autoplay warning at any step. Gate 2: PASS WITH NOTES (header and README wording fixed here).
…ers (#352) CI run 44541962833 failed DoxChat.sound.test.tsx:211: findByText resolved on the warning's commit before the effect that cues the Low double buzz and stops the thinking loop had run. Both are now awaited with waitFor, as the file's other effect-driven checks are. No code change. docs:test 1610 passed; the file 15/15 three runs in a row.
baldurpan
left a comment
There was a problem hiding this comment.
A big, carefully built change, and the tests are thorough (236 pass locally in src/lib/sound, theme and settings-control; CI is green). Seven threads inline. In order of weight:
- Phones lose the theme control (and get no sound control). This is the one I'd hold the merge for.
context/verify.mdstill describes the old audit rules. The file isn't in the diff, so the thread is onaudit-dist.mjs.flight()buildscurveandpanCurve, which nothing plays. It does this for every visitor, muted ones included, anddocs/README.mddescribes a swell that follows them.
4–7. Nits: a fader race inengine.ts, the thinking pings lost after a mute and unmute, the starting ARIA states in the panel markup, and one sentence in the README that contradicts another.
- The gear shows at every width: the right group is no longer hidden below 50rem, and below it only the gear shows in the bar (the other chips stay in the mobile menu). audit-dist fails a gear inside an element hidden below md. - context/verify.md describes the audit as it now is. - flight() returns only the stage's length and its landing grains; the unused curve and panCurve and their sampling are gone, and nothing is computed while sound is muted. README and leaves.ts say what the voice really does. - The fader's unmute ramp is cancelled and held before each new level, so a fast drag from muted ends at the last level, not the first notch. - A loop asked for and not stopped (the thinking pings) comes back after a mute and an unmute. - The panel's starting states are true before the module runs: Mute ships pressed, and an inline script sets it and the Dark theme switch from html[data-sound] and html[data-theme]. - README and stack.md name the presses that sound: Send and "Try again". Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1624 passed, markers clean. Chromium against astro preview: the gear is visible and opens its panel inside the viewport at 320, 375 and 1440px.
…left (#352 phase 12, review) Gate 2 loopback 1 for phase 12: the muted skip in particles.ts had no test. soundFor() now takes whether sound is on and returns nothing while muted; particles.ts passes html[data-sound] === "on", and flight.test.ts pins it (red first). Comments and docs the review found untrue after 7965fba are fixed: the README's curve rule, the rustle comment, the phone layout in astro.config.mjs and audit-dist.mjs, the panel's viewport note, and the panel's no-script defaults; two test-hygiene nits as well. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1625 passed, markers clean.
…eview) The re-review's one note: soundFor()'s doc comment listed the stages that make no sound but not the new muted condition. Comment only; lint passed.
…phase 13) The owner asked for every nit. Tests that could assert nothing now can fail (the leaves' tail, the chat's unmount, the muted cue); rules with no test have one (the pointer rustle's 0.5 s silence via a pure rustleStep, HIDE_TAIL_MS, another tab's localStorage.clear(), a muted or cross-origin link arrival, no bell after a mid-answer error or a stall, the thinking ping's values). The engine chunk failing to load is retried on the next gesture instead of never. Thinking pings now start when the context runs even after an unmute from another tab or a wait that began before the engine existed. audit-dist pins the CSS that leaves only the gear on a phone and the panel's starting-state script; theme-contrast measures the switches' focus ring; the fader's ring shows on keyboard focus only; tests query the panel by role; stale comments and the README's typed-address claim are corrected. Gate 1: check, typecheck (root, docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), test 3826 passed, docs:test 1651 passed, markers clean.
…t checks (#352 phase 13, review) The phase 13 review's notes: cue.ts's retry handler is now the import's rejection handler, so a throw from createEngine() or attach() can no longer build a second engine on the next press, and its test rejects the import itself (red with the handler emptied). The muted-cue test that could not fail is removed; engine.test's muted case covers it. audit-dist's chip-hiding check counts only a rule whose subject is a direct child of the group, and flags the gear only as the rule's subject, with tests for the false positives. The focus-ring pair cites WCAG 2.2 SC 1.4.11 alone.
#352, Baldur's review) Baldur on #354 (SettingsControl.astro:61): with script blocked, ThemeProvider sets no data-theme and the page renders from the dark tokens on :root, so the switch must ship checked; dropping `checked` in 7965fba made a screen reader hear "Dark theme, off" on a dark page, and phase 13 then pinned that. The switch ships checked again, the inline script still unchecks it for a light reader, and the test pins `checked` (red before). His aside on flight.ts:104: the pointer rustle still dispatched an event on every frame for muted visitors. rustleStep() takes whether sound is on and sends nothing while muted, letting go of one still sounding; particles.ts passes html[data-sound] === "on". Tests red first.
…-toggle-with-a-settings-gear
baldurpan
left a comment
There was a problem hiding this comment.
Approving at 03e671c. All seven threads are settled: the gear at every width, verify.md matching the audit, flight() down to what plays, the gain hold, the wanted loops, the Dark theme switch shipping checked, and the README exception. The two follow-ups after my last read also hold: rustleStep() sends nothing while muted and lets a sounding rustle go once, and the wanted set in cue.ts restarts loops whenever the context turns running and at attach. docs:test, docs:build and docs:audit-dist pass at this head, and CI is green. Nice work.
The header's sun/moon toggle becomes GMT's Settings gear, and the docs site gets sound for the first time. Sound is quiet, starts muted, and is shared with GMT and northguild.dev. The plan, its ledger and every decision are in #352.
Closes #352
Closes #353 (the Safari opening: fixed in phase 10, pinned by a test, confirmed in WebKit, and heard in Safari by the owner)
What changes for a reader
The gear. GMT's gear, exactly, last in the header after Dox, GitHub and Discord. It opens a panel with:
The mobile menu's copy of the theme toggle is gone.
The theme rule is GMT's. Every press flips what is on screen, and a theme is saved only while it differs from the system's. This fixes the old toggle, which sometimes changed nothing.
The landing header's entrance. "/ worktree", search and Dox fade in. Every chip starts grey, then Dox, GitHub, Discord and the gear are painted green in that order. Before this, the Dox link was left out of both passes.
Sound is opt-in. Everyone starts muted. The choice is the
dox:soundkey shared with GMT and northguild.dev. This site writes only the level and the mute, and never GMT's aura or track. No press makes a sound, except Dox's send and "Try again".Audio and the browser. No browser lets a page start audio before a gesture on it.
/gmt, other/worktreepages) plays at once.Every voice was picked in an audition. The board is kept at
context/reference/settings-gear/sound-audition.html, as northguild.dev keeps its Huginn board.Phases (each its own commit, each through both gates)
The second commit on a row is that phase's fix after review. The last commit, 752dde7, moves the audition board to
context/reference/and deletes the branch's gate notes.Verification
docs:build,worker:bundle-check,docs:audit-dist(28 pages), and test-marker checks. Final run:pnpm test3826 passed,pnpm docs:test1610 passed.audit-distrules:flight()costs a median 1.8 ms per stage.Not verified
No release note:
docs/**owes none (context/release.md).