Skip to content

Fix nesting worktree groups under threads - #4078

Open
ymichael wants to merge 14 commits into
mainfrom
bb/fix-dragging-threads-into-worktrees-thr_pex33uqdb4
Open

ymichael wants to merge 14 commits into
mainfrom
bb/fix-dragging-threads-into-worktrees-thr_pex33uqdb4

Conversation

@ymichael

@ymichael ymichael commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Human comments

This makes a worktree/environment group a valid thread-row drag target, supports dragging it back to a section to unparent it, makes thread nesting less finicky, gives group drags an accurate preview, and applies the whole group optimistically on drop.

What was wrong

Environment-group drags were excluded from the nest-target heuristic, so dropping a Worktree group on a thread row could never establish the requested parent relationship. After adding that path, section drops moved the group section but did not clear its root parent relationships. The heuristic also used a narrow row band, a 350 ms delay, and the dragged card edge for horizontal cancellation, making valid targets easy to miss. The group preview inherited the representative root thread's cached display title, so its floating overlay and projected child looked like one root thread. Group persistence also launched one independent optimistic transaction per root, repeatedly cancelling queries and allowing partial intermediate hierarchy states.

What changed

  • Add a nest-group drop decision that reparents only group root threads, preserving descendants and preventing cycles.
  • Add a symmetric detach-group decision that unparents only group roots while moving the represented group into the target section.
  • Widen the target band to the middle 70%, arm the full row after 200 ms, and use pointer position with 12 px left tolerance.
  • Override the representative root's cached display fields so the overlay and projected child show the group name and root count.
  • Apply synchronous group metadata changes through one cache transaction, one snapshot, and one rollback boundary before persisting the individual requests concurrently.
  • Coalesce synchronous plugin SDK thread metadata updates so the plugin-backed and built-in sidebars share the same optimistic behavior.
  • Mirror the behavior in the built-in sidebar and thread-list plugin, with focused unit coverage.
  • Add HANDOFF.md and before/after reviewer evidence for parenting, unparenting, and the corrected child preview.

How you verified

  • pnpm exec turbo run test --filter=bb-plugin-thread-list --force -- --run app/dnd/useSectionThreadDnd.test.ts app/dnd/useSectionThreadDnd.projection.test.tsx (46 passed)
  • pnpm exec turbo run typecheck --filter=bb-plugin-thread-list --force
  • pnpm exec turbo run test --filter=@bb/app --force -- --run src/hooks/mutations/thread-state-mutations.test.tsx src/lib/plugin-bound-sdk.test.ts src/components/sidebar/useSectionThreadDnd.test.ts src/components/sidebar/useSectionThreadDnd.projection.test.tsx (65 passed)
  • pnpm exec turbo run typecheck --filter=@bb/app --force
  • pnpm exec turbo run typecheck --filter=@get-bb/plugin-sdk --force
  • Source-app smoke tests: group parenting and section-drop unparenting persisted for both worktree roots, preserved the group, updated immediately, and survived reload. The overlay and projected child both show Reviewer worktree group (2 threads).
  • Delayed-network smoke: with both PATCH requests held for 30 seconds, the complete group moved immediately while zero requests had been dispatched and direct GETs still showed the old persisted parent.

Related: #3029

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/fix-dragging-threads-into-worktrees-thr_pex33uqdb4 branch from 6adf538 to c9abd55 Compare September 22, 2026 18:50

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.

1 participant