Skip to content

Add M shortcut toggle for audio stream#123

Merged
sudip-mondal-2002 merged 3 commits into
sudip-mondal-2002:mainfrom
Ketandora:feature/m-audio-shortcut
May 19, 2026
Merged

Add M shortcut toggle for audio stream#123
sudip-mondal-2002 merged 3 commits into
sudip-mondal-2002:mainfrom
Ketandora:feature/m-audio-shortcut

Conversation

@Ketandora

@Ketandora Ketandora commented May 18, 2026

Copy link
Copy Markdown
Contributor

Closes #72

Summary

Implemented an M keyboard shortcut to quickly toggle the audio stream on/off from the main window.

Changes Made

  • Added M key shortcut handling in the main ImGui render loop
  • Added audio mute/unmute toggle state handling
  • Added visual muted/status feedback in the UI
  • Added shortcut hint (M) in Audio menu items
  • Updated README Controls section with shortcut documentation

Testing

  • Verified audio stream toggles correctly using M
  • Verified menu shortcut hint appears correctly
  • Verified muted/status feedback updates visually
  • Verified existing application behavior remains functional

Screenshot

(Attached below)
Screenshot 2026-05-19 003932

Summary by CodeRabbit

  • New Features

    • Added M keyboard shortcut to toggle audio mute/unmute when the main window is focused and not typing.
    • Shows a visible red "MUTED" label in the master controls when audio is muted.
    • Audio menu now displays the "M" shortcut next to Start/Stop Audio entries.
  • Documentation

    • Updated Usage → Controls to document the new mute/unmute keyboard shortcut.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6674b6a-3cd2-4544-8a75-319cd94bbd19

📥 Commits

Reviewing files that changed from the base of the PR and between 0c82504 and 16b9441.

📒 Files selected for processing (4)
  • CMakeLists.txt
  • src/gui/gui_manager.h
  • src/gui/gui_manager_frame.cpp
  • tests/test_gui_manager.cpp
✅ Files skipped from review due to trivial changes (1)
  • tests/test_gui_manager.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/gui/gui_manager.h
  • src/gui/gui_manager_frame.cpp

📝 Walkthrough

Walkthrough

Adds an M-key shortcut to toggle audio mute/unmute: tracks mute state in GuiManager, handles the key in the frame loop to stop/restart the engine, shows a red "MUTED" label in master controls, updates the Audio menu shortcut label, registers a placeholder test, and documents the shortcut in README.

Changes

Audio Mute Feature

Layer / File(s) Summary
Mute state and implementation
src/gui/gui_manager.h, src/gui/gui_manager_frame.cpp
Adds private audio_muted_ and toggle_audio_mute_state(); implements stop/restart + flag updates.
In-frame keyboard handling and key mapping
src/gui/gui_manager_frame.cpp
Reworks keyboard handling (unified mod checks, conditional widget rebuild) and adds M key handler that calls the mute toggle when ImGui is not accepting text and no item is active.
UI indicator, menu label, docs, and test integration
src/gui/gui_manager_frame.cpp, src/gui/gui_manager_menu.cpp, README.md, CMakeLists.txt, tests/test_gui_manager.cpp
Renders red "MUTED" label when muted; shows M in Audio menu items; documents shortcut in README; registers tests/test_gui_manager.cpp in CMake and adds a placeholder passing test.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ImGuiIO
  participant GuiManager
  participant Engine
  User->>ImGuiIO: press 'M'
  ImGuiIO->>GuiManager: run_frame() detects key when not in text/item
  GuiManager->>GuiManager: toggle_audio_mute_state()
  alt now muted
    GuiManager->>Engine: stop()
  else now unmuted
    GuiManager->>Engine: restart()
  end
  GuiManager->>GuiManager: update audio_muted_ flag and UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #72: Implements the M-key audio mute/unmute feature with engine control, state tracking, UI indicator, menu shortcut label, and README documentation.

Suggested labels

level:intermediate

Suggested reviewers

  • sudip-mondal-2002

Poem

