Repository navigation
Keep mobile sidebar drags from sticking or fighting the drawer - #6469
Merged
Merged
Conversation
The thread list's touch sensor listened for touchmove/touchend on the document. When the held row remounted mid-drag (an agent spawning a child under it, a pin from another client), the touch's remaining events went to the detached element and never bubbled, so the drag overlay stayed on screen and the next tap anywhere ended the stale drag as a drop. Listen on the touch target, as dnd-kit's TouchSensor does. Once a row is armed, claim every touchmove so native scrolling cannot start alongside the drag, and have the drawer's horizontal dismiss gesture skip moves another handler already claimed, so a sideways row drag no longer slides the sidebar closed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A long-press released with a quick slide fires the sensor's onStart and onEnd in the same task. dnd-kit only records the active drag in a layout effect, so its end handler saw no active drag and skipped onDragEnd while our onDragStart had already run, leaving the row dimmed and untappable. Flush the start synchronously so the end is always reported. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 16, 2026
…mounts (#7600) ## Human comments ## What was wrong On compact screens, swiping the sidebar or the right panel sometimes left it stuck partway until the next swipe. This happened when the timeline re-rendered during the swipe. Touch events always go to the element the touch started on, even after it has been removed from the page, and a removed element no longer passes them on to `window`. The swipe code listened for the rest of the gesture (`touchmove`, `touchend`, and the pointer equivalents) only on `window`. So when a re-render remounted the touched element, the swipe stopped receiving events and never finished. `recoverInterruptedMobileSwipe` reset it on the next touch, which is why another swipe got it unstuck. #6469 fixed the same problem for sidebar row drags. ## What changed - `gesture-dom.ts`: a new `listenToGesture(origin, type, listener, options)` listens on both `window` and the element the gesture started on, and calls the listener once even when the same event reaches both. - `sidebar.tsx`: the swipe that opens the sidebar uses it for both touch and pointer input. - `use-horizontal-dismiss-drag.ts`: uses it for both touch and pointer input. This covers dragging the sidebar drawer closed and both right-panel drags (open and close). ## How you verified - New tests: `sidebar.test.tsx` covers a touch and a pointer swipe whose touched element remounts mid-drag. `CompactSecondaryPanelShelf.test.tsx` covers opening and closing the right panel the same way. All four fail without the source change and pass with it. - `pnpm exec turbo run test --filter=@bb/app -- src/components/ui src/components/secondary-panel src/components/sidebar` passed: 1379 tests in 125 files. - `pnpm exec turbo run typecheck lint --filter=@bb/app` passed. - Manual check on a `pnpm start:worktree` build, comparing it with `main`'s app bundle on the same server and data. I used headless Chrome as a touch phone and sent real touches over the Chrome DevTools Protocol. Partway through each swipe I swapped the touched element for a copy, which is what a remount does. Results after lifting the finger: | Case | Sizes | `main` | This branch | |---|---|---|---| | Swipe right to open the sidebar | 390×844, 360×780, 744×1133 | stuck 110px across | opens fully | | Swipe left to open the right panel | same three | stuck at −90px, panel stays closed | opens fully | | Drag a sidebar row left to close the sidebar | 390×844 | stuck 255px across | closes | | Drag right inside the right panel to close it | 390×844 | stays open with a −270px offset on the page behind | closes | | Normal swipe, nothing remounted (control) | 390×844 | opens fully | — | - Not tested: a physical device, iOS Simulator Safari, and the native mobile shell. > 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
Since #4329 replaced dnd-kit's
TouchSensorwith the custom long-pressSidebarTouchSensor, the sensor listened fortouchmove/touchend/touchcancelondocument. 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 todocument. 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: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
onStartandonEndin the same task. dnd-kit records the active drag insensorContextonly in a layout effect. Its end handler therefore sees no active drag and skipsonDragEnd/onDragCancel, but ouronDragStarthas already run. The row stays atopacity: 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:
useHorizontalDismissDrag, restored in Restore mobile sidebar swipe dismissal #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.What changed
plugins/thread-list/app/dnd/sidebarTouchSensor.ts: attach the move/end/cancel listeners to the touch target instead ofdocument. Once a row is armed,preventDefaultevery touchmove, not only after the drag starts. WraponStartinflushSyncso 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, adefaultPreventedtouchmove 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
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, outsideact, still reportsonDragEnd;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), pluspnpm exec turbo run typecheck lint --filter=@bb/appand the@bb/apptests undersrc/components/{ui,sidebar,secondary-panel}(1352 tests).pnpm devin headless Chrome at 390×844 with touch emulation and CDPInput.dispatchTouchEvent:flushSynchalf 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 andflushSyncbut not the scroll or drawer changes.🤖 Generated with Claude Code