Skip to content

fix: restore local volume on unmute - #259

Closed
c436zhan wants to merge 1 commit into
benders:mainfrom
c436zhan:fix/issue-207-volume-restore
Closed

fix: restore local volume on unmute#259
c436zhan wants to merge 1 commit into
benders:mainfrom
c436zhan:fix/issue-207-volume-restore

Conversation

@c436zhan

Copy link
Copy Markdown

Summary

Restore the local player's previous non-zero volume when the speaker button unmutes from zero, instead of jumping to the hardcoded 0.8 value.

Root cause

The local volume button used setVolume(volume > 0 ? 0 : 0.8), so any unmute from zero ignored the user's previous slider position.

Changes

  • Track the last non-zero local volume while PlayerBar is mounted.
  • Fall back to 0.5 when unmuting with no previous non-zero value.
  • Add regression coverage for both previous-volume restore and no-history fallback.

Testing

  • corepack pnpm --filter frontend test -- PlayerBar.test.tsx (fails before the fix with 0.8, passes after: 22 tests / 123 frontend collected tests passed)
  • corepack pnpm --filter frontend typecheck (pass)
  • corepack pnpm --filter frontend lint:boundary (pass)
  • corepack pnpm --filter frontend lint (pass)
  • corepack pnpm --filter frontend test (pass: 18 files / 123 tests)
  • git diff --check (pass)

Note: the root pnpm verify script cannot run directly in this environment because nested scripts call a non-executable pnpm shim, so I ran the equivalent commands through corepack pnpm. The unchanged hub unit suite was also checked; test/admin-routes.test.ts consistently times out in admin — sync > POST /api/admin/hub/sync → returns 200 with local + peers result shape, unrelated to this frontend-only volume change.

Fixes #207

@c436zhan
c436zhan marked this pull request as ready for review July 13, 2026 20:44
benders pushed a commit that referenced this pull request Jul 13, 2026
#207)

Component-level tests that drive the actual Mute/Unmute buttons: local
restore + halfway fallback, and cast mute/unmute pushing to the Sonos
device. Test-style credit to PR #259.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SwwPcrohddTUN7kmQVedQC
@benders

benders commented Jul 13, 2026

Copy link
Copy Markdown
Owner

FROM @claude:

Thank you for this fix, @c436zhan — the root-cause diagnosis was spot on, and your component-level tests that drive the real Mute/Unmute buttons were the nicest test approach of the two competing PRs; we ported that style into the merged branch (4b5c706) with credit to this PR.

Closing as a duplicate of #258, which was merged for issue #207. The deciding differences: the volume slider is square-law (position = sqrt(volume)), so the 0.5 raw fallback here renders at ~71% of the slider rather than halfway (the merged fix uses raw 0.25 = 50% position); #258 also extends remember/restore to the Sonos cast speaker button, and tracking every slider change in a ref meant a drag-to-zero left a near-silent last sample (e.g. 0.02) as the restore level.

@benders benders closed this Jul 13, 2026
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.

Clicking volume "speaker" icon when volume is at zero should set it low

2 participants