Skip to content

feat(docs): the Settings gear and sound (#352) - #354

Merged
craig-o-curtis merged 25 commits into
mainfrom
352-replace-the-theme-toggle-with-a-settings-gear
Nov 19, 2026
Merged

craig-o-curtis merged 25 commits into
mainfrom
352-replace-the-theme-toggle-with-a-settings-gear

Conversation

@craig-o-curtis

@craig-o-curtis craig-o-curtis commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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:

    • a "Dark theme" switch, drawn as a leaf that turns over;
    • a mute button and an 11-notch volume fader drawn as a growing stem;
    • on the landing only, an "Aura" switch with a choice of track.

    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:sound key 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".

    • Volume notch: a leaf brush.
    • The landing's leaves: one rustle with dry ticks as leaves land. It plays for the opening and for each change between leaf, git graph and "worktree", driven by the particles' own timings, and it stops when the last leaf lands. Dragging through the leaves gives one soft, continuous rustle.
    • The aura: Forest air or Leaves overhead, off by default, landing only.
    • The Dox chat: GMT's seven voices, unchanged.
  • Audio and the browser. No browser lets a page start audio before a gesture on it.

    • A link from any page of northguild.dev (its root, /gmt, other /worktree pages) plays at once.
    • A refresh, back or forward, a typed address or a bookmark waits for the first click, tap or key, which starts everything, including what is left of the opening.
    • None of these logs Chrome's autoplay warning.

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)

# Phase Commits
1 Theme rule d78ee42
2 Settings gear and theme switch faf7cdf, c216d4b
3 Shared sound settings 8b8f222
4 Engine (GMT's, cut down) f28d2ea
5 Volume control 7692bb6
6 Leaf sounds a3c28d3
7 Aura 94d90d9, e0cf91c
8 Dox chat voices ec9253f, 497df82
9 Opening heard, as a change e57c8d1, 4505385
10 Sound starts at the first gesture 7f4cda9, abbc8f8
11 No autoplay warning on a refresh; a link from any northguild.dev page plays 9dad8f9

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

  • Gate 1 on every phase: lint, typecheck (root and docs), build, docs:build, worker:bundle-check, docs:audit-dist (28 pages), and test-marker checks. Final run: pnpm test 3826 passed, pnpm docs:test 1610 passed.
  • New audit-dist rules:
    • the header order and the single Settings button;
    • the entrance order, Dox < GitHub < Discord < gear;
    • the volume and aura controls' names;
    • no page loads the sound engine up front.
  • Gate 2: an independent review of every phase. Phases 1, 2, 7, 8, 9 and 10 each took one loopback; phase 11 was reworked twice on browser evidence before its review.
  • In Chromium (1440 px, with the browser's autoplay rule modelled):
    • The changes between pictures drop no frames: p99 16.8 ms over 30 s. flight() costs a median 1.8 ms per stage.
    • Arriving by a link: the opening cue fires at 161 ms and plays.
    • After a refresh: the page is silent until the first click, and then 84 sources start (aura, the rest of the opening, the next change).
    • Against a stub northguild.dev root on the same origin, with sound on: a link from it makes the audio context at load. A refresh (with or without a click before it), a second refresh, and back make none. No step logs the autoplay warning.
  • In WebKit (Playwright, Safari's engine), arriving by a link from a stub northguild.dev page with sound on: the context is made suspended (WebKit carries no click across a navigation), the opening's cue is remembered, and the first click about 0.8 s in turns the context running, joins the rest of the opening and plays everything after it (82 sources over 12 s, the next change at 9.5 s). That is On Safari, the landing's opening leaf sound is lost even on an in-site arrival #353's case; before phase 10 that click started nothing for the rest of the visit.
  • By ear: the owner listened in Safari and the sounds work. The owner also listened on the dev server. They hear the opening when arriving by the "worktree" title, and the levels stand as picked.

Not verified

  • Frame time of the opening: the first 4 s of a page start (WebGL start-up plus the opening's flight curve) showed 33-50 ms frames. That cost was not split between start-up and the curve.

No release note: docs/** owes none (context/release.md).

…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).
@craig-o-curtis
craig-o-curtis enabled auto-merge (squash) November 19, 2026 14:20
…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 baldurpan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Phones lose the theme control (and get no sound control). This is the one I'd hold the merge for.
  2. context/verify.md still describes the old audit rules. The file isn't in the diff, so the thread is on audit-dist.mjs.
  3. flight() builds curve and panCurve, which nothing plays. It does this for every visitor, muted ones included, and docs/README.md describes a swell that follows them.
    4–7. Nits: a fader race in engine.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.

Comment thread docs/src/components/Header.astro Resolved
Comment thread docs/scripts/audit-dist.mjs Resolved
Comment thread docs/src/hero/flight.ts Resolved
Comment thread docs/src/lib/sound/engine.ts Resolved
Comment thread docs/src/lib/sound/engine.ts Resolved
Comment thread docs/README.md Resolved
- 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.

@baldurpan baldurpan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@craig-o-curtis
craig-o-curtis merged commit d4d4387 into main Nov 19, 2026
1 check passed
@craig-o-curtis
craig-o-curtis deleted the 352-replace-the-theme-toggle-with-a-settings-gear branch November 19, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Safari, the landing's opening leaf sound is lost even on an in-site arrival Settings gear and sound

2 participants