Skip to content

Pocket tutorial cleanup: copy, mobile selection UI, and gesture compass polish#105

Merged
nedtwigg merged 12 commits into
mainfrom
mobile-tut-cleanup
May 28, 2026
Merged

Pocket tutorial cleanup: copy, mobile selection UI, and gesture compass polish#105
nedtwigg merged 12 commits into
mainfrom
mobile-tut-cleanup

Conversation

@nedtwigg
Copy link
Copy Markdown
Member

Summary

  • Reshape the Pocket tutorial: trim docs/specs/tutorial.md to point at the canonical copy in tut-items.ts/tut-runner.ts, clarify the Gesture/Select hints, and surface the Playground nav link on mobile.
  • Adapt text selection for touch: mobile selection overlay and copy popup now sit above the selection (so the dragging thumb can't cover them), the popup drops keyboard-shortcut chrome on touch, and a double-tap-then-drag arms block selection (the touch-side replacement for Alt).
  • Polish the gesture compass: track the submenu origin through overshoot, latch the expanded/collapsed compass as a small state machine, and place selected-group option chips on the circle (not a square). Spec and a new unit test lock the circular RADIUS_LAYOUT invariant in place.

Test plan

  • pnpm -C lib test (mobile-gesture-menu + terminal-mouse-router unit suites)
  • Storybook: Components/SelectionPopup Desktop vs Mobile; Components/SelectionOverlay Mobile{Linewise,Block}Drag; MobileTerminalUi GestureSoutheastOvershoot
  • On a touch device, walk the Pocket tutorial end-to-end:
    • gn-touch-mode / gn-arrows / gn-enter / gn-esc all credit
    • Copy paste: drag-select, Copy Raw and Copy Rewrapped on changelog, no cp-override step
    • Double-tap-then-drag produces a block selection; single-tap-then-drag stays linewise; two consecutive drags don't masquerade as a double-tap
    • Compass expands the moment an overshoot drag settles, and lets you reach the back option without unwinding the full overshoot

🤖 Generated with Claude Code

nedtwigg and others added 11 commits May 27, 2026 17:03
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The options phase laid out option chips with squareDirectionVector, whose
diagonal magnitude is √2, flinging diagonal sub-options to square corners
while cardinals sat on the circle. Use the normalized direction vectors so
every option lands on the circle at the given radius.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When a drag crossed the select radius into a submenu, the reference origin
stayed pinned at RADIUS_SELECT from the start. Continuing to drag in the
opening direction (the natural overshoot) meant the user had to drag all the
way back through it before a move in any other direction could register.

Add advanceOptionOrigin, a ratchet that slides the option origin outward to
meet the finger while the drag continues in the selection direction, so a
reversal immediately counts toward the intended option. Applied to both the
options and quit submenu phases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The compass circle now tracks the gesture: it spawns expanded, collapses to
the selection point when the first item is chosen, stays collapsed while the
drag keeps overshooting in the opening direction, then latches back to full
size as soon as the drag stops or turns toward an option — staying expanded
until the final selection collapses it to the chosen item.

Add an `expanded` latch to the options/quit states (set where overshoot is
already detected) and drive the circle's scale/opacity/origin from phase in
the component.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The expand latch only released when the drag fully stopped pushing outward or
reversed, so settling jitter kept the compass collapsed until a deliberate
move back — adding a second pause before it expanded. Treat an outward push
smaller than OPTION_EXPAND_RELEASE as a settle (still ratcheting the origin),
so the compass expands the moment the placards settle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a TouchUiContext that MobileTerminalUi provides, so the shared selection
components can tell they are rendered in the touch UI:

- SelectionPopup drops the Cmd+C / Cmd+Shift+C shortcut hints (no keyboard on
  touch) and always anchors above the selection so the thumb can't cover it.
- SelectionOverlay anchors its hint above the selection and labels block
  selection as "Start drag with double-tap" instead of "Hold Opt".

Desktop behavior is unchanged (context defaults to false). Add Storybook
stories covering both desktop and mobile for each component.

Note: the double-tap block-selection gesture the mobile hint describes is not
yet wired up — touch drags still produce linewise selections. Implementation
follows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The mobile selection hint promises block selection via double-tap, but touch
events have no Alt key (the only thing that set block shape). Detect a
double-tap in the terminal mouse router — a press landing soon after and near
the previous touch that ended as a tap — and latch block mode for the drag it
begins, carrying it through beginDrag/updateDrag. Recording the tap only on a
no-drag release keeps two quick consecutive drags from being mistaken for a
double-tap. Desktop Alt behavior is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add the missing "to" in the gn-enter/gn-esc hints, and match the
on-screen mode button label by writing `Gestures` mode in the Pocket
Copy paste prose (`Select` and `Mouse` in the same sentence already
match their button labels).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The exploded-option layout switched from a square to a circle in
ee1293b, but the mobile-ui spec still described `RADIUS_LAYOUT` as a
square half-side. Rewrite that paragraph to match the code and add a
unit test asserting `hypot(vec.x * R, vec.y * R) ≈ R` for every
direction vector so the invariant can't quietly regress.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 28, 2026

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: b30e21b
Status: ✅  Deploy successful!
Preview URL: https://092f0b0d.mouseterm.pages.dev
Branch Preview URL: https://mobile-tut-cleanup.mouseterm.pages.dev

View logs

This single-snapshot test caught no real bugs and broke on every
SiteHeader tweak (most recently the mobile Playground link). Delete
the test and its snapshot rather than re-baselining it again.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nedtwigg nedtwigg merged commit 5b86a38 into main May 28, 2026
9 checks passed
@nedtwigg nedtwigg deleted the mobile-tut-cleanup branch May 28, 2026 04:11
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