Repository navigation
Restore mobile sidebar swipe dismissal - #2805
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Reported directly; no linked GitHub issue.