Skip to content

feat(app): make mobile gestures follow the finger, carry release velocity, and share one page owner - #8536

Open
smsunarto wants to merge 11 commits into
get-bb:mainfrom
smsunarto:scott/bb-31-apple-design-mobile-gesture-physics-sideba-thr_hpvnhhpqmm
Open

smsunarto wants to merge 11 commits into
get-bb:mainfrom
smsunarto:scott/bb-31-apple-design-mobile-gesture-physics-sideba-thr_hpvnhhpqmm

Conversation

@smsunarto

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

On phones, the sidebar, right-panel shelf, sheets and right-panel tab pager released on fixed 220 ms timers with threshold-only open/close decisions:

  • A flick and a slow drag landed the same way.
  • The tab pager didn't follow the finger.
  • A new touch couldn't catch a settling surface.

The settle timers also ran without checking which gesture currently held the page. An older gesture's timer could write or clear the page position after another surface took it, leaving the page partly off screen. See #8535.

What changed

  • Finger-tracking motion that carries release velocity.
    • New @bb/shared-ui gesture-physics helper: velocity sampling, momentum projection, rubber-band past edges, and settle durations derived from the remaining distance and release speed. It is registered in the plugin registry.
    • The sidebar swipe, right-panel shelf (open and close), sheets (responsive-overlay) and tab pager track the finger. They project the release to decide where to land, and settle with a velocity-matched CSS curve.
    • Commit haptics fire only when a gesture actually opens or closes something, through gesture-commit-feedback.
  • Interruptible. A touch during a settle picks the surface up from its in-flight position, with no jump. Reopening the shelf mid-close resumes from the page's current offset.
  • One page-gesture owner. page-gesture-owner.ts holds a monotonic token and is the only module that writes the page (sidebar inset) position: writePageMotion(token, …) writes only for the current owner.
    • Every page mover claims a token first: sidebar swipe, sidebar button open/close, shelf swipe open/close, Escape, and programmatic shelf open/close.
    • Every delayed finish step (settle timers, rAF) checks ownership first. A stale one makes no page write, no commit and no haptic. It releases only its own surface's chrome, and only if that surface doesn't hold the page again.
  • Reduced motion. Settles skip the animation, and the pager snaps on tap or interrupt.
  • The desktop sidebar slides on translate so its panel tracks the inset gap without a seam.

How you verified

  • pnpm exec turbo run typecheck test lint lint:type-aware --filter=@bb/app --filter=@bb/shared-ui --filter=@bb/plugin-registry: 17/17 tasks pass.
    • @bb/app: 7610 tests passed, 20 skipped.
    • @bb/shared-ui: 105 passed.
    • @bb/plugin-registry: 1 passed.
  • node packages/plugin-registry/scripts/build-registry.mjs --check: up to date.
  • Pinned oxfmt --check on the changed files passes.
  • New behaviour tests: gesture-physics.test.ts, plus additions to sidebar.test.tsx, CompactSecondaryPanelShelf.test.tsx, MobilePanelTabPager.test.tsx and responsive-overlay.test.tsx.
  • page-gesture-ownership.test.tsx has two guards:
    • A runtime trap fails on any page position write made without owning the page, across taps, swipes, Escape and their interruptions.
    • A static scan fails on direct page writes outside the owner module.
    • It also reproduces three interleavings: Escape mid-swipe, Escape during the sidebar's opening settle, and the sidebar button about 80 ms after a shelf flick.
    • These tests fail on the previous iteration of this branch and pass now.
  • Live checks in a source dev instance with 390×844 touch emulation and per-frame traces:
    • flick and slow open/close for the sidebar and shelf;
    • shelf reopen mid-close;
    • sidebar during shelf close;
    • the three interleavings above;
    • button and backdrop taps;
    • the desktop 1440×900 sidebar collapse seam.

Notes

  • Not verified on a physical iPhone: haptics and iOS WebKit rendering. Haptics are covered by a unit test against the native bridge.
  • Edge cases are tracked separately as follow-ups:
    • rotating within ~35 ms of a sidebar tap;
    • a touch held down before a button toggle;
    • an inline transition writer outside the owner module;
    • widening the guard test's coverage.
  • Escape doesn't reach the mobile sidebar while the composer is focused, because the composer editor cancels the key. The sidebar's defaultPrevented guard is unchanged from main, so this PR doesn't touch it.

Closes #8535

AGENT GENERATED

@smsunarto
smsunarto marked this pull request as ready for review December 2, 2026 09:25

This branch has not been deployed

No deployments
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.

Mobile sidebar, shelf, sheets and tab pager use fixed-time slides that ignore the finger and can be overwritten by stale gestures

1 participant