Skip to content

Add pause-while-recording across macOS, Windows, and Linux (tested on Ubuntu)#1028

Open
apotenza92 wants to merge 7 commits intocjpais:mainfrom
apotenza92:feature/pause-while-recording-media-key
Open

Add pause-while-recording across macOS, Windows, and Linux (tested on Ubuntu)#1028
apotenza92 wants to merge 7 commits intocjpais:mainfrom
apotenza92:feature/pause-while-recording-media-key

Conversation

@apotenza92
Copy link
Copy Markdown

Before Submitting This PR

If this is a feature or change that was previously closed/rejected:

  • I have explained in the description below why this should be reconsidered
  • I have gathered community feedback (link to discussion below)

Human Written Description

I originally opened #998 after having an issue on macOS where mute while recording wasn't working correctly with my hardware setup (USB audio interface), so I decided to just try making pause while recording as an additional option that I prefer.

Related Issues/Discussions

Fixes #998
Related to #192

This revisits the older pause/resume media request from #192, but the scope here is intentionally framed as a bug-fix / hardening pass rather than a net-new feature pitch. This PR makes pause-while-recording behave consistently across macOS, Windows, and Linux, improves lifecycle safety, and aligns the settings/UI/backend behavior.

Community Feedback

The original motivation came from #998. I did not open a separate Discussion thread for this change, but I manually built and tested the resulting behavior on macOS, Windows, and Ubuntu to verify the feature works across all three supported desktop platforms. I primarily run macOS but used Parallels to test in Windows and Ubuntu VMs.

Testing

Automated / local checks

  • cargo test --manifest-path src-tauri/Cargo.toml media_control -- --nocapture
  • bun run build
  • bun run format:check
  • bun run lint

Manual cross-platform validation

  • macOS
    • Built Handy.app and DMG locally
    • Launched the app bundle successfully
    • Verified pause-while-recording pauses active media playback
    • Verified resume-after-recording restores playback when enabled
  • Windows 11 ARM VM
    • Built native handy.exe
    • Launched and verified the app runs in the VM
    • Verified pause/resume behavior works during recording
  • Ubuntu 24.04 ARM64 VM
    • Built native handy
    • Launched and verified the app runs in the VM
    • Verified pause/resume behavior works during recording

What changed

  • Added platform-specific media control backends for macOS, Windows, and Linux
  • Added lifecycle hardening to avoid duplicate pause/resume and stale in-flight pause results
  • Updated recording start/stop ordering so pause happens before Handy's start sound and resume happens after the stop sound
  • Synced UI/store/backend behavior for pause/resume settings
  • Added unit coverage for media-control lifecycle cases

Notes

  • cargo clippy --all-targets --all-features -- -D warnings still reports existing repo-wide warnings unrelated to this PR, so I did not fold a broad clippy cleanup into this change

Screenshots/Videos (if applicable)

None for now.

AI Assistance

  • No AI was used in this PR
  • AI was used (please describe below)

If AI was used:

  • Tools used: pi coding agent / AI coding assistant
  • How extensively: used for repository discovery, implementation assistance, build debugging, cross-platform VM build/test setup, and PR drafting support

@cjpais
Copy link
Copy Markdown
Owner

cjpais commented Mar 13, 2026

@apotenza92
Copy link
Copy Markdown
Author

Reproduced locally on macOS x86_64 target and pushed fix. Issue was MediaRemote bridge being compiled for the host arch instead of the target arch

@github-actions
Copy link
Copy Markdown

🧪 Test Build Ready

Build artifacts for PR #1028 are available for testing.

Download artifacts from workflow run

Artifacts expire after 30 days.

apotenza92 and others added 5 commits March 18, 2026 23:19
The `any_application_is_playing()` guard in `platform_resume_playback`
was causing media to never resume. After sending the MediaRemote pause
command, the OS does not immediately update its now-playing state, so
the check would always see the paused app as still "playing" and bail
out before calling `play()`. Since we already know something was playing
(we paused it ourselves and stored that in `paused_playback`), the guard
is unnecessary — remove it.

Also handle the race where `resume_after_recording` is called before the
MediaRemote pause backend call returns: store the resume intent in
`stale_resume_play` so the pause thread can resume immediately once its
result arrives, preventing media from getting stuck paused.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@apotenza92 apotenza92 force-pushed the feature/pause-while-recording-media-key branch from b4e21a3 to 876e23b Compare March 19, 2026 01:01
@apotenza92
Copy link
Copy Markdown
Author

I pushed a cleanup / update based on some issues that came up during my own local testing:

  • fixed macOS resume-after-recording behaviour
  • fixed the macOS case where playback could start after recording even if nothing
    was playing initially
  • restored the macOS whisper bindings override so x86_64-apple-darwin builds
    compile again
  • cleaned out unrelated local/debug churn from the branch

Re-tested locally on macOS:

  • playback case: pauses during recording and resumes after
  • no-media case: does not spuriously start playback
  • cargo check -q
  • cargo check —target x86_64-apple-darwin —no-default-features -q

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.

[BUG] macOS 26.3 - 'Mute While Recording' doesn't work when using USB Audio Interface. Can handy have 'Pause While Recording' as an alternative?

2 participants