Skip to content

Require a deliberate long press to reorder sidebar threads - #4329

Merged
ymichael merged 8 commits into
mainfrom
bb/investigate-and-reproduce-github-issue-thr_qmsxi4xt8e
Sep 25, 2026
Merged

ymichael merged 8 commits into
mainfrom
bb/investigate-and-reproduce-github-issue-thr_qmsxi4xt8e

Conversation

@ymichael

@ymichael ymichael commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The Thread List's touch sensor activated a drag after a 200 ms hold with up to 6 px of drift. A slightly slow tap on a pinned row could then unpin it if released over another section. The compact actions menu also had its own long-press timer and could appear during a drag. See issue #4281 and its reproduction report.

What changed

A touch on the thread row now arms reordering after a 500 ms hold and shows the matching compact drag chip under the finger. Drag starts after 12 px of deliberate movement. Movement over 6 px before the hold cancels the pending drag, preserving scrolling. Releasing an armed hold without moving opens the thread without changing its pin or order. A stationary hold can still open the actions menu; if movement starts a drag, that menu closes and cannot reopen during the drag. The same menu dismissal applies in compact and desktop context menus. Mouse and keyboard reorder paths remain unchanged. No wire, CLI, or configuration contracts changed.

How you verified

  • pnpm exec turbo run typecheck test --filter=bb-plugin-thread-list: passed, 439 tests. Touch tests exercise short hold, armed drag chip, release with navigation, and armed movement; menu tests cover pending and already open actions menus.
  • pnpm exec turbo run lint --filter=bb-plugin-thread-list: passed with warnings, including two new React effect warnings for menu dismissal.
  • In an isolated optimized app at a 390 × 844 coarse-pointer viewport, a 230 ms hold with 4 px drift opened the pinned thread without dragging. A stationary 800 ms hold opened the actions menu without dragging. Moving 16 px while still pressed started dragging and closed the menu. The QA fixture was restored after deliberate drag testing.
  • git diff --check: passed.

Fixes #4281

AGENT GENERATED

@ymichael ymichael changed the title Require a touch handle to reorder sidebar threads Require a deliberate long press to reorder sidebar threads Sep 25, 2026
@ymichael
ymichael merged commit 129c2a9 into main Sep 25, 2026
18 checks passed
@ymichael
ymichael deleted the bb/investigate-and-reproduce-github-issue-thr_qmsxi4xt8e branch September 25, 2026 06:29
ymichael added a commit that referenced this pull request Oct 9, 2026
…5275)

## Human comments

## What was wrong

When the sidebar row layer moved into the thread-list plugin (#4036),
about seventeen components were copied instead of moved. The app and the
plugin each kept a copy, and the copies drifted: different touch delays,
a release-click fix only in the app, extra rename features only in the
plugin, and a fourth confirm dialog in the tasks plugin. Separately,
bb's core `sidebar.collapsed*` UI preferences were left behind when the
plugin migrated its own preferences. The app kept writing all six, only
`sidebar.collapsedThreads` still had a reader (mobile recents), and that
made recents' collapse state sync across devices by accident.

## What changed

Three commits. Each component now has one home, placed by the rule now
written down in `docs/forkable-plugins.md` ("What belongs in
shared-ui"):

1. **Shared presentation primitives go to `packages/shared-ui` and the
plugin registry.** These are `use-dialog-state`,
`use-drag-click-suppression`, `use-reorder-dnd`,
`use-sidebar-reorder-dnd`, `sortable-motion`, `compact-long-press-menu`,
`action-menu-items`, `confirm-delete-dialog`, `rename-dialog`,
`inline-rename`, `inline-rename-editor`, `sidebar-visibility-customize`,
`sidebar-customize-panel`, `sidebar-row-classes`,
`sidebar-hover-actions`, `context-selection` and
`thread-list-empty-state`. Where the app and the plugin need different
behaviour, the difference is a prop:
- Each side passes its own touch sensor: the app's drawer-aware one, and
the plugin's 500 ms long-press one from #4329.
   - The app renders the inline rename editor through its lazy split.
   - `MachineRenameDialog` uses the shared `RenameDialog` shell.
- The tasks plugin's `ConfirmDialog` is replaced by
`ConfirmDeleteDialog`, which gains `className`, `size` and
`confirmDisabled` props.
2. **The thread status glyph is host-rendered through the SDK.** The app
still draws the glyph in the palette, related threads and mobile
recents, so the host now exposes it as `experimental_ThreadStatusGlyph`
(`indicator`, `archived`, `rowStatus`, `hideIdleDraftLabel`, `size`),
and the plugin deletes its copy. The plugin still resolves the indicator
itself, which lets it fold in collapsed children and drafts.
- The SDK test fake exposes the requested indicator as data attributes.
- Glyph rendering tests moved to the app's `ThreadStatusGlyph.test.tsx`.
   - SDK bumped to 0.6.36; the thread-list SDK floor is now 0.6.36.
- Added an `api_to_audit.md` entry and the Plugin Guide surface symbols.
3. **Mobile recents keeps its collapse state on the device.** It is
stored in local storage under `bb.mobileRecents.collapsedThreads`.
`useMobileRecentsThreadReveal` replaces the app's sidebar reveal hook
and keeps the one behaviour recents used: navigating to a thread, or a
thread becoming unread, opens its collapsed ancestors. The six
`sidebar.collapsed*` keys leave the UI preference registry, the demo
server and `docs/configuration.md`. The server already ignores stored
rows for unknown keys. The thread-list migration no longer reads them.

No server/daemon wire changes. Net −1,769 non-test lines (+399 generated
registry JSON).

**User-visible differences:**
- The plugin's long-press menus now swallow the click that follows a
long press (#4813), as the app's already did.
- `MachineRenameDialog` now returns focus to the opener after closing.
- Tasks confirm dialogs clear their content while closing.
- Mobile recents collapse no longer syncs across devices, and starts
expanded once per device.
- An install that has not started bb since 2026-09-21 loses its old
sidebar collapse state.

## How you verified

Ran with `pnpm exec turbo run typecheck lint test` on the touched
packages:

| Package | Tests |
|---|---|
| app | 5,640 |
| thread-list | 451 |
| tasks | 412 |
| db | 615 |
| client-core | 279 |
| domain | 220 |
| plugin-sdk | 368 |
| plugin-build | 165 |
| plugin-api-docs | 73 |
| demo-server | 15 |
| plugin-registry | 1 |

All pass. The server UI preferences test file also passes (18 tests).

- **Lint:** 0 errors.
- **Typecheck:** clean, except one error that already fails on main from
#5098 (`lazySecondaryPanelComponents.tsx:287`), in a file this PR does
not touch.
- **Fork check:** `pnpm check:plugin-forks plugins/thread-list
plugins/tasks` passes.
- **SDK version guard:** `check-plugin-sdk-version.mjs` passes.

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

> AGENT GENERATED

---------

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

Mobile: slight touch drift on a pinned thread can unpin it

1 participant