Commit graph

16 commits

Author SHA1 Message Date
45171a95c3
zebra-spaces: stacked layout below 1100px (kill cramped 3-col on iPad/split-screen)
Bumps the stacked-layout breakpoint from 800px to 1100px. iPad
landscape (1024), desktop split-screen halves (~960), and tablet
portrait (768) now get the same vertical controls -> timeline ->
cameras stack a phone does, instead of three squeezed columns.

Also fixes a latent source-order cascade bug: the phone-only
#tiles-thumbs single-column override was placed before the default
auto-fill rule, so equal-specificity cascade let the default win.
Moved the override after the default; phones now actually get
single-column thumbs as the comment claimed.

Other 4 pages: stamp date bump 2026-06-07 -> 2026-06-08 from this
session's make stamp run.
2026-06-08 14:45:56 -04:00
caa0548113
zebra-spaces: fresh-stream wrap on mic ontrack + mute-gate mesh swap (kill fedora-chrome silence)
Fox 2026-06-07 telemetry on blanka-chrome ruled out the sink-routing
hypothesis from 467146a:

  audio via AudioContext 085b target=0.5s ctxState=running sink=default
  mesh stream swapped into worklet for 085b
  ...
  aud.recv pkt=14622 lost=1 bytes=9117575 jitter=0.0100 level=0.000 jbuf=? lp=0.1s

50 pps stereo Opus arriving on the SFU sub PC, sink routed to the
picked device, but jbuf=? (jitterBufferEmittedCount=0) + level=0 — the
native decoder consumes nothing because no MediaStreamSource is bound
to the SFU receiver's track. fxhp-phone same room same window decodes
fine (jbuf=0.49s level=0.001), so the SFU is healthy and the defect is
per-client wiring.

Two coupled defects:

(A) tracks=0 race in handleRemoteSfuTrack mic branch. Chrome can fire
ontrack with ev.streams[0] still empty at handler-time (the live track
arrives a microtask later, or MSID-supplant merges new+dead tracks).
Caching ev.streams[0] then handing it to attachSfuTrack drops the
listener into the silent <audio> fallback — telemetry: "sfu attach
b1a7 fresh=1 tracks=0" + "meter for b1a7: MediaStream has no audio
track". Screen/camera/game already wrap ev.track in a fresh
MediaStream; mic now does the same. Single track, guaranteed live,
every time.

(B) Mesh ontrack unconditionally swaps the worklet's source to the
mesh stream — even when the mesh track is still muted (no RTP). The
SFU receiver becomes orphaned (no decoder), and if the mesh track
never unmutes the listener hears silence with no automatic SFU
restore. Gate the swap on track-not-muted: swap immediately if mesh
is already flowing, otherwise wait for 'unmute'. Add a mute-watchdog
that swaps back to the cached SFU stream after MESH_MUTE_WINDOW_MS
of mesh silence — same shape as the existing
connectionState=='failed' restore path, but driven by track-level
mute instead of PC-level failure.

Hard refresh + leave/enter worked because the fresh negotiation
delivered the mesh track already unmuted, so the eager swap landed
on a live source. Now the same swap waits for live source instead of
hoping for one.

Tests:
  - handleRemoteSfuTrack: ev.streams[0] empty but ev.track live →
    fresh MediaStream wrap rescues the attach (chain built, audible
    path verified)

