Repository navigation
fix(sidebar): stop a missed pointerup from hiding a remote host section - #19032
Conversation
Clicking a host header arms a drag session on pointerdown, but the window pointermove/pointerup listeners attach from an effect gated on that state -- a render and a paint later. On a heavy sidebar a quick click's pointerup can land inside that window and never be seen, so the session survives the click and the next bare mouse move clears the 4px threshold and promotes a drag the user is not doing. The host tier is the only header that hides itself while dragging (opacity-0, plus forceCollapseHosts on every section), so the host the user just collapsed vanishes outright. It only returns on a stray later pointerup or when the viewport remounts -- which is why toggling the host filter fixes it: the viewport's React key includes visibleWorkspaceHostIds. Treat a pointermove with no button held as a released pointer and end the session instead of promoting. The repo and project-group header drags share the race, where it commits an unintended reorder on the next click, so they get the same guard. Extracting their duplicated click-swallow block keeps project-header-drag.ts under the max-lines ceiling.
📝 WalkthroughWalkthroughThe change adds shared helpers for pointer-release detection and drag-handle click suppression. Host, project-group, and project header drag hooks use these helpers to cancel stale drag sessions and suppress post-drag clicks. New tests cover missed pointer releases, button-less pointer movement, and drag promotion while the pointer remains down. Merge Risk: 🟡 Moderate · up to Stale drag recovery can leave a sidebar header click suppressed after a promoted drag, making a later header interaction appear unresponsive. This should be corrected before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the bug, root cause, fix, scope, and automated verification. However, it omits several required template sections, including ELI5, What Changed, Why, Linked Issue with a Resolution Add the required template sections and complete them. Include a linked issue using
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 0e09ea3f-3888-47ea-b4b8-9d2cac39a3ff
📒 Files selected for processing (6)
src/renderer/src/components/sidebar/header-drag-click-swallow.tssrc/renderer/src/components/sidebar/header-drag-pointer-release.tssrc/renderer/src/components/sidebar/host-header-drag.test.tsxsrc/renderer/src/components/sidebar/host-header-drag.tssrc/renderer/src/components/sidebar/project-group-header-drag.tssrc/renderer/src/components/sidebar/project-header-drag.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| if (hasPointerBeenReleased(event)) { | ||
| endDrag(false) | ||
| return | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- project-group-header-drag.ts ---'
sed -n '1,280p' src/renderer/src/components/sidebar/project-group-header-drag.ts
printf '%s\n' '--- project-header-drag.ts ---'
sed -n '1,300p' src/renderer/src/components/sidebar/project-header-drag.ts
printf '%s\n' '--- related tests and references ---'
rg -n --glob '*.{ts,tsx}' 'endDrag|hasPointerBeenReleased|click.*listener|project-group-header-drag|project-header-drag' src/renderer/srcRepository: stablyai/orca
Length of output: 33813
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 28074
🏁 Script executed:
#!/bin/bash
set -eu
sed -n '150,240p' src/renderer/src/components/sidebar/project-group-header-drag.ts
sed -n '160,250p' src/renderer/src/components/sidebar/project-header-drag.ts
rg -n --glob '*.{ts,tsx}' 'endDrag|hasPointerBeenReleased|project-group-header-drag|project-header-drag' src/renderer/srcRepository: stablyai/orca
Length of output: 18809
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4
Length of output: 4003
🌐 Web query:
github stablyai/orca project-group-header-drag.ts project-header-drag.ts endDrag
💡 Result:
In the stablyai/orca repository, the files src/renderer/src/components/sidebar/project-group-header-drag.ts and src/renderer/src/components/sidebar/project-header-drag.ts are components of the sidebar's drag-and-drop system, which enables manual reordering of project headers and project group headers [1][2]. Recent updates to these files and related modules (such as project-group-header-drop.ts and project-header-drop.ts) have addressed issues related to drag-and-drop mechanics [3][1][4]. Specifically, changes have: - Improved drop precision by mapping header drags to the nearest boundary slot rather than relying on a restricted "dead zone" [3][4]. - Enabled drag-and-drop functionality by the header icon, which previously failed due to restrictive event target checks (i.e., failing to recognize SVGElement targets) [5]. - Fixed issues where dropping over expanded section bodies resulted in a silent no-op [4]. The endDrag logic is typically handled within the drag-and-drop lifecycle managed by these hooks and their corresponding drop handlers, where drop indicators are computed and commit logic is executed to update the order (e.g., via tabOrder updates) [4][2]. [3][1][4][2][5]
Citations:
- 1: 22d5989
- 2: GitHub pull request 7191 in stablyai/orca (link omitted to avoid creating a cross-reference)
- 3: 24dc165
- 4: GitHub pull request 8891 in stablyai/orca (link omitted to avoid creating a cross-reference)
- 5: GitHub pull request 8576 in stablyai/orca (link omitted to avoid creating a cross-reference)
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- header-drag-click-swallow.ts ---'
cat -n src/renderer/src/components/sidebar/header-drag-click-swallow.ts
printf '%s\n' '--- drag test files and relevant test names ---'
rg -n -C 4 --glob 'project-*drag.test.ts*' --glob 'header-drag-click-swallow*' 'swallowNextClickOnDragHandle|click|pointer|session|cleanup|endDrag' src/renderer/src/components/sidebarRepository: stablyai/orca
Length of output: 3445
Do not install the click suppressor when endDrag(false) cancels a promoted session.
Both hasPointerBeenReleased(...) branches call swallowNextClickOnDragHandle(...) through endDrag(false). The helper registers a window listener but returns only a timeout handle. Effect cleanup clears the timeout without removing the listener. If cleanup runs first, the listener can consume a later header-handle click. Restrict click swallowing to the pointer-up completion path, or return an explicit disposer for cancellation cleanup. Add a regression test for stale-session recovery followed by a header click.
📍 Affects 2 files
src/renderer/src/components/sidebar/project-group-header-drag.ts#L191-L194(this comment)src/renderer/src/components/sidebar/project-header-drag.ts#L204-L207
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Phantom-drag recovery —
hasPointerBeenReleased(event.buttons === 0onpointermove) ends an armed session before it promotes, recovering from apointerupthat landed before the window listeners attached. Applied consistently touseHostHeaderDrag,useRepoHeaderDrag, anduseProjectGroupHeaderDrag. - Click-swallow extraction — the duplicated pointerup-click swallow block moved into
swallowNextClickOnDragHandle, shared across the three hooks and keepingproject-header-drag.tsunder the 300-linemax-linesceiling. - Regression test —
host-header-drag.test.tsxreplays the fast-click race and pins the three invariants: a missed release no longer promotes, a stale session no longer blocks a later drag, and a held-button drag still promotes.
The fix is well-grounded: the new test reproduces the exact race (it fails against the un-fixed hooks), and I confirmed it plus the existing project-*header-drag suites pass and oxlint is clean on all changed files. The click-swallow refactor is behavior-preserving — the dropped clickSwallowTimeoutRef.current = null inside the timeout callback is harmless, since the effect cleanup clears the ref regardless.
One note for awareness rather than action: the same race is guarded in all three hooks but only the host hook gets a regression test; the repo/project-group hooks exercise distinct promotion/commit paths, so they're not strictly covered by the host test. This is consistent with the PR's own framing and doesn't block merge.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…on (stablyai#19032) Clicking a host header arms a drag session on pointerdown, but the window pointermove/pointerup listeners attach from an effect gated on that state -- a render and a paint later. On a heavy sidebar a quick click's pointerup can land inside that window and never be seen, so the session survives the click and the next bare mouse move clears the 4px threshold and promotes a drag the user is not doing. The host tier is the only header that hides itself while dragging (opacity-0, plus forceCollapseHosts on every section), so the host the user just collapsed vanishes outright. It only returns on a stray later pointerup or when the viewport remounts -- which is why toggling the host filter fixes it: the viewport's React key includes visibleWorkspaceHostIds. Treat a pointermove with no button held as a released pointer and end the session instead of promoting. The repo and project-group header drags share the race, where it commits an unintended reorder on the next click, so they get the same guard. Extracting their duplicated click-swallow block keeps project-header-drag.ts under the max-lines ceiling.

The bug
Root cause
Not the row model — that always emits both host headers (verified below). It's a phantom host-header drag.
useHostHeaderDragarms a drag session onpointerdown, but subscribes to windowpointermove/pointerupfrom auseEffectgated on that state — so the listeners attach a render and a paint after the press. On a heavy sidebar a quick click'spointeruplands inside that window and is never seen. The session survives the click, and the next bare mouse move (no button held) clears the 4px threshold and promotes a drag the user is not doing.The host tier is the only header that hides itself while dragging:
HostSectionHeaderrenders the dragged host withopacity-0—HostSectionHeader.tsx:112(repo / project-group headers just highlight, which is why only remote host groups show this)draggingHostIdalso drivesforceCollapseHosts, collapsing every host section at once —use-section-rows.ts:228So the host you just collapsed goes fully invisible. It only clears on a stray later
pointerupor whenVirtualizedWorktreeViewportremounts — and its React key includesvisibleWorkspaceHostIds(WorktreeList.tsx:283), which is exactly why unchecking + rechecking the host in the filter brings it back.Proof
New
host-header-drag.test.tsxreplays the sequence:pointerdown, thenpointerupdispatched before React flushes the arming effect, then a bare mouse move.Before (fix reverted, test kept):
draggingHostId === 'ssh:host-a'with the mouse button up is precisely the stuck state that renders the header atopacity-0and force-collapses every host section.After:
The other two cases guard the fix: a genuine held-button drag still promotes, and a stale session no longer blocks a later real drag.
Row model ruled out
Before suspecting the view layer I drove
buildRows('workspace-status', …) + addHostSectionRowsthrough a throwaway harness across every collapse permutation — collapsed host, collapsed status lanes, all lanes collapsed, a host present in only one lane. Both host headers survive in all of them:The fix
header-drag-pointer-release.ts(new): apointermovewithbuttons === 0means thepointerupnever reached us.host-header-drag.tsends the session instead of promoting.The repo and project-group header drags share the identical race — there it commits an unintended reorder on the next click rather than hiding anything — so they get the same guard. Extracting their duplicated click-swallow block into
header-drag-click-swallow.tskeepsproject-header-drag.tsunder the 300-linemax-linesceiling (it sat at exactly 300); its timeout semantics are unchanged, since the effect cleanup must not tear the listener down on disarm.Verification
pnpm test src/renderer/src/components/sidebar/— 297 files / 2506 tests passpnpm tcclean,oxlintcleanNot verified in the running app. Reproducing it live needs two connected remote hosts and the timing race to land, which is what made it intermittent in the first place — the repro here is at the hook level.