Skip to content

Prevent accidental tab drags when clicking - #6210

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/tab-click-gesture-bug
Jun 24, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/tab-click-gesture-bug

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Raises the tab drag activation distance from 5px to a named 12px policy so small trackpad drift during a click still switches tabs instead of starting a drag.
  • Keeps the existing pointerup activation model, dnd-kit drag lifecycle, split/drop logic, webview passthrough, SSH behavior, and cross-platform pointer-event behavior unchanged.
  • Adds focused regression coverage for the enabled threshold, the old 5px sensitivity guard, and the disabled hidden-worktree sentinel.

Design / Review Pipeline

  • Design approach documented in ignored scratch doc: design-docs/tab-click-drag-threshold.md.
  • Design review: auto-design-review-fix completed clean for P0/P1 after adding ownership/data-flow detail, less brittle test guidance, and rollback criteria.
  • Implementation: matched the reviewed design with no deviations.
  • Completeness verification: read-only verifier marked implementation complete against every requirement; one verifier-local test-resolution hiccup was superseded by passing local/subagent runs.

Code Review

  • Round 1: two independent reviewers found no correctness issues. One noted the threshold test did not pin the exact 12px value.
  • Fix from review: pinned TAB_DRAG_ACTIVATION_DISTANCE_PX to 12 in the test.
  • Round 2: two fresh reviewers returned clean; only residual gap was real-device/manual trackpad feel, covered by product validation below.

Validation

  • brennan-test-changes verdict: land.
  • Product surface: launched Electron from this worktree on branch brennanb2025/tab-click-gesture-bug; verified plain tab click switched without drag state, 8px sub-threshold drift switched without reorder, and intentional drag beyond threshold still showed drag affordance and reordered.
  • SSH/cross-platform: no live SSH pass; accepted because this is renderer-local pointer classification with no runtime IPC/path/provider changes and no platform branch.

Screenshots

  • /tmp/orca-tab-drag-evidence/click-target-active.png
  • /tmp/orca-tab-drag-evidence/subthreshold-click-terminal1-active.png
  • /tmp/orca-tab-drag-evidence/intentional-drag-active.png

Checks Run

  • pnpm run typecheck
  • pnpm run lint
  • git diff --check
  • pnpm vitest run src/renderer/src/components/tab-group/useTabDragSplit.test.ts src/renderer/src/components/tab-bar/tab-strip-pointer-activation.test.tsx --config config/vitest.config.ts
  • brennan-test-changes also ran the focused tests individually.

Post-PR Stabilization

  • Completed required sleep 480 after opening the PR.
  • CodeRabbit posted no actionable comments.
  • PR checks passed: track-community-pr and verify.
  • No follow-up fix commits were needed after PR creation.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change extracts the tab-drag pointer activation distance from an inline ternary in the PointerSensor configuration into two new exports in useTabDragSplit.ts: a constant TAB_DRAG_ACTIVATION_DISTANCE_PX set to 12, and a helper function getTabDragActivationDistance(enabled) that returns the constant when enabled and Number.MAX_SAFE_INTEGER when disabled. The hook's PointerSensor now calls the helper instead of the previous enabled ? 5 : Number.MAX_SAFE_INTEGER inline expression, raising the enabled activation threshold from 5 px to 12 px. A new test block exercises both branches of the helper and pins it to TAB_DRAG_ACTIVATION_DISTANCE_PX.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: preventing accidental tab drags during clicks, which directly corresponds to the core improvement (raising activation distance from 5px to 12px).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description comprehensively covers all required template sections with detailed information about the changes, testing, validation, and review process.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit 7c99439 into main Jun 24, 2026
2 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/tab-click-gesture-bug branch June 24, 2026 04:05
nwparker added a commit that referenced this pull request Jul 3, 2026
* fix(tabs): restore deferred tab activation so dragging a terminal tab doesn't switch panes mid-gesture

PR #5927 shipped terminal-pane drag (reorder tabs, move a tab into another
pane, edge-split into a new column). It deliberately DEFERRED tab activation
to pointer-up and suppressed it during a drag, so pressing a tab to drag it
never switched the active tab or stole terminal focus mid-gesture.

