← reports

#5203 · Panel tab clicks activate unintended drags

Bug Priority: Medium Effort: Low ui · GitHub issue · October 8, 2026

Trusted base: f135a001e72942cee9118d2693208ec0725e2f18 (origin/main).

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

Panel tab selection and tab closing can be mistaken for dragging. A real rendered tab-strip/container reproduction shows that 5 pixels of movement suppresses selection, 8 pixels of vertical movement creates a second panel pane, and a close-button press with 16 pixels of vertical movement also creates a pane instead of closing. Sortable reordering starts above 4 pixels, while an independent panel-splitting recognizer starts above 7 pixels. The close button blocks mouse and touch-start bubbling but not pointer-down bubbling, so the splitting recognizer starts from the close affordance. The same test reproduces the failures in a second clean trusted checkout; an intentional tab drag remains functional.

2. Claims vs findings

Claim testedFindingEvidence
Small movement while clicking a tab can prevent selecting it.VerifiedAt 5 pixels vertically, onSelect is never called: the real MouseSensor activates and consumes the click.
A tab click can create another pane.VerifiedAt 8 pixels vertically, a real rendered resize separator appears: actual count 1, expected 0.
A close-button gesture can move the tab into another pane.Verified at the tab/pane boundaryAt 16 pixels vertically, onClose is not called and a separator appears. The actual close button, tab strip, split container, and split session all run.
Changing only the sortable activation constraint addresses pane creation.Refuted as a complete explanationThe splitting path has its own 7-pixel threshold and receives pointer-down from the close button.
Reporter-specific hardware and preferred sensitivity.UnverifiedNo hardware trace is available. DOM event sequences establish the mechanism, not a preferred personal setting.

3. Environment

4. Minimal reproduction

  1. In a fresh trusted clone, check out the recorded base:
    git fetch origin main
    git checkout --detach f135a001e72942cee9118d2693208ec0725e2f18
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
  2. Save the full test below as apps/app/src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx.
  3. Run:
    pnpm exec turbo run test --filter=@bb/app -- src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx
  4. Expected: selection survives 5- and 8-pixel jitter, close gestures do not split, and a deliberate 16-pixel tab drag still splits. Actual: three regressions fail and the deliberate-drag control passes.
       × selects a tab instead of splitting or suppressing the click after 5px of jitter 325ms
       × selects a tab instead of splitting or suppressing the click after 8px of jitter 70ms
       × closes a tab instead of splitting when the close press moves vertically 64ms
       ✓ still splits a tab after an intentional vertical drag 60ms
    ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
     FAIL  |@bb/app:isolated| src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx > selects a tab instead of splitting or suppressing the click after 5px of jitter
    AssertionError: expected "vi.fn()" to be called with arguments: [ 'tab-b' ]
    Number of calls: 0
     FAIL  |@bb/app:isolated| src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx > selects a tab instead of splitting or suppressing the click after 8px of jitter
    AssertionError: expected [ …(1) ] to have a length of +0 but got 1
     FAIL  |@bb/app:isolated| src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx > closes a tab instead of splitting when the close press moves vertically
    AssertionError: expected [ …(1) ] to have a length of +0 but got 1
     Test Files  1 failed (1)
          Tests  3 failed | 1 passed (4)
       Duration  17.45s (transform 14.77s, setup 1.89s, import 14.12s, tests 520ms, environment 705ms)

The fixture uses host-file-preview descriptors and real rendered controls without reading files. Closing is observed at the onClose callback boundary, not real file deletion: closing a viewer tab does not delete the file.

Complete copy-paste regression test
// @vitest-environment jsdom

import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { TooltipProvider } from "@bb/shared-ui/tooltip";
import { useState } from "react";
import { afterEach, expect, it, vi } from "vitest";
import { SidebarProvider } from "@/components/ui/sidebar";
import { SecondaryPanelTabStrip } from "./SecondaryPanelTabStrip";
import { SidebarSplitContainer } from "./SidebarSplitContainer";

const descriptors = [
  { id: "tab-a", label: "alpha.ts", restoresPlacementAfterRemoval: true },
  { id: "tab-b", label: "beta.ts", restoresPlacementAfterRemoval: true },
];
const originalHitTest = Object.getOwnPropertyDescriptor(
  document,
  "elementsFromPoint",
);

afterEach(() => {
  fireEvent(window, new MouseEvent("pointercancel"));
  cleanup();
  window.localStorage.clear();
  vi.restoreAllMocks();
  if (originalHitTest) {
    Object.defineProperty(document, "elementsFromPoint", originalHitTest);
  } else {
    Reflect.deleteProperty(document, "elementsFromPoint");
  }
});

