Skip to content

Improve sound handling and show title in volume mixer #4447

Merged
DavidGBrett merged 6 commits intoFlow-Launcher:devfrom
DavidGBrett:improve-volume-mixer-behavior
May 7, 2026
Merged

Improve sound handling and show title in volume mixer #4447
DavidGBrett merged 6 commits intoFlow-Launcher:devfrom
DavidGBrett:improve-volume-mixer-behavior

Conversation

@DavidGBrett
Copy link
Copy Markdown
Contributor

@DavidGBrett DavidGBrett commented May 7, 2026

Mostly fixes #2864

Fixes the blank name issue in the volume mixer by setting AssemblyTitle

Only creates the sound / media players when _settings.UseSounds is set and observes changes to that, disposing and init'ing as needed.

This avoids showing flow in the volume mixer if it is set to false at startup, but unfortunately it doesn't seem possible to remove it from there in runtime.

As far as I can tell this is because the created audio session is tied to the flow launcher process itself in windows, so our only options would be trying some low level API's or using a seperate process for audio.


Summary by cubic

Summary of changes

Show “Flow Launcher” by name in the Windows volume mixer and make sound effects opt-in with lazy init. The mixer no longer shows Flow if sounds are off at startup (addresses #2864; runtime removal isn’t possible).

  • Details
    • Changed: Settings.UseSound is now observable; we react on startup, on setting changes, and after resume via SyncSoundEffectsState. In Dispose, we now UnregisterSoundEffectsEvent before DisposeSoundEffects for safe teardown. SoundPlay adds null checks.
    • Added: [assembly: AssemblyTitle("Flow Launcher")] for the mixer label. New methods SyncSoundEffectsState, DisposeSoundEffects, and IsSoundEffectsInitialized manage player lifecycle and reinit after resume.
    • Removed: Unconditional media player initialization at startup and direct per-field close/dispose calls.
    • Memory impact: Lower usage when UseSound is off (no players created); resources released immediately when toggled off or on dispose.
    • Security: No new risks.
    • Tests: No new unit tests.

Written for commit c7447ea. Summary will update on new commits.

The volume mixer uses this value, so this fixes the issue where no named showed for flow there
@github-actions github-actions Bot added this to the 2.2.0 milestone May 7, 2026
@DavidGBrett DavidGBrett changed the title Improve volume mixer behavior Improve sound handling and appearance in volume mixer May 7, 2026
@DavidGBrett DavidGBrett marked this pull request as ready for review May 7, 2026 10:00
@coderabbitai coderabbitai Bot added the bug Something isn't working label May 7, 2026
@DavidGBrett DavidGBrett added the enhancement New feature or request label May 7, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 25741799-541a-4a2a-93d1-bd104af19872

📥 Commits

Reviewing files that changed from the base of the PR and between 52370d7 and c7447ea.

📒 Files selected for processing (1)
  • Flow.Launcher/MainWindow.xaml.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher/MainWindow.xaml.cs

📝 Walkthrough

Walkthrough

Flow Launcher makes the UseSound setting observable via property-change notifications and synchronizes sound resource lifecycle with this setting. Sound effects are conditionally initialized or torn down when the setting changes; playback is guarded against uninitialized instances and resources are re-synced after sleep and on disposal. Assembly title "Flow Launcher" was added.

Changes

Sound Lifecycle Synchronization

Layer / File(s) Summary
Observable Setting
Flow.Launcher.Infrastructure/UserSettings/Settings.cs
UseSound is converted from an auto-property to a backing-field property with OnPropertyChanged() notification on setter.
Assembly Metadata
SolutionAssemblyInfo.cs
Adds [assembly: AssemblyTitle("Flow Launcher")].
Initialization & Wiring
Flow.Launcher/MainWindow.xaml.cs
Constructor calls SyncSoundEffectsState() so sound resources are created only when UseSound is enabled.
Setting Change Handler
Flow.Launcher/MainWindow.xaml.cs
Adds Settings.UseSound PropertyChanged handler to call SyncSoundEffectsState() on toggle.
Playback Safety
Flow.Launcher/MainWindow.xaml.cs
SoundPlay() early-returns when sound player instances are null to prevent null dereferences.
Lifecycle Helpers
Flow.Launcher/MainWindow.xaml.cs
Introduces IsSoundEffectsInitialized(), DisposeSoundEffects(), and SyncSoundEffectsState(bool forceReinitializeWhenEnabled = false) to centralize init/teardown logic.
Sleep/Hibernate Recovery
Flow.Launcher/MainWindow.xaml.cs
Resume path dispatches SyncSoundEffectsState(forceReinitializeWhenEnabled: true) to the UI thread instead of unconditional init.
Dispose / Cleanup
Flow.Launcher/MainWindow.xaml.cs
Dispose(bool) delegates sound cleanup to DisposeSoundEffects() for centralized disposal.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • jjw24
  • taooceros
  • Jack251970
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main changes: improving sound handling (conditional initialization based on UseSound setting) and showing the application title in the volume mixer via AssemblyTitle.
Description check ✅ Passed The PR description is detailed and directly related to the changeset, explaining the fixes to issue #2864, the AssemblyTitle addition, and the conditional sound initialization logic.
Linked Issues check ✅ Passed The PR addresses both requirements from issue #2864: it adds AssemblyTitle to display 'Flow Launcher' in the volume mixer, and implements conditional sound initialization to avoid showing the app in the mixer when sounds are disabled at startup.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objectives: AssemblyTitle addition, Settings.UseSound observability, SyncSoundEffectsState implementation, and sound resource lifecycle management for the volume mixer improvement.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Flow.Launcher/MainWindow.xaml.cs`:
- Around line 782-790: The wake/sleep handler must force reinitialization of the
MediaPlayer even if _animationSoundWMP is non-null; change the logic in the
dispatcher-invoked block so that SyncSoundEffectsState (or the code path it
calls) invokes InitSoundEffects unconditionally when sound is enabled on wake
instead of only when IsSoundEffectsInitialized() returns false. Concretely,
update SyncSoundEffectsState (or the wake handler that calls it) to detect a
resume event and call InitSoundEffects() regardless of
IsSoundEffectsInitialized(), ensuring _animationSoundWMP gets reconstructed
after resume; keep the Dispatcher.CheckAccess/Invoke pattern around the call to
preserve UI-thread affinity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f72394b2-34dc-454b-a634-e529e7f3efb3

📥 Commits

Reviewing files that changed from the base of the PR and between d146197 and 92269ab.

📒 Files selected for processing (3)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs
  • Flow.Launcher/MainWindow.xaml.cs
  • SolutionAssemblyInfo.cs

Comment thread Flow.Launcher/MainWindow.xaml.cs
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Flow.Launcher/MainWindow.xaml.cs">

<violation number="1" location="Flow.Launcher/MainWindow.xaml.cs:758">
P2: After sleep/hibernate, sound players are no longer reinitialized when `UseSound` is enabled, so the previous "sound not playing after sleep" issue can reappear.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread Flow.Launcher/MainWindow.xaml.cs Outdated
@DavidGBrett DavidGBrett marked this pull request as draft May 7, 2026 10:06
Add SyncSoundEffectsState and observe UseSound changes in MainWindow

Only initialize sound effects on startup when Settings.UseSound is enabled.
Listen for UseSound changes at runtime and sync the sound player state by
initializing or disposing it as needed.
@DavidGBrett DavidGBrett force-pushed the improve-volume-mixer-behavior branch from 92269ab to 298f45b Compare May 7, 2026 10:50
@DavidGBrett DavidGBrett changed the title Improve sound handling and appearance in volume mixer Improve sound handling and show title in volume mixer May 7, 2026
@DavidGBrett DavidGBrett marked this pull request as ready for review May 7, 2026 10:55
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Windows volume mixer behavior by ensuring Flow Launcher has a proper session title and by lazily initializing/disposing sound-effect players based on the UseSound setting, preventing an audio session from being created at startup when sounds are disabled (related to #2864).

Changes:

  • Add AssemblyTitle("Flow Launcher") so the app name appears correctly in the Windows volume mixer.
  • Make Settings.UseSound raise PropertyChanged so the app can react immediately to toggles.
  • Replace unconditional sound initialization with SyncSoundEffectsState() plus centralized disposal and safer playback null-checks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
SolutionAssemblyInfo.cs Adds AssemblyTitle to improve the displayed app name in the Windows volume mixer.
Flow.Launcher/MainWindow.xaml.cs Lazily initializes/tears down sound players based on UseSound, adds reinit-on-resume path, and null-safety in SoundPlay.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Makes UseSound observable via PropertyChanged to support runtime lifecycle updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Flow.Launcher/MainWindow.xaml.cs Outdated
Comment thread Flow.Launcher/MainWindow.xaml.cs Outdated
Comment thread Flow.Launcher/MainWindow.xaml.cs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Flow.Launcher/MainWindow.xaml.cs`:
- Around line 1534-1539: Swap the call order in the MainWindow disposal sequence
so the sleep/wake listener is deregistered before tearing down players: call
UnregisterSoundEffectsEvent() prior to DisposeSoundEffects() (near the dispose
block that currently calls _hwndSource?.Dispose(), _notifyIcon?.Dispose(),
DisposeSoundEffects(), _viewModel.ActualApplicationThemeChanged -=
ViewModel_ActualApplicationThemeChanged, UnregisterSoundEffectsEvent()). This
ensures the background Win32 callback cannot reinitialize sound players after
they have been disposed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95276c49-0e54-44fd-bfb3-711da1db76fe

📥 Commits

Reviewing files that changed from the base of the PR and between 298f45b and 52370d7.

📒 Files selected for processing (1)
  • Flow.Launcher/MainWindow.xaml.cs

Comment thread Flow.Launcher/MainWindow.xaml.cs
Copy link
Copy Markdown
Member

@Jack251970 Jack251970 left a comment

Choose a reason for hiding this comment

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

LGTM! Feel free to merge it by yourself!

@DavidGBrett DavidGBrett enabled auto-merge May 7, 2026 12:55
@DavidGBrett DavidGBrett merged commit 4847576 into Flow-Launcher:dev May 7, 2026
3 checks passed
@DavidGBrett DavidGBrett deleted the improve-volume-mixer-behavior branch May 7, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Improve behavior in the Windows volume mixer

3 participants