Skip to content

feat: drag to reorder the new tab Actions list - #2982

Merged
SawyerHood merged 3 commits into
get-bb:mainfrom
nlorio-notion:nlorio--FEAT-drag-reorder-new-tab-actions
Sep 3, 2026
Merged

SawyerHood merged 3 commits into
get-bb:mainfrom
nlorio-notion:nlorio--FEAT-drag-reorder-new-tab-actions

Conversation

@nlorio-notion

@nlorio-notion nlorio-notion commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

Context

The new tab shows an Actions list in the side panel. The list holds up to two built-in actions: Open browser and Start terminal. The list also holds one row for each action that a plugin registers. The user starts work from these rows many times each day. The sidebar already lets the user drag its sections and its plugin rows into a new order.

Problem

The Actions list used a fixed order. It showed Open browser first, then Start terminal, then the plugin actions in registration order. This order caused three problems:

  1. The user cannot move a frequent action to the top of the list.
  2. A plugin action stays below both built-in actions.
  3. The order changes when a plugin registers a new action.

Solution

Each row now has a reorder handle. The user drags the handle to move the action. The app keeps the new order for that client.

The list at rest The handle after hover
The Actions list at rest The reorder handle after the pointer moves onto the row
The row during the drag The list after the drop
The row moves and the list shows the new order The action is now the first row

The user drags the last action to the top of the list with its handle

I recorded this media from a dev app on this branch. A temporary local plugin supplies the Quickstart row and the Subagents row. That plugin registers two experimental_newThreadPanelAction slots. The list therefore holds both built-in actions and plugin actions.

The change has six parts:

  1. A new module. apps/app/src/components/secondary-panel/NewTabActions.tsx holds the Actions list. The list was in NewTabFileSearch.tsx, which has more than 1,200 lines. Both callers and both test files already imported the list as one unit.
  2. One row shape. Each action is one flat NewTabAction value with a ready icon node. Built-in rows and plugin rows use the same NewTabActionRow. The row holds the action button, the shortcut hint, the reorder handle, and the optional trailing control as siblings. LauncherTile loses the variant prop and the ariaKeyshortcuts prop, because only the action rows used them.
  3. A handle, not a whole row. The handle starts the drag. ProvidersSettingsSection and QueuedMessagesList already use a handle in the same way. A handle also gives keyboard reorder, and it keeps a click on the row unambiguous. The app hides the handle until the pointer moves onto the row, and it always shows the handle on a touch device.
  4. Shared drag behavior. The list uses the general useReorderDnd hook and the shared sortable motion. The general hook owns the sensors, drag threshold, Escape key behavior, vertical movement, and click suppression. The sidebar wrapper keeps its compact-drawer touch policy. The Actions list uses the standard touch sensor, so touch reorder works while the sidebar drawer is closed.
  5. Storage. The app writes the order to bb.newTab.actionOrder in newTabActionsAtoms.ts. This is the atomWithStorage pattern that the sidebar section order and the plugin nav order already use. The app puts a new action after the saved rows. The app also keeps the slot of an action whose plugin is absent, so the position survives a reload.
  6. Shared order helpers. apps/app/src/lib/stored-order.ts holds arrangeByStoredOrder, reorderStoredOrder, and haveSameOrder. The plugin nav sidebar already had this logic, so this change moves the logic instead of a copy. reorderStoredOrder uses arrayMove from @bb/client-core. haveSameOrder moves here from usePersistedSidebarSectionOrder. After the delegation, reorderPluginNavPanels and havePluginNavPanelOrdersDiverged only renamed arguments, so this change deletes them and the tests that only tested them.

The list keeps its cost low when the user cannot reorder it. The app orders the rows by id. The app mounts DndContext, its sensors, and the document key listener only for two or more actions. For an empty list, the component returns before this work.

Result

The user can now put the Actions rows in any order, and the app keeps that order after a reload.

Automatic checks:

  1. pnpm exec turbo run typecheck --filter=@bb/app passes after the review fixes.
  2. The 11 focused action and sidebar drag tests pass after the review fixes.
  3. pnpm exec turbo run build --filter=@bb/app passes.
  4. Lint reports 175 warnings and 0 errors. This count equals the count on main.
  5. 898 tests pass in the plugin, secondary-panel, sidebar, and settings suites.

