Skip to content

Restore mobile sidebar swipe dismissal - #2805

Merged
ymichael merged 1 commit into
mainfrom
bb/restore-mobile-sidebar-swipe-thr_f366sb3qdb
Sep 1, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/restore-mobile-sidebar-swipe-thr_f366sb3qdb

Conversation

@ymichael

@ymichael ymichael commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The compact left sidebar tracked closing gestures only from inside its panel, while the backdrop covering the exposed main-content strip handled clicks only. The compact right shelf had no swipe-dismiss controller after its shelf conversion, so neither its panel nor its exposed-content dismiss layer could track a closing swipe. A dismiss controller without an edge reservation would also compete with browser history navigation gestures.

What changed

Added one shared horizontal-dismiss hook for pointer/touch tracking, intent and velocity arbitration, nested horizontal-scroll protection, settling, and cleanup. The left and right shelf adapters now attach it to both the panel and their exposed-content dismiss layer, configure their direction and visual transforms, and reserve the corresponding 24px browser-navigation edge. No wire, CLI, guide, or protocol changes.

How you verified

  • Added red-to-green regressions for closing both shelves from the remaining exposed-content strip.
  • Added red-to-green regressions proving both corresponding 24px browser edges are ignored.
  • pnpm exec turbo run test --filter=@bb/app -- --run src/components/ui/sidebar.test.tsx src/components/secondary-panel/CompactSecondaryPanelShelf.test.tsx src/components/secondary-panel/SecondaryPanelLayout.test.tsx (56 passed)
  • pnpm exec turbo run typecheck --filter=@bb/app
  • pnpm exec turbo run lint --filter=@bb/app (0 errors)
  • Manually verified the left exposed-strip gesture at a 390x844 Chromium viewport before shutting down the requested dev share.

Reported directly; no linked GitHub issue.

AGENT GENERATED

@ymichael
ymichael merged commit 16f0ac5 into main Sep 1, 2026
15 checks passed
@ymichael
ymichael deleted the bb/restore-mobile-sidebar-swipe-thr_f366sb3qdb branch September 1, 2026 16:50
ymichael added a commit that referenced this pull request Oct 28, 2026
## Human comments

## What was wrong

Since #4329 replaced dnd-kit's `TouchSensor` with the custom long-press
`SidebarTouchSensor`, the sensor listened for
`touchmove`/`touchend`/`touchcancel` on `document`. Touch events keep
targeting the element where the touch started. If that row remounts
mid-drag, the remaining events go to a detached node and never bubble to
`document`. dnd-kit attaches these listeners to the event target for
exactly this reason. A remount happens, for example, when an agent
spawns a child thread under the held row, or when another client pins
it. The drag then never ends:
- the drag chip stays on screen, including over the thread view once the
drawer closes;
- the next tap anywhere ends the stale drag as a drop, so it doesn't
navigate and instead moves or nests the thread wherever the tap landed.

A second path leaves a row stuck as "being dragged" even when it stays
on the page. A long-press released with a quick slide past 12 px fires
the sensor's `onStart` and `onEnd` in the same task. dnd-kit records the
active drag in `sensorContext` only in a layout effect. Its end handler
therefore sees no active drag and skips `onDragEnd`/`onDragCancel`, but
our `onDragStart` has already run. The row stays at `opacity: 0.35,
pointerEvents: "none"` and ignores taps until a reload. This was the
cause of the row stuck after long-press, Archive and Unarchive,
diagnosed in a separate bb thread.

Two gesture conflicts also made row drags feel finicky:
- The drawer's horizontal dismiss gesture (`useHorizontalDismissDrag`,
restored in #2805) never checked whether another handler had claimed the
touch. A sideways row drag therefore slid the sidebar closed under the
chip and dismissed it on release.
- Between arming (a 6 px hold tolerance) and starting the drag (12 px of
movement), the sensor did not cancel touchmoves, so native list
scrolling could start alongside the drag.

## What changed

- `plugins/thread-list/app/dnd/sidebarTouchSensor.ts`: attach the
move/end/cancel listeners to the touch target instead of `document`.
Once a row is armed, `preventDefault` every touchmove, not only after
the drag starts. Wrap `onStart` in `flushSync` so dnd-kit commits the
active drag before a release in the same task can arrive.
- `apps/app/src/components/ui/use-horizontal-dismiss-drag.ts`: before a
dismiss drag begins, a `defaultPrevented` touchmove abandons the
session, the same way a native text selection already does. This affects
the mobile sidebar and the compact secondary panel shelf.

## How you verified

- New tests that fail before and pass after:
- `sidebarTouchSensor.test.tsx`: the drag ends when the touched row
remounts mid-drag, and a later touch is not hijacked;
  - `sidebarTouchSensor.test.tsx`: an armed hold claims touchmoves;
- `sidebarTouchSensor.test.tsx`: a drag whose move and release are
dispatched in the same task, outside `act`, still reports `onDragEnd`;
- `sidebar.test.tsx`: the drawer stays open when a row gesture claims
the swipe's touchmoves.
- `pnpm exec turbo run typecheck test lint
--filter=bb-plugin-thread-list` (482 tests), plus `pnpm exec turbo run
typecheck lint --filter=@bb/app` and the `@bb/app` tests under
`src/components/{ui,sidebar,secondary-panel}` (1352 tests).
- Manual QA on `pnpm dev` in headless Chrome at 390×844 with touch
emulation and CDP `Input.dispatchTouchEvent`:
- before the fix, pinning the held thread through the API mid-drag left
the chip stuck; the next tap on another thread did not navigate and
nested the dragged thread under a different one;
- after the fix, the same sequence clears the chip on release, and the
next tap navigates and closes the drawer;
- before the fix, a long-press then sideways drag closed the drawer;
after it, the drawer stays open.
- The `flushSync` half was verified separately in Chromium on an
isolated dev build. A hold, quick slide and release previously left the
row stuck; with the fix, the drag ends about 20 ms after release. That
build had the listener change and `flushSync` but not the scroll or
drawer changes.
- Not tested on iOS Safari or the iOS app.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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