PR #6395 (d32d62a) deleted tab-strip-pointer-activation.ts and made
SortableTab/EditorFileTab/BrowserTab activate eagerly on pointerdown — fixing
click-to-switch-after-reorder but regressing the drag: grabbing a tab now
flips the active tab + focused pane and yanks xterm keyboard focus before the
drag is even recognized (aggravated by PR #6210 raising the dnd-kit threshold
5px->12px). The move itself still lands, but the gesture feels broken.

Restore the deferred-activation hook, but gate it on measured pointer
DISPLACEMENT instead of the drag-active context ref the old hook used — that
ref clears asynchronously relative to the drop's pointerup, which is exactly
what made #6395's click-after-reorder misfire. Displacement mirrors dnd-kit's
own activation threshold: a release within TAB_DRAG_ACTIVATION_DISTANCE_PX is
a click (activate); crossing it is a drag (suppress). Because each press
measures its own gesture, a click after a reorder always activates.

- Recreate src/renderer/src/components/tab-bar/tab-strip-pointer-activation.ts
  (displacement-gated) + unit tests, incl. an explicit #6395 regression case.
- Rewire onPointerDown in SortableTab, EditorFileTab, BrowserTab to use it.
- BrowserTab.test.tsx shallow-renders via mocked React hooks; add useRef/
  useCallback stubs so the new hook works under that harness.

Verified end-to-end in a dev build via CDP: pressing a tab no longer
activates/steals focus on pointerdown; a click still activates on release;
dragging a tab into another pane still moves it; clicking tabs after a drag
still switches (the #6395 guard in tests/e2e/tabs.spec.ts stays green because
it uses zero-displacement clicks). 233 unit tests pass; oxlint + renderer
typecheck clean.

* fix: restore pane detach tab placement
@nwparker nwparker mentioned this pull request Jul 3, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(tabs): restore deferred tab activation so dragging a terminal tab doesn't switch panes mid-gesture

PR stablyai#5927 shipped terminal-pane drag (reorder tabs, move a tab into another
pane, edge-split into a new column). It deliberately DEFERRED tab activation
to pointer-up and suppressed it during a drag, so pressing a tab to drag it
never switched the active tab or stole terminal focus mid-gesture.

PR stablyai#6395 (04713f5) deleted tab-strip-pointer-activation.ts and made
SortableTab/EditorFileTab/BrowserTab activate eagerly on pointerdown — fixing
click-to-switch-after-reorder but regressing the drag: grabbing a tab now
flips the active tab + focused pane and yanks xterm keyboard focus before the
drag is even recognized (aggravated by PR stablyai#6210 raising the dnd-kit threshold
5px->12px). The move itself still lands, but the gesture feels broken.

Restore the deferred-activation hook, but gate it on measured pointer
DISPLACEMENT instead of the drag-active context ref the old hook used — that
ref clears asynchronously relative to the drop's pointerup, which is exactly
what made stablyai#6395's click-after-reorder misfire. Displacement mirrors dnd-kit's
own activation threshold: a release within TAB_DRAG_ACTIVATION_DISTANCE_PX is
a click (activate); crossing it is a drag (suppress). Because each press
measures its own gesture, a click after a reorder always activates.

- Recreate src/renderer/src/components/tab-bar/tab-strip-pointer-activation.ts
  (displacement-gated) + unit tests, incl. an explicit stablyai#6395 regression case.
- Rewire onPointerDown in SortableTab, EditorFileTab, BrowserTab to use it.
- BrowserTab.test.tsx shallow-renders via mocked React hooks; add useRef/
  useCallback stubs so the new hook works under that harness.

Verified end-to-end in a dev build via CDP: pressing a tab no longer
activates/steals focus on pointerdown; a click still activates on release;
dragging a tab into another pane still moves it; clicking tabs after a drag
still switches (the stablyai#6395 guard in tests/e2e/tabs.spec.ts stays green because
it uses zero-displacement clicks). 233 unit tests pass; oxlint + renderer
typecheck clean.

* fix: restore pane detach tab placement
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