Skip to content

Drag worktree groups through the single-thread drop rules - #4219

Merged
ymichael merged 1 commit into
mainfrom
bb/unify-worktree-group-drag-rules
Sep 23, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/unify-worktree-group-drag-rules

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

#4078 made worktree groups draggable onto threads, into sections, and into and out of Pinned by adding a group copy of every drop decision (nest-group, detach-group, pin-group, unpin-group, next to move-group). Each copy had its own resolver branch, landed check, and handler, so single-thread and group drops had to be fixed twice and drifted: group drags did nothing in grouped (project/machine) mode, a group pin ignored the Pinned insert marker it displayed, and group section moves rewrote sectionId on every nested descendant even though nested threads follow their parent. A worktree group is only a display grouping, so it is really a list of top-level threads — the same thing as a single-thread drag with one entry.

What changed

plugins/thread-list/app/dnd/useSectionThreadDnd.ts (1742 → 1422 lines):

  • A dragged item resolves to its top-level threads: [thread], or a group's nodes.
  • Decisions shrink to move (covers move, detach, and unpin into a section), nest, and pin, plus the unchanged reorder-pinned/rejected/unchanged. Each carries the exact unpinThreadIds, updates, and pinThreadIds for its threads, computed per thread from its own pin and nesting state.
  • One executor applies unpin → updates → pin, toasts once if an update fails, and stops before pinning.
  • Pinned inserts chain one request per thread so a group lands together at the marker, and use the pinned thread order rather than sortable item ids. That fixes Fix nesting worktree groups under threads #4078's pinned grouping sending an environment: item id as a neighbour thread.

Behaviour changes that follow from applying one rule to both:

  • Group drags work in grouped mode, with the same rules as single threads there.
  • Group section moves write only the top-level threads.
  • Dropping a group back into its own section, or a pinned group back into Pinned, shows the "unchanged" state instead of nothing.
  • Nesting the child of a pinned thread no longer sends a redundant unpin.
  • Failure toasts read "Failed to move thread(s)." / "Failed to pin thread(s)."; "Failed to unpin and move thread." and the "worktree group" wording are gone.
  • A thread whose stored section differs from where it is displayed gets its section rewritten when dropped in its displayed section (previously treated as unchanged).

Also removes the unused useUpdateThreads hook (and its tests) from apps/app; the plugin SDK's update batching stays.

No wire, CLI, SDK, or guide changes.

How you verified

  • Rewrote the decision tests for the new shape, including group nest/move/pin/unpin, grouped mode, own-descendant rejection, the unchanged cases, chained pinned inserts, and thread neighbours next to a pinned environment group.
  • New projection test: a group whose un-parenting fails is not pinned. It fails when the executor keeps going after a failed update.
  • pnpm exec turbo run typecheck lint test --filter=bb-plugin-thread-list --filter=@bb/app passes (thread-list 434 tests; app 5059 passed, 5 skipped).
  • Rebuilt and ran pnpm start:worktree from this change for manual testing.

AGENT GENERATED

🤖 Generated with Claude Code

A dragged item now resolves to its top-level threads (one thread, or a
worktree group's roots), and move, nest and pin decisions carry the exact
unpin, update and pin changes for that list. One executor applies them, so
the parallel group decision kinds and handlers are gone. Pinned inserts use
thread neighbours and keep a group's threads together, and the unused
useUpdateThreads hook is removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@ymichael
ymichael merged commit 53d7102 into main Sep 23, 2026
40 of 42 checks passed
@ymichael
ymichael deleted the bb/unify-worktree-group-drag-rules branch September 23, 2026 21:54
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