New tests:

  1. apps/app/src/lib/stored-order.test.ts tests the fallback to registration order, a new id at the end, the kept slot of an absent id, a duplicate stored id, and the reorder and decline cases.
  2. NewTabActions.test.tsx tests saved and new actions, handle availability, compact touch setup with the sidebar closed, and invalid saved data.

Manual checks in a dev app on this branch:

  1. Move the pointer onto a row. The app shows the handle.
  2. Drag the last action to the top with its handle. The list shows the new order.
  3. Read bb.newTab.actionOrder. The value matches the new order.
  4. Reload the page. The list keeps the order.
  5. Drag the action back to the bottom. The app does not run the action.
  6. Click the row. The app runs the action.

This change does not send new data between the server and the host daemon, so it does not change HOST_DAEMON_PROTOCOL_VERSION. It also adds no CLI command and no SDK method. The sidebar section order and the plugin nav order are client-local in the same way. Tell me if you want an agent-facing surface, and I will add one.

One follow-up stays out of this change. Three call sites repeat the same check of event.over and the same string check of event.active.id: this list, PluginNavSidebarItems, and ReorderableSidebarSectionOrderList. An onReorder(activeId, overId) option on the general hook and the sidebar wrapper would remove the repeat. That option changes every reorder caller, so it needs its own change.

AGENT GENERATED

nlorio-notion and others added 2 commits September 2, 2026 19:23
## What was wrong

The new-tab launcher's Actions section rendered in a fixed order: Open
browser, Start terminal, then plugin actions in registration order. A
user whose most-used action is contributed by a plugin had no way to
bring it to the top, and the order shifted whenever plugins registered.

## What changed

- `NewTabActions` builds one descriptor list from the built-in and
  plugin actions and renders it through `DndContext`/`SortableContext`,
  reusing the sidebar reorder stack (`useSidebarReorderDnd`,
  `useSidebarSortable`) so activation thresholds, Escape-to-cancel,
  drag styling, and post-drag click suppression match the sidebar.
- The order persists per client in `bb.newTab.actionOrder`
  (`newTabActionOrderAtom`), the same `atomWithStorage` pattern the
  sidebar section order and plugin nav panel order already use.
- Extracted the ordering logic the plugin nav sidebar already had into
  `lib/stored-order.ts` (`arrangeByStoredOrder`, `reorderStoredOrder`,
  `haveStoredOrdersDiverged`) and pointed `pluginNavSidebarOrder.ts` at
  it instead of keeping a second copy. Newly registered actions append
  after saved ones; an action whose plugin is absent keeps its slot.

No CLI or SDK surface: like the sidebar section order and the plugin
nav panel order, this is client-local UI arrangement.

## How you verified

- `pnpm exec turbo run typecheck --filter=@bb/app`, `build`, and lint
  (warnings unchanged at the 175 baseline).
- New `stored-order.test.ts` plus two `NewTabActions` order tests; 805
  tests across the plugin, secondary-panel, and sidebar suites pass.
- Manually in a dev app on this branch: dragged a plugin action to the
  top, confirmed the rendered order and the stored key, reloaded and
  the order held, dragged it back, and confirmed a drag does not fire
  the action while a plain click still does.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
## What was wrong

The first pass made the whole action row the drag activator and left the
rest of the change carrying avoidable duplication: the row shell existed
in two layouts, the ordering helpers were reached through renaming
aliases, and drag bindings were threaded into `LauncherTile`, which
non-draggable file and recent rows also use.

## What changed

- Every action row is now one shell: a `NewTabActionRow` with the action
  button, the shortcut hint, a hover-revealed reorder handle, and the
  optional trailing control as siblings. The handle is the drag
  activator, matching the two handle-based reorderable lists the repo
  already has (`ProvidersSettingsSection`, `QueuedMessagesList`), so the
  grip is the real gesture target rather than a decoration and keyboard
  drag works from it.
