Skip to content

fix: keep the founder's tempo on first join; make "Remember settings" reach the app - #517

Open
quasor wants to merge 3 commits into
mainfrom
claude/project-thread-oppi6c
Open

quasor wants to merge 3 commits into
mainfrom
claude/project-thread-oppi6c

Conversation

@quasor

@quasor quasor commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Before: whoever founds a room has their tempo reset to 120 BPM the moment the first peer joins. A founder at 95 BPM has their Link session, and their DAW, pulled to 120. Separately, unticking "Remember settings" doesn't stop WAIL saving your capture-channel selection and restoring it on the next join. The Debug tab also shows an "Interval offset D" slider that does nothing.

After: the room keeps the founder's tempo. The Remember toggle controls whether capture selections are saved. The dead slider is gone.

Founder tempo. #502 inserted case "UpdateStreamsError": between peers.SeedLastSeen() and the founding-room block in session.go. As a result, the tempo declaration and IntervalConfig broadcast ran only on a rejected stream update, never on joining an empty room. With no declared tempo, the relay used its 120 BPM default when the first peer joined, and both peers adopted it. This is in v5.0.0 and every beta since v4.2.0-beta.0. I reproduced it against a local relay with two headless peers at -bpm 95: the relay logged config set: tempo=120.0 and both peers logged Adopting room tempo 120.0 BPM.

Remember settings. main.js calls invoke('set_remember_enabled'), but wails-adapter.js never mapped that command (since #389). The adapter threw "Unknown command", .catch(() => {}) swallowed the error, and App.rememberEnabled stayed at its default of true.

How

  • session.go:
    • Moved the founding block back under PeerListReceived.
    • It now declares currentBPM rather than the join-time bpm, so reconnecting into a room that emptied meanwhile doesn't revert a tempo change made during the session.
    • New TestFounderDeclaresTempoAndIntervalConfig runs a real session against an in-process fake relay. It asserts the founder broadcasts TempoDeclare at its own BPM plus its IntervalConfig, and it fails on main.
  • Frontend:
    • Mapped set_remember_enabled in wails-adapter.js.
    • Removed the retired offset slider (ADR-0009) and its unmapped set_interval_offset call.
    • New TestFrontendInvokesMapToAppMethods checks three things: every command main.js invokes is mapped, every mapped App method exists, and each positional arg list matches the method's arity. A future gap then fails CI instead of failing silently.
  • scripts/tier2-e2e.sh:
    • The default BPM goes from 240 to 120.
    • The script always asked for 240, but because of this bug every test room actually ran at the relay's 120. So the ADR-0009 placement check (feat!: sender-relative rounds — the client side of ADR-0009 #512) had only ever been validated on 8s intervals.
    • With the founder's tempo honoured, 240 BPM really means 4s intervals. That leaves the once-a-second probe about two usable seconds per boundary, so the verdict flaked: 1 pass in 4 runs. The single reported "skip" was a vote-binning artifact; the probe heard consecutive tone blocks.
    • At 120 BPM: 5 passes in 5 runs.

Not in this PR. Peer log lines never reach the session: signaling.go emits PeerLogBroadcast, but session.go matches LogBroadcast. I left that unfixed on purpose. The relay forwards every log line to every other peer, and the fold-in uses log.Printf, which feeds WsLogWriter. So with two log-sharing peers, a plain rename would bounce each line back and forth between them indefinitely. The fix needs to fold peer lines in without re-sharing them, and that deserves its own change.

Checks run locally (Linux)

  • go test -tags nolibopusfile ./...: pass
  • go test -tags linkstub,nolibopusfile ./...: pass
  • go build -tags linkstub,nolibopusfile -o /dev/null .: ok
  • ./scripts/tier2-e2e.sh (step mode): PASS, 9 checks, 0 failures
  • ./scripts/loopback-e2e.sh: PASS

Generated by Claude Code

PR #502 inserted the UpdateStreamsError case between PeerListReceived's
SeedLastSeen and its founding-room block, so the block (log the join,
declare the founder's tempo, broadcast its interval config) ran only on a
rejected stream update and never on joining an empty room. The relay then
had no tempo for the room, fell back to 120 BPM when the first peer joined,
and both peers adopted it: a founder at 95 BPM had their Link session (and
DAW) reset to 120 the moment someone joined. In v5.0.0 and every beta since.

Move the block back under PeerListReceived, declaring currentBPM rather
than the join-time bpm so a reconnect into a room that emptied meanwhile
doesn't revert a tempo change made during the session.

TestFounderDeclaresTempoAndIntervalConfig runs a session against an
in-process fake relay and asserts the founder broadcasts TempoDeclare at
its own BPM plus its IntervalConfig; it fails on the old code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0128WmRHbSuEccdNYHw3WXq5
The script asked for 240 BPM, but the founder-tempo bug reset every test
room to the relay's 120 BPM default, so the ADR-0009 placement check
(#512) has only ever run on 8s intervals. With the founder's tempo now
honoured the room really runs at 240, and 4s intervals leave the vote
about two clean probe seconds per boundary: boundaries abstain and the
verdict flakes (1 of 4 runs passed; the one reported "skip" was a binning
artifact, the probe heard consecutive blocks). At 120 BPM it passed 5 of 5.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0128WmRHbSuEccdNYHw3WXq5
main.js pushes the checkbox to the backend with
invoke('set_remember_enabled'), but wails-adapter.js never mapped that
command (since #389). The adapter threw "Unknown command", the call site
swallowed it, and App.rememberEnabled stayed at its default true: with
"Remember settings" unticked, the capture-channel selection was still
saved to capture_enabled.json and restored on the next join.

Map the command, and remove the Debug tab's "Interval offset D" slider,
which promised the retired fixed offset (ADR-0009) and called an equally
unmapped set_interval_offset.

TestFrontendInvokesMapToAppMethods pins the contract so the next gap
fails CI instead of failing silently: every command main.js invokes is
mapped, every mapped App method exists, and each positional arg list
matches the method's arity.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0128WmRHbSuEccdNYHw3WXq5
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.

2 participants