Skip to content

Fix reordering workspaces with collapsed children - #25302

Merged
nwparker merged 1 commit into
mainfrom
nwparker/cannot-re-order-worktree-card
Oct 4, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/cannot-re-order-worktree-card

Conversation

@nwparker

@nwparker nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​212 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​212
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8

ELI5

A workspace with collapsed children could start dragging, but dropping it lower in the sidebar appeared to do nothing. Its hidden children kept pulling the parent back above the destination. Manual order now honors the parent’s saved position.

What Changed

In Manual mode, the visibility pipeline adds required ancestor cards before applying saved order. Previously it added ancestors afterward, placing a parent at its highest-ranked child’s position. The sidebar and the shared visibility inputs used by keyboard navigation now select the same policy. Parents still appear when a visible child needs them, and expanding their children preserves the hierarchy.

Why

The parent controls its manual placement. Fixing the ordering pipeline avoids rewriting every hidden descendant’s rank on each drag and preserves activity-based parent promotion in automatic sort modes. This applies to local and remote workspaces; it changes no host operations or wire messages.

Linked Issue

Reported directly by a maintainer; no existing issue.

Visual Proof

Same downward drag, with 53 children collapsed. Before: the parent remains above Last workspace. After: the parent lands below Last workspace. Captured from hidden Electron renderers on macOS; the original code fails the regression assertion and the fixed code passes.

Before After
Before downward drop After downward drop

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

All app launches used ORCA_BACKGROUND_LAUNCH=1.

  • 59 focused unit tests passed: manual lineage ordering on local/SSH rows, filtered structural parents, automatic sorts, shortcut rendering, and real metadata writes.
  • worktree-parent-reorder.spec.ts --repeat-each=3: 6 passed on macOS, covering downward/upward drags and child expansion in both card styles. The same test fails against the original code. Synthetic rows skip IPC persistence; unit tests cover the real write action.
  • Existing manual-order persistence and virtualized downward-drag tests passed.
  • Playwright CLI CDP verified this checkout’s identity and rendered order.
  • pnpm tc, pnpm run check:code-quality:changed, and pnpm exec electron-vite build --mode e2e passed.

Windows/Linux UI and live SSH were not exercised locally. Full lint, full suite, and release build are left to CI.

Review

Self-reviewed ancestor injection, saved ordering, filtered parents, child hierarchy, and shortcut visibility inputs.

Agent skill upstream boundary

  • Not applicable; no agent skill source is changed.

Notes

No new paths, shortcuts, provider-specific behavior, persistence fields, or remote protocol changes. Folder workspace rows retain their existing ordering. The same filtering and sorting passes are reused; no per-child writes are added.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — targeted local checks above; remaining coverage in CI.

@pullfrog

pullfrog Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d6c5c9ac-c1b4-458f-aeb4-ae29f57a6ce7
📥 Commits

Reviewing files that changed from the base of the PR and between b99d28e and 82c6251.

📒 Files selected for processing (5)
  • src/renderer/src/components/sidebar/visible-worktree-options-from-state.ts
  • src/renderer/src/components/sidebar/visible-worktrees-manual-lineage-order.test.ts
  • src/renderer/src/components/sidebar/visible-worktrees.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
  • tests/e2e/worktree-parent-reorder.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Manual sort mode now preserves lineage-parent positions when visible worktrees are computed. The change adds unit tests for local and SSH hosts and an end-to-end test for reordering a collapsed parent in both worktree card styles.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 82c62

The collapsed-parent reorder change is ready to merge after normal checks; no actionable issue remains from this review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing workspace reordering when child workspaces are collapsed.
Description check ✅ Passed The description covers the required sections, explains the user-facing problem and implementation, includes before-and-after visual proof, and reports testing. It also explains that no issue is linked…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nwparker
nwparker merged commit ab41610 into main Oct 4, 2026
17 of 18 checks passed
@nwparker
nwparker deleted the nwparker/cannot-re-order-worktree-card branch October 4, 2026 21:24
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