- Moved the actions list out of the 1,200-line `NewTabFileSearch.tsx`
  into `NewTabActions.tsx`, which both callers and both test files
  already treated as its own unit. `LauncherTile` loses the `variant`
  and `ariaKeyshortcuts` props that only the action rows used.
- Actions are one flat `NewTabAction` shape with a pre-rendered `icon`,
  so built-in and plugin rows render through the same JSX instead of two
  near-identical blocks.
- Ordering is keyed on ids, and `DndContext`, its sensors, and the
  document key listener now mount only when there are at least two
  actions to order; an empty list returns before any of it.
- `reorderStoredOrder` uses `arrayMove` from `@bb/client-core` instead of
  a fourth hand-rolled splice-move, and `haveSameOrder` moved from
  `usePersistedSidebarSectionOrder` into `lib/stored-order.ts` so one
  module owns the ordering primitives.
- Deleted `reorderPluginNavPanels` and `havePluginNavPanelOrdersDiverged`,
  which had become argument renames over the shared helpers, and the
  plugin-nav order tests that only re-tested them.

## How you verified

- `pnpm exec turbo run typecheck --filter=@bb/app` passes; lint warnings
  back to the 175 baseline.
- Two new tests cover the handle: one per action once two can be ordered,
  none when a single action cannot move. 898 tests across the plugin,
  secondary-panel, sidebar, and settings suites pass.
- Manually in a dev app: hovered a row to reveal the grip, dragged the
  bottom action to the top by its handle, and confirmed the live
  reorder preview, the persisted order, and that a plain click still
  runs the action.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@SawyerHood

Copy link
Copy Markdown
Collaborator

@slopcop take a look

@bb-slop-cop

bb-slop-cop Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am the Slop Cop. I am reviewing this pull request now.

I will check security, code quality, performance, architecture, tests, and the user workflow.

},
[normalizedOrder, onOrderChange, orderedIds],
);
const { dndContextProps, onClickCapture } = useSidebarReorderDnd({

@bb-slop-cop bb-slop-cop Bot Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — High: Use a non-sidebar touch sensor here.

useSidebarReorderDnd uses SidebarTouchSensor.

On compact viewports, that sensor installs the non-passive touchmove listener only while the sidebar drawer is open.

Dnd-kit requires this listener for iOS Safari to cancel later touch moves.

This panel usually operates with the sidebar drawer closed, so touch reorder can scroll or fail.

Please extract a general reorder hook with a standard touch sensor.

Keep the drawer gate only in the sidebar wrapper.

Add a compact-viewport touch test.

export const newTabActionOrderAtom = atomWithStorage<string[]>(
NEW_TAB_ACTION_ORDER_STORAGE_KEY,
[],
createJsonLocalStorage<string[]>(),

@bb-slop-cop bb-slop-cop Bot Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Moderate: Validate the stored order before use.

createJsonLocalStorage<string[]>() checks JSON syntax but does not check the value shape.

I stored {} and opened the New Tab view.

The app stopped with TypeError: storedOrder is not iterable.

Please accept only an array of strings at this storage boundary.

Use the empty default after invalid data, and add a malformed-storage test.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain-English summary: This PR lets users reorder New Tab actions and keeps the order on their browser.

It also moves common saved-order logic into one helper.

I found one blocking touch issue and one moderate recovery issue:

  • Compact iOS touch reorder can fail because the new list uses a sidebar-only sensor policy.
  • Valid JSON with the wrong shape can crash the app until the user clears local storage.

I added inline comments with the evidence and the required fixes.

The security and performance reviews found no additional issues.

The shared order helper removes duplicate logic, but the sidebar drag hook creates incorrect architectural coupling here.

The app type check passed.

The app suite had 3,727 passing tests and one unrelated failure from a missing push-notifications/package.json file.

Browser QA passed for mouse reorder, saved order after reload, post-drag click suppression, and a later normal action click.

I reproduced the invalid-storage crash in the same browser session.

I would hold the merge until the compact touch issue is fixed.

@SawyerHood

Copy link
Copy Markdown
Collaborator

This lgtm! I'll just address the slopcop issues myself and merge! Ty for the contribution

@SawyerHood
SawyerHood merged commit 831fd0a into get-bb:main Sep 3, 2026
13 checks passed
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.

2 participants