Skip to content

test(dual-tap): cover handleDualTap; document Shift gesture in layout spec#169

Open
dormouse-bot wants to merge 1 commit into
mainfrom
test/dual-tap-coverage
Open

test(dual-tap): cover handleDualTap; document Shift gesture in layout spec#169
dormouse-bot wants to merge 1 commit into
mainfrom
test/dual-tap-coverage

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Surfaced by the nightly code-quality survey.

handleDualTap (handle-dual-tap.ts) is the mode-exit gesture detector: a left-then-right tap of Meta (or Shift) within 500ms exits passthrough mode. It carries non-trivial state-machine logic — a per-side timing window, strict left→right ordering, two independent Meta/Shift tracks, and an "always consume Meta/Shift presses" contract that the doc comment explicitly flags as a correctness requirement ("so later handlers don't misinterpret a modifier release as a navigation key"). None of it was covered by a test.

This PR adds handle-dual-tap.test.ts pinning that behavior:

  • left→right Meta within the window exits passthrough (and resets state)
  • a right press past the 500ms window does not exit (boundary is exclusive)
  • right→left ordering does not exit
  • left→right Shift exits, independently of Meta
  • Meta and Shift tracks don't cross-trigger (Left Cmd → Right Shift is a no-op)
  • non-modifier keys return false (not consumed); Meta/Shift return true
  • when already in command mode, the gesture completes and resets state but does not call exitTerminalMode

While writing the tests I noticed the Shift gesture is undocumented in the layout spec — docs/specs/layout.md described only the LCmd → RCmd Meta gesture for both the passthrough mode-exit and "Enter command mode" sections. Per AGENTS.md ("When updating code covered by a spec, update the spec to match"), this PR also updates those two sections to document the LShift → RShift variant and note that the Meta and Shift tracks are independent.

No behavior change — tests and docs only.

… spec

handleDualTap had no test coverage despite non-trivial timing/state-machine
logic (500ms window, left→right ordering, independent Meta/Shift tracks, and
the always-consume contract). Add handle-dual-tap.test.ts pinning that
behavior.

The Shift dual-tap variant was also undocumented in docs/specs/layout.md
(only the Meta LCmd→RCmd gesture was described). Update the passthrough and
"Enter command mode" sections to match the code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: c7d66f5
Status: ✅  Deploy successful!
Preview URL: https://7d15d23b.mouseterm.pages.dev
Branch Preview URL: https://test-dual-tap-coverage.mouseterm.pages.dev

View logs

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