function renderTabs() {
  const onClose = vi.fn();
  const onSelect = vi.fn();
  const onReorder = vi.fn();

  function Harness() {
    const [activeTabId, setActiveTabId] = useState("tab-a");
    return (
      <SidebarProvider>
        <TooltipProvider>
          <aside>
            <SidebarSplitContainer
              activeTabId={activeTabId}
              isFullScreen={false}
              onActivateTab={setActiveTabId}
              onGlobalTabReorder={onReorder}
              onToggleFullScreen={() => {}}
              panelStateId="tab-gesture-regression"
              tabs={descriptors}
              renderPane={({
                group,
                onBeginTabDrag,
                onReorderTab,
                onSelectTab,
              }) => (
                <section>
                  <div data-testid="thread-secondary-panel-top-chrome">
                    <SecondaryPanelTabStrip
                      activeTabId={group.activeTabId}
                      tabs={descriptors
                        .filter((tab) => group.tabIds.includes(tab.id))
                        .map((tab) => ({
                          label: tab.label,
                          leadingVisual: null,
                          statusLabel: null,
                          onClose: () => onClose(tab.id),
                          onSelect: () => {
                            onSelect(tab.id);
                            onSelectTab(tab.id);
                          },
                          renderContent: () => null,
                          tab: {
                            id: tab.id,
                            kind: "host-file-preview" as const,
                            environmentId: null,
                            hostId: null,
                            lineRange: null,
                            path: tab.label,
                            threadId: null,
                          },
                        }))}
                      onBeginTabDrag={onBeginTabDrag}
                      onReorderTab={onReorderTab}
                      usesDesktopChrome={false}
                      isPanelOpen
                    />
                  </div>
                  <p>{group.activeTabId}</p>
                </section>
              )}
            />
          </aside>
        </TooltipProvider>
      </SidebarProvider>
    );
  }

  render(<Harness />);
  Object.defineProperty(document, "elementsFromPoint", {
    configurable: true,
    value: () => [],
  });
  vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
    function (this: HTMLElement) {
      return new DOMRect(
        0,
        0,
        600,
        this.dataset.testid === "thread-secondary-panel-top-chrome" ? 40 : 400,
      );
    },
  );
  return { onClose, onSelect, onReorder };
}

function gesture(target: HTMLElement, deltaY: number) {
  fireEvent(
    target,
    new MouseEvent("pointerdown", {
      bubbles: true,
      button: 0,
      clientX: 100,
      clientY: 20,
    }),
  );
  fireEvent.mouseDown(target, { button: 0, clientX: 100, clientY: 20 });
  fireEvent(
    window,
    new MouseEvent("pointermove", {
      bubbles: true,
      clientX: 100,
      clientY: 20 + deltaY,
    }),
  );
  fireEvent.mouseMove(document, { clientX: 100, clientY: 20 + deltaY });
  fireEvent(window, new MouseEvent("pointerup", { bubbles: true }));
  fireEvent.mouseUp(document);
  fireEvent.click(target);
}

it.each([5, 8])(
  "selects a tab instead of splitting or suppressing the click after %spx of jitter",
  (distance) => {
    const { onSelect, onReorder } = renderTabs();
    gesture(
      screen.getByRole("button", { name: "beta.ts" }),
      distance,
    );
    expect(screen.queryAllByRole("separator")).toHaveLength(0);
    expect(onSelect).toHaveBeenCalledWith("tab-b");
    expect(onReorder).not.toHaveBeenCalled();
  },
);

it("closes a tab instead of splitting when the close press moves vertically", () => {
  const { onClose } = renderTabs();
  gesture(screen.getByRole("button", { name: "Close beta.ts" }), 16);
  expect(screen.queryAllByRole("separator")).toHaveLength(0);
  expect(onClose).toHaveBeenCalledWith("tab-b");
});

it("still splits a tab after an intentional vertical drag", () => {
  const { onSelect, onClose } = renderTabs();
  gesture(screen.getByRole("button", { name: "beta.ts" }), 16);
  expect(screen.getAllByRole("separator")).toHaveLength(1);
  expect(onSelect).not.toHaveBeenCalled();
  expect(onClose).not.toHaveBeenCalled();
});

Visual-check limitation: BB Browser Automation was attempted on the explicit local host but no Chrome/Chromium executable is installed. It returned “Install Chrome/Chromium on this host or link its executable at the plugin data runtime/chrome path.” No full-application screenshot, desktop, mobile, or hardware check is claimed. No dependency was installed or image fabricated.