Ticket 0001 updated with the telemetry comparison and the new
diagnosis. Mesh-mute-watchdog has no dedicated test yet (the mesh
ontrack lives in connectToPeer which the listener test harness
doesn't extract) — pin in multi-peer-mesh.test.js next pass.
2026-06-07 11:33:57 -04:00
0ce1339f8e
zebra-spaces: prefix-match in flushSfuStreams (kill silent fedora-chrome listener)
Fox 2026-06-06: "fedora chrome is flawless besides not able to hear
any mics it was working a few days back and nothing was changed on
the system, only thing we changed was our zebra codes."

The race: on a listener joining a room with existing speakers, the
SFU sub PC ontrack can fire BEFORE the signal-server peer-joined
event populates `members`. handleRemoteSfuTrack already does prefix
resolution at line ~4640:

  let pubHex = pubHex16;
  for (const [, mm] of members){
    if (fh.startsWith(pubHex16)){ pubHex = fh; break; }
  }

When the roster is empty, the loop finds nothing, pubHex stays the
16-char streamID prefix, and sfuStreamsByPubHex.set(pubHex, stream)
caches under that short key. peer-joined arrives later,
flushSfuStreams runs to attach what was cached — but its inner match
was strict ===:

  if (mm.pubkey && hex(unb64(mm.pubkey)) === pubHex){

mm.pubkey decodes to the FULL 64-char hex; pubHex from the cache is
the 16-char prefix; === never matches; listener stays permanently
silent for every speaker who was already in the room.

Pre-cascade this defect was masked: the old guard `!remoteAudio.has(uuid)`
was always true for worklet listeners (remoteAudio is the <audio>
fallback path only), so flushSfuStreams re-attached every cached
stream on every peer-joined — the eventual second ontrack from a
later renegotiation would land with members populated, cache key
became the full pubhex, and === matched. The 2e74b92 fix replaced
the always-true guard with `!listenerAudioNodes.has(uuid)`, which
correctly skipped re-attach but also exposed the strict-equality
matcher in the cold path.

Fix: switch flushSfuStreams' inner match from `=== pubHex` to
`fh.startsWith(pubHex)`. Symmetric with handleRemoteSfuTrack's own
prefix resolution. Works for both cases:

  - cache key is full 64-char pubhex → startsWith with a full string
    requires equality, so behavior is unchanged when ontrack arrived
    after peer-joined (the common case).
  - cache key is 16-char prefix → startsWith matches the first 16
    chars of any member's full pubhex. 64 bits of prefix entropy =
    astronomical collision probability.

Pinned by 29 new assertions in test/listener-audio-attach.test.js,
extracted from the live page so they cannot drift:
  - 22 cover the attach FSM (chain reachability, dedup, in-place
    swap, jbuf race, idempotent re-attach).
  - 7 cover handleRemoteSfuTrack including the failing scenario:
    "ontrack ARRIVES BEFORE peer-joined (member roster empty) →
    cached + audible after flush" — fails pre-fix, passes post-fix.

Makefile gets test-listener-audio + adds it to test-all.
2026-06-06 14:37:18 -04:00
334ee82d6b
zebra-spaces: listener mute button doubles as audio-unlock gesture
Fox 2026-06-04, after pulling CLIENT_LOG from the proxy:

  stream for 25cc0aaf7eb0 autoplay blocked: ... — staying on live WebRTC
  autoplay blocked: ... — tap the tile to play

Firefox Android refuses .play() on every <audio> element created
after the entry-button gesture has aged out. Both the HTTP DJ stream
AND the WebRTC fallback were silently dead — the phone heard nothing.

Two-part fix:

 1. Every remoteAudio + streamAudio <audio> element is now created
    with muted=true. Muted autoplay has no gesture requirement on
    any browser — decoding starts the moment the src is set, the
    buffer fills, and audibility is gated entirely by a later
    user gesture.

 2. btn-mute is enabled for listeners (was disabled because there's
    no mic to mute) and re-purposed as the audio-unlock toggle. The
    click is the gesture. applyAudioMute() reads a per-uuid audio-
    Path map ('dj' | 'rtc') and unmutes only the canonical path for
    each peer so the WebRTC duplicate stays silenced while the DJ
    stream plays.

Also picked up while I was in here:
  - startStream onFail clears the pubHex from streamMode so the
    next auto-enrol pass retries.
  - stopStream sets audioPath='rtc' instead of poking remoteAudio
    directly.
2026-06-03 20:57:09 -04:00
3ca9042e54
zebra-spaces: boot-error logging + watchFirstFrame keyframe diagnostic
- moderation: 'boot' button onclick now .catch'es and logs server
   errors. Server now returns 'boot target not found (stale uuid?)'
   instead of silently no-op'ing when the page's member roster lagged
   the room — the moderator was clicking 'boot' and seeing nothing
   happen because their page held a stale uuid.

 - diagnostic: watchFirstFrame logs 'still black after 2500ms — no
   keyframe?' on any fresh SFU video track (screen/camera/game) whose
   decoder never unmutes. Pairs with the SFU's extended kfBurst so we
   can tell next session which path actually broke when a camera tile
   renders black.

multi-peer-mesh test harness extracts the new fn alongside
watchVideoTrackForRemoval so handleRemoteSfuTrack still runs end-to-end
in the headless sandbox.

Stamp date refresh on the other pages (no behavior change).
2026-06-03 15:51:18 -04:00
8c90379006
zebra: dark mode default on all pages + unified theme key
All five pages — chat (zebra-audio), zebra-audio, how-it-works,
host-your-own, zebra-spaces — now ship with the same dark-mode
infrastructure: pre-paint head script, shared dark CSS block, fixed
top-right theme toggle, and one localStorage key ('zebra-theme-v1')
shared across pages so the user's choice follows them.

Dark IS the default: missing pref reads as dark, only an explicit
'light' opts out. First-time visitors land in dark without a flash.

The shared CSS covers the surfaces every page has (body, links,
buttons, inputs, dots, meter, status, log, hr, footer) so each page
looks intentional in dark without per-page tuning. zebra-spaces keeps
its richer overrides for badges + latency rows + tile metas.
2026-06-01 22:18:02 -04:00
2fd2ac3546
zebra-spaces: start remote screen tiles muted + add unmute button — fixes mobile autoplay
Mobile browsers refuse to autoplay a <video> carrying an unmuted audio
track without a user gesture; the whole element stays paused, so the
video pixels never render either. The phone listener saw a black tile
even with a healthy track flowing.

Start the remote tile muted so it autoplays everywhere; expose an
'unmute audio' button in the meta bar that toggles. The button click
counts as the gesture, so audio kicks in on demand. Local preview never
offers unmute (would feed back into the publisher's own mic).
2026-06-01 20:02:03 -04:00
d9852e661e
zebra-spaces: local preview tile so publisher sees their own screen share
The SFU does not echo a publisher's stream back, so anyone sharing alone
in a room had no visual confirmation — game iframe stayed up, no tile
appeared. Render a muted local preview keyed by myKeys.pubHex on publish,
remove on unpublish. Subscribe path skips own pubHex to defend against
SFUs that do echo publishers.

Also refreshes integrity stamps on the other web pages (date drift).
2026-06-01 19:45:15 -04:00
c525c7df11
web: bump mobile body padding from 1rem to 1.25rem so the right edge has visible breathing room 2026-05-31 14:13:25 -04:00
c8a9adc423
web: every page works on mobile without horizontal overflow
- index.html, kernel.html: were missing the viewport meta entirely;
  mobile fell back to the default 980px layout and the content was
  scaled down. Add the standard 'width=device-width,initial-scale=1'
  and centre the body with margin:0 auto so the 640px max-width is
  centered instead of left-aligned on wide displays.
- host-your-own.html, how-it-works.html, zebra-audio.html, chat.html:
  add a 600px breakpoint that tightens body padding to 1rem, shrinks
  the h1 from 3rem to 2.2rem, and lets long URLs / pubkey hashes wrap
  via overflow-wrap:anywhere on body prose. .code / .diagram already
  use overflow-x:auto so internal scrolling stays bounded to the box,
  never pushes the page wider than the viewport.
- chat.html: cap the QR share box's canvas (was a fixed 320px square)
  with max-width:100% on phones, so 320px-wide handsets don't overflow.
- zebra-audio.html: the mute button had a fixed 6rem width to keep the
  'mute'/'unmute' label from shifting the row; on narrow phones that
  width forced wrapping. Drop it back to auto on small viewports.

All pages stamp+verify; the integrity footer hashes in the source
match the served files after `make stamp`.
2026-05-31 13:52:32 -04:00
1e76f62f71
zebra-spaces v0.1: multi-party voice rooms with roles, identity, vault
New page: web/zebra-spaces.html. Extends the rendezvous + WebRTC mesh
model from zebra-audio (1:1) to a room of up to ~8 speakers (host + 2
co-hosts + speakers) with listeners (deferred to v0.2 for SFU fan-out).

Identity: per-browser persistent Ed25519 keypair in localStorage,
plus a per-session UUID for in-room "whose who". Password-vault
backup/restore (PBKDF2 600k + AES-GCM, matches zebra-audio's crypto)
emits a self-contained 'zspc-id-v1|...' blob.

Roles: everyone joins as listener; mods (host + co-hosts) extend
mic-invites that listeners accept/decline; host promotes to co-host;
mods demote and boot. Co-hosts cannot remove the host. Every role
transition is signed by the acting mod's Ed25519 over a canonical
input bound to room_id + epoch, so a compromised relay cannot forge
promotions, only refuse to relay them.

Pairs with cmd/zebra-spaces-signal in proxy.unturf.com.

Nav: zebra-audio and host-your-own cross-link to spaces.
Makefile: stamp target now covers zebra-spaces.html (web/chat.html
and web/how-it-works.html stamps refreshed today as a side effect).
2026-05-31 10:54:36 -04:00
5e1c4402b2
web: host-your-own page + nav links; deploy-to-both-repos reminder
Add web/host-your-own.html and link it from the chat and how-it-works headers
and footers. make stamp now stamps it alongside the other pages. CLAUDE.md:
turn the deploy flow into an explicit push-BOTH-repos reminder (zebra-report
source + www.unturf.com served) and list host-your-own.html as a deployed page.
2026-05-29 15:17:22 -04:00
162b4b2917
web: auto-reconnect on cross-LAN drops + live mic-input switching
- chat + zebra-audio: treat ICE 'disconnected' as recoverable (grace
  before acting), auto ICE-restart on 'failed'/timeout driven by the
  offerer to avoid glare, and auto-rejoin the signaling socket if it
  drops mid-call. Superseded-pc guard ignores late events from a
  closed connection.
- zebra-audio: input-device dropdown that hot-swaps the mic via
  replaceTrack (no renegotiation, mute preserved); refreshes on
  devicechange so a plugged-in interface appears mid-call.
2026-05-28 21:29:50 -04:00
0ca6b2b31a
how-it-works: explain what 'hi' becomes (AES-GCM scramble before volume) 2026-05-28 17:58:23 -04:00
ae3e4316fb
web: stamp each zebra-report page with build date + md5/sha256
Add an integrity footer to chat.html, zebra-audio.html, and how-it-works.html
showing the build date (2026-05-28) and the page's own MD5 + SHA-256. A file
can't hold its own hash, so web/stamp.js (make stamp) computes the hashes with
the two hash fields zeroed, then writes the real values back — self-consistent
and idempotent. To verify a served page: blank the two fields and re-hash;
confirmed it reproduces the stamped value with plain sha256sum.
2026-05-28 17:50:12 -04:00
c287328bb9
web: add "how it works" write-up + link it from the chat header
Standalone blog-style page (matching chunkfive/monospace b&w UX) explaining the
whole solution: amplitude-as-data, the no-copy-paste signaling relay, the
multi-level modem, the Opus->G.711 codec fix and 440 Hz beat, the ACK/outbox
reliability layer, and the Hamming(12,8)+Gray FEC. Linked from chat.html's
header.
2026-05-28 12:50:34 -04:00