Skip to content

fix(sidebar): stop a missed pointerup from hiding a remote host section - #19032

Merged
nwparker merged 1 commit into
mainfrom
nwparker/disappearing-remote-host-group
Sep 6, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/disappearing-remote-host-group

Conversation

@nwparker

@nwparker nwparker commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55 $\color{#cf222e}{\Huge{\mathbf{−}}}$​39 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

The bug

I have 2 remote hosts in my filter to show. If I collapse one of them, sometimes it just totally disappears — gone. I have to go to the filter and uncheck + recheck for it to come back. (Status grouping view.)

Root cause

Not the row model — that always emits both host headers (verified below). It's a phantom host-header drag.

useHostHeaderDrag arms a drag session on pointerdown, but subscribes to window pointermove/pointerup from a useEffect gated on that state — so the listeners attach a render and a paint after the press. On a heavy sidebar a quick click's pointerup lands 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:

  • HostSectionHeader renders the dragged host with opacity-0 — HostSectionHeader.tsx:112 (repo / project-group headers just highlight, which is why only remote host groups show this)
  • draggingHostId also drives forceCollapseHosts, collapsing every host section at once — use-section-rows.ts:228

So the host you just collapsed goes fully invisible. It only clears on a stray later pointerup or when VirtualizedWorktreeViewport remounts — and its React key includes visibleWorkspaceHostIds (WorktreeList.tsx:283), which is exactly why unchecking + rechecking the host in the filter brings it back.

Proof

New host-header-drag.test.tsx replays the sequence: pointerdown, then pointerup dispatched before React flushes the arming effect, then a bare mouse move.

Before (fix reverted, test kept):

 ❯ src/renderer/src/components/sidebar/host-header-drag.test.tsx (3 tests | 1 failed)
     × does not start a drag when the pointer is released before the window listeners attach

 FAIL  useHostHeaderDrag > does not start a drag when the pointer is released before the window listeners attach
 AssertionError: expected 'ssh:host-a' to be null

 - Expected:  null
 + Received:  "ssh:host-a"

 Tests  1 failed | 2 passed (3)

draggingHostId === 'ssh:host-a' with the mouse button up is precisely the stuck state that renders the header at opacity-0 and force-collapses every host section.

After:

 Test Files  1 passed (1)
      Tests  3 passed (3)

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', …) + addHostSectionRows through 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:

none collapsed:      HOST ssh:host-a | hdr in-progress | a1 | hdr in-review | a2 | HOST ssh:host-b | hdr in-progress | b1 | hdr in-review | b2
host-a collapsed:    HOST ssh:host-a (collapsed) | HOST ssh:host-b | hdr in-progress | b1 | hdr in-review | b2
all lanes collapsed: HOST ssh:host-a | hdr in-progress | hdr in-review | HOST ssh:host-b | hdr in-progress | hdr in-review
mixed b collapsed:   HOST ssh:host-a | hdr in-progress | a1 | hdr in-review | a2 | HOST ssh:host-b (collapsed)

The fix

header-drag-pointer-release.ts (new): a pointermove with buttons === 0 means the pointerup never reached us. host-header-drag.ts ends 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.ts keeps project-header-drag.ts under the 300-line max-lines ceiling (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 pass
  • pnpm tc clean, oxlint clean

Not 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.

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.
@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 7f999

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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… Add the required template sections and complete them. Include a linked issue using Fixes #..., provide before-and-after visual proof or state N/A with a reason, mark or explain the Testing items, complete the Review, Agent skill upstrea…
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary fix: preventing a missed pointerup from leaving a sidebar host drag active and hiding a remote host section.
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.
Full details: Description check

Explanation

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 Fixes # reference, Visual Proof or N/A with a reason, Review, Notes, the Agent skill upstream boundary checkbox, and the checklist. It also does not mark the Testing checklist items.

Resolution

Add the required template sections and complete them. Include a linked issue using Fixes #..., provide before-and-after visual proof or state N/A with a reason, mark or explain the Testing items, complete the Review, Agent skill upstream boundary, Notes, and Checklist sections, and add the ELI5, What Changed, and Why headings with concise content.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 0e09ea3f-3888-47ea-b4b8-9d2cac39a3ff

📥 Commits

Reviewing files that changed from the base of the PR and between 15dabf8 and 7f999f3.

📒 Files selected for processing (6)
  • src/renderer/src/components/sidebar/header-drag-click-swallow.ts
  • src/renderer/src/components/sidebar/header-drag-pointer-release.ts
  • src/renderer/src/components/sidebar/host-header-drag.test.tsx
  • src/renderer/src/components/sidebar/host-header-drag.ts
  • src/renderer/src/components/sidebar/project-group-header-drag.ts
  • src/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.

Comment on lines +191 to +194
if (hasPointerBeenReleased(event)) {
endDrag(false)
return
}

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.

🎯 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/src

Repository: 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/src

Repository: 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/sidebar

Repository: 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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Phantom-drag recovery — hasPointerBeenReleased (event.buttons === 0 on pointermove) ends an armed session before it promotes, recovering from a pointerup that landed before the window listeners attached. Applied consistently to useHostHeaderDrag, useRepoHeaderDrag, and useProjectGroupHeaderDrag.
  • Click-swallow extraction — the duplicated pointerup-click swallow block moved into swallowNextClickOnDragHandle, shared across the three hooks and keeping project-header-drag.ts under the 300-line max-lines ceiling.
  • Regression test — host-header-drag.test.tsx replays 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit ced8a93 into main Sep 6, 2026
28 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
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