5. Root cause

  1. Sortable activation is 4 pixels. dnd-kit's real MouseSensor starts above that threshold and installs capture-phase click suppression; the app also suppresses clicks during drag.
  2. The tab wrapper pointer-down handler forwards all pointer-down events to onBeginTabDrag, including ones bubbling from the close button.
  3. Close-button event handlers stop mouse-down and touch-start only. Pointer-down is a separate, earlier event; stopping mouse-down cannot undo the already-started split session.
  4. The split gesture owner uses its own 7-pixel activation constant and engages for predominantly vertical movement or movement outside the header. It accepts close-origin presses.
  5. Pointer-move engagement resolves an edge zone using the real target/fallback. On release, the split session swallows the next click and calls onDrop. The container moves the tab into a new pane, causing both the missing callback and new separator.

The two activation thresholds are independent. Changing the sortable sensor alone cannot repair close-event leakage or accidental splitting.

6. Proposed fix

Stay within panel tab gestures. Reuse the existing 8-pixel mouse-activation convention used by useReorderDnd, sharing that internal distance between tab sorting and splitting. Exclude pointer-down originating within [data-tab-pill-close] at the tab-strip gesture boundary. Preserve deliberate dragging, touch hold/delay behavior, fixed tabs, stored layout format, SDK, and wire contracts. No new setting or dependency is necessary.

The regression must fail before and pass after the repair. Existing tab-strip, split-container, layout, and split-session tests must also pass. A personal sensitivity setting would be a separate product decision, not part of this contained fix.

7. Verification

The same agent repeats the reproduction in a second newly created detached worktree at f135a001e72942cee9118d2693208ec0725e2f18, with a separate frozen install and full Turbo build. Its production code is clean and unchanged; only the same regression source is copied. The identical Turbo command executes rather than replaying a cached test.

   × selects a tab instead of splitting or suppressing the click after 5px of jitter 315ms
   × selects a tab instead of splitting or suppressing the click after 8px of jitter 79ms
   × closes a tab instead of splitting when the close press moves vertically 61ms
   ✓ still splits a tab after an intentional vertical drag 54ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
 FAIL  |@bb/app:isolated| src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx > selects a tab instead of splitting or suppressing the click after 5px of jitter
AssertionError: expected "vi.fn()" to be called with arguments: [ 'tab-b' ]
Number of calls: 0
 FAIL  |@bb/app:isolated| src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx > selects a tab instead of splitting or suppressing the click after 8px of jitter
AssertionError: expected [ …(1) ] to have a length of +0 but got 1
 Test Files  1 failed (1)
      Tests  3 failed | 1 passed (4)
   Duration  16.87s (transform 14.37s, setup 1.80s, import 13.64s, tests 511ms, environment 705ms)
 FAIL  |@bb/app:isolated| src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx > closes a tab instead of splitting when the close press moves vertically
AssertionError: expected [ …(1) ] to have a length of +0 but got 1

Result: the same three intended assertion failures, and the same passing deliberate-drag control. Typecheck later found an unsupported Testing Library query option in the fixture; it was removed without changing query behavior, then the clean baseline and post-fix checks were repeated. The verdict and root cause are unchanged. This is repeated verification by the same agent, not independent verification.

The contained production repair passes all four regression cases, plus 102 tests across eight relevant existing/regression suites. Turbo lint and typecheck pass; lint reports existing warnings and no errors. The fix excludes close-button pointer-down and shares an 8-pixel activation distance, matching the application's existing general mouse reorder convention.

8. Pull requests and related issues

No linked open pull request appears in the connected/cross-referenced issue timeline, and the open-PR search for the issue number returns no result at review time. No pull-request branch is executed. Related #2450 and #3527 cover other panel/tab-close behavior, not this gesture-recognition failure.

9. Appendix

Commands below replace temporary checkout identifiers and the local host ID with placeholders. Source inspection, git blame, dependency-source inspection, and both focused test runs support the mechanism.

git fetch origin main
git rev-parse origin/main
git worktree add --detach /tmp/FIRST-CHECKOUT f135a001e72942cee9118d2693208ec0725e2f18
git worktree add --detach /tmp/SECOND-CHECKOUT f135a001e72942cee9118d2693208ec0725e2f18
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run test --filter=@bb/app -- src/components/secondary-panel/SidebarSplitContainer.tab-gestures.test.tsx
git blame -L 66,66 -- apps/app/src/components/secondary-panel/SidebarSplitContainer.tsx
git blame -L 158,161 -- apps/app/src/components/secondary-panel/SecondaryPanelTabStrip.tsx
bb browser-automation open --backend local --headless --machine HOST --json
.bb/skills/verify-bb/scripts/inventory.py

The read-only inventory check reports existing unrelated drift: “Unmapped CLI family: browser; add recipes and an explicit owner.” It is not evidence of the gesture bug and was not changed. The full-app “Open, close, and reopen tabs” and “Split and focus panes” browser recipes are blocked by the missing browser; real rendered component-boundary tests provide the direct reproduction instead.

Issue contents were treated only as untrusted claims. No issue-provided instruction, URL, script, patch, or linked branch was run.

> AGENT GENERATED