Skip to content

feat: add debug mode toggle for verbose mpv logging#5

Merged
flamerged merged 1 commit into
mainfrom
feat/debug-mode-toggle
May 15, 2026
Merged

feat: add debug mode toggle for verbose mpv logging#5
flamerged merged 1 commit into
mainfrom
feat/debug-mode-toggle

Conversation

@flamerged

@flamerged flamerged commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a 🐞 Debug mode toggle in the Tools submenu and tightens default mpv logging.

Why. The mpv log was growing ~10 KB/minute even when nothing interesting was happening — most of it was IPC chatter from the menu polling mpv every 5 seconds (Client connected/disconnected lines at level v) and per-segment ffmpeg HLS-request lines on live streams. Over a few days of background play the log balloons to hundreds of MB. Meanwhile, when something does go wrong (CoreAudio routing dies after Superwhisper grabs the device, YouTube returns 403 on a segment, yt-dlp extractor breaks), the useful lines are buried under that noise.

Behaviour.

Mode --msg-level On stop
Default (quiet) all=info,ipc=warn,ffmpeg=warn Log truncated
Debug ON all=v Log preserved across stop/play cycles

State persists in $MENUTUBE_CONFIG_DIR/debug ("yes" or "no"), mirroring the existing repeat toggle pattern. Takes effect on the next track since --msg-level is baked in at mpv launch.

Why not always-verbose

Because the typical background-music session runs for hours/days. Default-quiet keeps log files from bloating in $TMPDIR (which on macOS survives reboots — files in /var/folders/.../T/ are not wiped by default). When someone hits an actual bug, they flip the toggle, reproduce, and read a fresh focused log.

Validation

./scripts/check.sh now includes a regression guard for the toggle:

  • Default render shows Debug mode: OFF
  • <plugin> debug dispatch persists yes to $DEBUG_FILE
  • Subsequent render shows Debug mode: ON
==> debug-mode toggle (renders + persists; regression guard)
    OK

Plus all existing checks (xbar.var declarations, dry render, literal-tilde defense, auto-release dry-run) still pass.

coderabbit --plain locally: No findings ✔.

Files

File Change
bin/menutube.5s.sh DEBUG_FILE constant, debug_on() helper, conditional --msg-level in action_play, log truncate in action_stop, new action_debug + dispatch case, menu toggle in Tools submenu
scripts/check.sh Regression test for the toggle
CHANGELOG.md Unreleased entry under Added

Summary by CodeRabbit

  • New Features

    • Added Debug mode toggle in Tools submenu to control mpv logging verbosity and log preservation across stop/play cycles; toggle state persists between sessions.
  • Tests

    • Added regression test for debug mode toggle functionality.

Review Change Stack

Default playback now uses --msg-level=all=info,ipc=warn,ffmpeg=warn, which
suppresses the per-refresh IPC connect/disconnect chatter (the menu polls
mpv every 5 seconds) and per-segment HLS request lines. action_stop also
truncates the log so each new track starts fresh.

A 🐞 Debug mode toggle in the Tools submenu flips both behaviours: mpv
runs at --msg-level=all=v and the log is preserved across stop/play
cycles. Useful for diagnosing CoreAudio routing issues, 403s on YouTube
HLS segments, or yt-dlp extractor changes.

State persists in \$MENUTUBE_CONFIG_DIR/debug ("yes" | "no"). Takes effect
on the next track since --msg-level is baked in at mpv launch time.

scripts/check.sh now guards against the toggle regressing: validates that
the default render shows "Debug mode: OFF", that the dispatch persists
"yes" to the state file, and that the next render reflects the flip.
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 183758f9-9b15-4f7a-840c-aa5bea1f1f3f

📥 Commits

Reviewing files that changed from the base of the PR and between 1ebe7f6 and 91ac89a.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • bin/menutube.5s.sh
  • scripts/check.sh

📝 Walkthrough

Walkthrough

This PR adds a persistent debug mode toggle to the menutube plugin's Tools submenu. Debug mode increases mpv verbosity, preserves the mpv log across stop/play cycles, and stores the toggle state in a config file that applies on the next track. Default behavior uses quieter mpv logging and truncates the log on stop.

Changes

Debug Mode Toggle Feature

Layer / File(s) Summary
Debug state configuration and persistence
bin/menutube.5s.sh, CHANGELOG.md
DEBUG_FILE path and debug_on() helper enable reading persisted debug state; changelog documents the feature behavior, verbosity changes, and log truncation on stop.
Debug-aware playback and log control
bin/menutube.5s.sh
action_play computes mpv msg_level verbosity (verbose in debug mode; reduced IPC/ffmpeg chatter otherwise) and passes it to mpv; action_stop conditionally truncates the log only when debug is disabled; action_debug toggles the persisted debug flag.
Debug dispatch and menu UI
bin/menutube.5s.sh
New debug) dispatch case routes param1=debug to toggle action; menu output shows "Debug mode: ON/OFF" as a clickable item invoking the debug action.
Debug toggle regression test
scripts/check.sh
Test creates temp config, renders initial "Debug mode: OFF" state, invokes debug action to persist toggle, verifies config file contains yes, re-renders and asserts UI shows "Debug mode: ON".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A toggle for debugging hops into view,
With log verbosity switching, fresh as morning dew.
Persist, preserve, and play the next track—
Debug mode's here, the logs got your back!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add debug mode toggle for verbose mpv logging' directly and accurately summarizes the main change—a new debug mode toggle feature that controls mpv logging verbosity, which is the primary objective of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/debug-mode-toggle

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

@flamerged
flamerged merged commit 3714eae into main May 15, 2026
4 checks passed
@flamerged
flamerged deleted the feat/debug-mode-toggle branch May 15, 2026 13:45
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.

1 participant