Skip to content

fix(hotkey): never debounce a STOP, only a START#18

Merged
mledour merged 1 commit into
mainfrom
fix/hotkey-honor-stop
Jun 8, 2026
Merged

fix(hotkey): never debounce a STOP, only a START#18
mledour merged 1 commit into
mainfrom
fix/hotkey-honor-stop

Conversation

@mledour

@mledour mledour commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Finding #7 (code review): the debounce swallows a deliberate STOP

The 500 ms toggle debounce was direction-agnostic — it dropped any Ctrl+F9 edge landing within 500 ms of the previous toggle. But each edge toggles monitoring, so the swallowed second edge of a rapid pair is always the STOP. A user who deliberately tapped START then STOP within half a second had the STOP dropped → the writers kept running and the CSVs kept growing while they believed recording had stopped ("I stopped it and it kept recording").

(There's no way to distinguish a deliberate fast double-tap from a spurious OBS double-fire by timing — they're identical inputs — so honoring the deliberate STOP necessarily means the spurious case nets to OFF too. That's the better outcome anyway.)

Fix

Make the debounce direction-aware:

  • STOP (target = OFF) → always honored.
  • START (target = ON) → debounced (still stops a remapper/OBS/ShadowPlay firing Ctrl+F9 repeatedly from flapping the recording on).

Results:

  • Deliberate fast START→STOP now ends OFF as intended.
  • A spurious double-fire nets to OFF instead of leaving monitoring stuck ON — and its merge covers only the handful of frames in that <500 ms window (cheap; not the 10-50 ms stall of a full session that the original debounce comment worried about).

Verification

The hotkey path lives in xrEndFrame (needs a live layer + simulated key state), so — like MergeIntoOutput and the rest of it — it's covered by the build + review rather than a unit test. One file, layer.cpp (+33/−22); no lines >120 cols.

🤖 Generated with Claude Code

The 500 ms toggle debounce was direction-agnostic: it dropped any edge
landing within 500 ms of the previous toggle. Because each Ctrl+F9 edge
toggles monitoring, the swallowed second edge of a rapid pair is ALWAYS the
STOP -- so a user who deliberately tapped START then STOP within half a
second had the STOP dropped, leaving the writers running and the CSVs growing
while they believed recording had stopped ("I stopped it and it kept
recording").

Make the debounce direction-aware: a STOP (target = OFF) is always honored;
only a START (target = ON) is debounced, which still stops a remapper / OBS /
ShadowPlay that fires Ctrl+F9 repeatedly from flapping the recording on. A
deliberate fast START->STOP now ends OFF as intended, and a spurious
double-fire nets to OFF -- its merge covers only the handful of frames in that
<500 ms window (cheap, not the 10-50 ms stall of a full session) -- rather
than leaving monitoring stuck ON.

The hotkey path lives in xrEndFrame (needs a live layer + simulated key
state), so like the rest of it it is covered by the build + review rather
than a unit test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mledour mledour merged commit 617ea27 into main Jun 8, 2026
3 checks passed
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.

2 participants