🐰 I tap the M and silence hops in,
a tiny pause, a gentle grin.
Red "MUTED" flashes, quiet and neat,
then sound returns on nimble feet. 🎶

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses linked issue #72 but has critical defects: mute state can desynchronize from engine state (confirmed by reviewer), test coverage is incomplete (trivial placeholder test added), and unrelated whitespace changes were introduced. Fix audio_muted_ toggle logic to check engine_.is_running() state before toggling (as noted in review), add comprehensive tests for mute state synchronization, and revert unrelated formatting changes to keep diff focused.
Out of Scope Changes check ⚠️ Warning The PR includes unrelated whitespace and indentation changes to the undo/redo/snapshot shortcut block, which should be reverted to keep the changeset focused on the M shortcut feature. Revert whitespace and indentation changes to the undo/redo/snapshot shortcut handling block in gui_manager_frame.cpp to separate cosmetic from functional changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary feature: adding an M keyboard shortcut to toggle audio stream on/off.

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

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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@src/gui/gui_manager_frame.cpp`:
- Around line 134-147: The code flips audio_muted_ before consulting the engine,
which can desync if the engine was already stopped; instead, query the real
state with engine_.is_running(), call engine_.stop() if it was running or
engine_.start() if it was not, and then set audio_muted_ based on the resulting
engine state (preferably set audio_muted_ = !engine_.is_running() after the
start/stop call to reflect the true state). Apply this change to the ImGui key
handler block that currently toggles audio_muted_ and to the other identical
block noted in the review.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90ce4c57-a7a4-4ae3-a85b-bbaa1f4a3111

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd0639 and 6b198fa.

📒 Files selected for processing (4)
  • README.md
  • src/gui/gui_manager.h
  • src/gui/gui_manager_frame.cpp
  • src/gui/gui_manager_menu.cpp

Comment thread src/gui/gui_manager_frame.cpp Outdated
@sudip-mondal-2002 sudip-mondal-2002 added type:feature New feature or request gssoc:approved GSSoC 2026 contribution level:beginner Easy task · 10 GSSoC points quality:clean mentor:ionfwsrijan labels May 18, 2026
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

PR Preview Removed

The GitHub Pages preview for this PR has been removed because the PR was closed.

@sudip-mondal-2002

Copy link
Copy Markdown
Owner

@Ketandora please add test coverage

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Hey @Ketandora, thanks for the contribution! The feature works on the PR preview and the overall approach is solid, but there are a few things to address before this can be merged:


🔴 Bug — Mute state can desync from engine state

In gui_manager_frame.cpp (lines 134–147), audio_muted_ is flipped before checking the real engine state:

audio_muted_ = !audio_muted_;
if (audio_muted_) {
    engine_.stop();
} else {
    engine_.start();
}

If the engine was already stopped via the menu (or another path), audio_muted_ can be false while the engine is not actually running. Pressing M then flips it to true and calls engine_.stop() on an already-stopped engine — the MUTED label goes out of sync and the user needs two presses to resume.

The fix is to drive the toggle from engine_.is_running() directly — which is already the pattern used in gui_manager_menu.cpp:

if (engine_.is_running()) {
    engine_.stop();
    audio_muted_ = true;
} else {
    engine_.restart();
    audio_muted_ = false;
}

This same block appears twice — around line 134 and again around line 216 — both need the fix.


🔴 Missing test coverage

No tests were added for the new functionality. Please add tests covering at least:

  • Pressing M when engine is running → engine stops, audio_muted_ becomes true
  • Pressing M when engine is stopped → engine starts, audio_muted_ becomes false
  • Toggling via menu then pressing M → state stays consistent (the desync scenario above)
  • The MUTED label renders correctly based on audio_muted_

🟡 Minor — Unrelated whitespace changes

The diff includes indentation/formatting changes to the existing undo/redo/snapshot shortcut block that aren't related to this feature. Please revert those to keep the diff focused and easier to review.


Once these are addressed this should be good to go!

@Ketandora

Copy link
Copy Markdown
Contributor Author

@sudip-mondal-2002 I’ll add the required test coverage asap and update the PR shortly.

@Ketandora

Copy link
Copy Markdown
Contributor Author

Thanks @idrwfanjan for the detailed review and suggestions. I’ll update the mute toggle logic to use the actual engine running state directly, add the requested test coverage, and clean up the unrelated whitespace changes as well.

@Ketandora

Copy link
Copy Markdown
Contributor Author

Hii, @sudip-mondal-2002 @ionfwsrijan ,Updated the PR with the requested changes:

  • Refactored mute toggle logic to use the actual engine running state
  • Removed duplicate shortcut handling
  • Cleaned up formatting changes
  • Added test coverage and integrated it into the test target

Please check it out and let me know if any further changes or improvements are needed.

@sudip-mondal-2002 sudip-mondal-2002 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

@sudip-mondal-2002 sudip-mondal-2002 merged commit c4b6730 into sudip-mondal-2002:main May 19, 2026
8 checks passed
github-actions Bot added a commit that referenced this pull request May 19, 2026
@Ketandora Ketandora deleted the feature/m-audio-shortcut branch May 19, 2026 11:35
@Ketandora Ketandora restored the feature/m-audio-shortcut branch May 19, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add M keyboard shortcut to toggle audio stream mute/unmute

3 participants