Skip to content

Restore compact sizing, search debounce, and label collapse in the plugin branch pickers - #4062

Merged
ymichael merged 4 commits into
mainfrom
bb/check-worktree-responsiveness-regression-thr_q4upmga6w5
Sep 22, 2026
Merged

ymichael merged 4 commits into
mainfrom
bb/check-worktree-responsiveness-regression-thr_q4upmga6w5

Conversation

@ymichael

@ymichael ymichael commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When environment selection moved into plugins (#3227 for project checkout, #3932 for
worktrees), both branch pickers stopped rendering through BranchPicker and silently
dropped behavior that component still implements. Three regressions followed, all
confirmed by driving the pickers in a dev app at 1440×900, 470×844 and 390×844:

  1. Compact drawer height. plugins/environment-git-worktree/app.tsx pinned the
    option list with an unconditional h-80, so the compact drawer measured a flat
    390 × 399 in every state — 399 px of sheet for two rows. Every other branch picker
    uses min-h-0 max-h-[60vh] … md:max-h-80, which sizes to content below md.
  2. Search debounce. Both plugins pass useDeferredValue(query) straight into
    experimental_useBranches, which is not a debounce. Typing feature issued 7
    GET /api/v1/projects/:id/branch-options requests — 7 host round trips running
    git branch. BranchPicker debounces the same query at 120 ms.
  3. Trigger label. The worktree chip rendered Branch from: main in one span
    instead of marking the prefix data-promptbox-hide-compact. In a promptbox under
    30 rem the prefix is supposed to disappear; instead it consumed the chip, which read
    Branch from: ... at 470 px and Branc... at 390 px, hiding the branch entirely.

What changed

  • plugins/environment-git-worktree/app.tsx — option list h-80 → md:h-80, so the
    compact drawer sizes to content while the desktop popover keeps the stable 288 × 367
    dimensions Support existing worktree selection and separate branch picker policy #3932 introduced. The trigger renders prefix and value as separate spans,
    the prefix carrying data-promptbox-hide-compact and the value the usual emphasis,
    matching the project-checkout chip.

  • apps/app/src/hooks/queries/branch-search-debounce.ts (new),
    project-queries.ts, environment-queries.ts — the debounce now lives in the two
    hooks that own branch requests, useProjectSourceBranches and
    useEnvironmentMergeBaseBranches, behind a shared useDebouncedBranchSearchQuery.
    A component holding this policy is what let the regression happen: callers that
    stopped rendering BranchPicker silently started hitting the host per keystroke.
    At the query boundary no caller can forget it, and the first render is still
    immediate — only changes wait.

  • apps/app/src/components/pickers/BranchPicker.tsx — drops its own debounce and
    reports search queries to consumers as they are typed; both consumers feed them
    back into the hooks above. Callers keep filtering cached results off the immediate
    query, so lists still narrow on each keystroke.

  • packages/plugin-sdk/src/app-contract.ts, docs/api_to_audit.md — record that
    experimental_useBranches debounces query, since that decides whether a plugin
    should debounce its own search input. No plugin source changed: the plugins never
    held the debounce, they call experimental_useBranches and the implementation is
    app-side, so nothing needs rebuilding against a new SDK.

No wire, CLI, or configuration changes, and no new public plugin API members.

How you verified

Measured in an isolated source dev app (fixture repo: 6 branches, 2 existing
worktrees), driven through headless Chromium:

Check Before After
Worktree drawer, no search match 390 × 399 390 × 266
Worktree drawer, branches listed 390 × 399 390 × 382
Worktree drawer, 2 existing worktrees 390 × 399 390 × 284
Worktree popover, desktop 288 × 367 288 × 367
branch-options requests for 7 keystrokes, worktree 7 1
branch-options requests for 6 keystrokes, project checkout 6 1
Worktree chip at 470 px Branch from: ... main

The after values match the project-checkout picker in the same states (266 px empty,
382 px listed), and the pre-#3932 worktree picker also issued 1 request for 7
keystrokes.

Tests:

  • usePluginBranchPickerState.test.tsx and environment-queries.test.tsx — new
    debounce tests for both request paths; with the debounce removed they fail with 8
    and 5 requests instead of 2.
  • plugins/environment-git-worktree/app.test.tsx — new compact-prefix test asserting
    the prefix span carries data-promptbox-hide-compact and the value does not; the
    existing chip assertions move to the split-span text.
  • pnpm exec turbo run test typecheck --filter=bb-plugin-environment-git-worktree —
    96 tests, 5 files, typecheck clean.
  • pnpm exec turbo run test --filter=@bb/app -- src/components/plugin src/components/pickers src/components/secondary-panel/git-diff src/hooks/queries — 850 tests across the pickers, plugin bridge, git-diff panel, and query hooks.
  • pnpm exec turbo run typecheck lint --filter=@bb/app — clean.

Not covered: headless Chromium only, so the WebKit/iOS-Simulator drawer checks the UI
guidance asks for were not run, and the full repository suite was not run. The
merge-base picker's debounce is covered by the new environment-queries test rather
than a live measurement. Unrelated
and untouched: branch-picker drawers have no bottom safe-area inset because
BRANCH_PICKER_CONTENT_CLASS_NAME's p-0 overrides the drawer padding, which has been
true since #325 for all three pickers.

AGENT GENERATED

ymichael and others added 4 commits September 22, 2026 10:44
…ugin branch pickers

The worktree and project-checkout branch pickers left the shared BranchPicker
when environment selection moved into plugins, and each lost behavior the shared
component still implements.

- Size the worktree option list to its content below md, so the compact drawer
  no longer renders a fixed 320px list for two rows.
- Debounce the query usePluginBranches sends to the branches endpoint, so typing
  costs one host round trip instead of one per keystroke.
- Split the worktree trigger label into prefix and value, marking the prefix
  compact-collapsible so a narrow promptbox shows the branch instead of
  "Branch from: ...".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The 120ms search debounce lived in BranchPicker and, after the previous
commit, in usePluginBranches. That is the shape that let the regression
happen: the policy sat in a component, so callers that stopped rendering it
silently started hitting the host on every keystroke.

Move it to the two hooks that own the branch requests,
useProjectSourceBranches and useEnvironmentMergeBaseBranches, through a
shared useDebouncedBranchSearchQuery. BranchPicker now reports search queries
to its consumers as they are typed, and no caller can forget the policy.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The hook now debounces before requesting branches, which decides whether a
plugin should debounce its own search input. Record it on the SDK contract
and in the experimental API audit entry.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The previous commit edited packages/plugin-sdk/src/app-contract.ts, which the
version-lockstep check treats as a published surface change: bundled-types ship
that comment, and the publish job never republishes an existing version.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@ymichael
ymichael force-pushed the bb/check-worktree-responsiveness-regression-thr_q4upmga6w5 branch from 0dc28e2 to 93966c1 Compare September 22, 2026 17:48
@ymichael
ymichael merged commit 127e5bc into main Sep 22, 2026
16 checks passed
@ymichael
ymichael deleted the bb/check-worktree-responsiveness-regression-thr_q4upmga6w5 branch September 22, 2026 18:03
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