Skip to content

fix(sidebar): preserve hidden rows in manual order - #16488

Merged
Jinwoo-H merged 4 commits into
mainfrom
aug25-sta3921-manual-order-pr-review
Aug 25, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
aug25-sta3921-manual-order-pr-review

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​512 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​509
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​215 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​147

ELI5

Manual order could still depend on Smart-sort metadata for rows hidden by filters or collapsed groups. Those rows could jump when revealed. This change gives every known row a durable manual rank the first time a real drag establishes Manual order, while preserving hidden rows in their existing slots.

What Changed

  • Build one complete manual-order catalog from every known non-archived Git and folder workspace, independent of filters, collapse, or Board lane visibility.
  • Treat a same-ID host cluster as durably ranked only when every owner agrees on the same finite manualOrder.
  • On the first real reorder with missing ranks, merge the visible move into the complete sequence and materialize all known rows once; later reorders stay sparse.
  • Share the same catalog and rank map across the left sidebar and Workspace Board.
  • Route folder ranks through the folder-workspace persistence API and fan same-ID Git updates out to every explicit local, paired-runtime, or SSH owner.
  • Harden stale/duplicate visible-order merging so it cannot drop known rows.
  • Add unit and persisted-profile Electron coverage for hidden rows, Smart → Manual, activity-driven sortOrder writes, reload, folder rows, and duplicate host ownership.

Why

Manual uses manualOrder ?? sortOrder. sortOrder is mutable Smart-sort state, so leaving filtered or collapsed rows without manualOrder means the displayed Manual order is not fully user-owned. PR #14284 backfills only rendered rows and also targets an older Board persistence path; this branch applies the stronger complete-known-row behavior to current main.

Linked Issue

STA-3921

Related hypothesis: #14284

Visual Proof

N/A — this fixes ordering persistence without changing component visuals. A real Electron drag/reload flow is covered by manual-worktree-order-persistence.spec.ts.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Passed after rebasing onto latest origin/main:

  • pnpm -s typecheck
  • Oxlint on every changed file
  • Focused Vitest: 5 files, 74 tests
  • Electron E2E: manual drag survives activity and persisted-profile reload (1/1)
  • Manual Electron/CDP: rendered order remained a → c → b after a persisted Smart reorder and full process restart; all four rows, including a collapsed row, retained finite manualOrder
  • Physical-host persistence boundary: disposable rows were written to and read back from m4 Air's and Windows 2's own orca-data.json; openclaw's SSH row was read back from the client-owned profile with the correct SSH hostId; all three fixtures were removed
  • Revert oracle: removing complete-catalog materialization makes the hidden-row regression test fail

pnpm -s typecheck:e2e remains red on unrelated repository-wide pre-existing errors; it reports no error from this spec.

Review

Three fresh same-worktree OpenCode reviews covered persistence boundary/efficiency, product semantics, and migration/regression compatibility. Their initial blockers led to the shared complete catalog, required rank inputs, defensive merge, same-ID host fan-out, folder support, and a stronger E2E refresh oracle. All three final verdicts are READY.

Invariant: after a real user reorder establishes Manual mode, Manual is one durable order for every known non-archived workspace. Filters and collapsed groups are presentation-only; they do not remove rows from that order.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • A direct Smart → Manual selection without a drag does not invent a new order; the first real reorder establishes the durable sequence.
  • Rows created in Manual mode receive a rank at creation. Any later incomplete catalog is materialized at the next real reorder.
  • Same bare IDs across hosts move as one cluster, matching the existing ID-only drag identity.
  • The migration is a bounded one-time O(N) write; steady-state reorders remain sparse.
  • No remote wire shape or opcode changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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 (targeted checks passed; full E2E typecheck has unrelated existing failures)

@Jinwoo-H
Jinwoo-H force-pushed the aug25-sta3921-manual-order-pr-review branch from 466177c to ade5f2e Compare August 25, 2026 22:02
@Jinwoo-H
Jinwoo-H marked this pull request as ready for review August 25, 2026 22:04
@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 88b049ed-a6e7-4ebe-ba51-371a784d3395

📥 Commits

Reviewing files that changed from the base of the PR and between 41baada and a5d00f5.

📒 Files selected for processing (1)
  • src/main/ipc/worktree-git-common-watch.test.ts

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


📝 Walkthrough

Walkthrough

The change adds a global manual-order catalog for Git worktrees and folder workspaces. Drag handlers use catalog ranks and complete worktree IDs to preserve hidden rows and sparse durable ranks. Metadata updates now persist folder-workspace changes separately and write Git worktree changes to known owner hosts. Unit, integration, and end-to-end tests cover ordering, duplicate IDs, filtered drops, owner routing, persistence, activity updates, reload behavior, and asynchronous watcher assertions.

Merge Risk: 🔵 Low · up to a5d00

The change preserves hidden rows in manual ordering and is mergeable with owner awareness, but the restart coverage relies on a fixed one-second delay that may intermittently flake on slower or loaded CI machines.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 17 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 primary change: preserving hidden rows during manual ordering.
Description check ✅ Passed The description follows the required template and covers the change, rationale, linked issue, visual proof, testing, review notes, compatibility considerations, and checklist status. It also documents…
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 follows the required template and covers the change, rationale, linked issue, visual proof, testing, review notes, compatibility considerations, and checklist status. It also documents the unrelated repository-wide typecheck:e2e failure.

  • 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

🧹 Nitpick comments (2)
src/renderer/src/components/sidebar/WorktreeList.tsx (1)

109-112: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider one shared hook for the catalog.

WorkspaceKanbanDrawer.tsx builds the same memoized catalog from the same two inputs. A shared useWorktreeManualOrderCatalog() hook keeps the sidebar and the board on identical inputs if the sources change later.

♻️ Proposed hook
// src/renderer/src/components/sidebar/use-worktree-manual-order-catalog.ts
export function useWorktreeManualOrderCatalog(): WorktreeManualOrderCatalog {
  const allWorktrees = useAllWorktrees()
  const folderWorkspaces = useAppStore((s) => s.folderWorkspaces)
  return useMemo(
    () => buildWorktreeManualOrderCatalog({ worktrees: allWorktrees, folderWorkspaces }),
    [allWorktrees, folderWorkspaces]
  )
}
tests/e2e/manual-worktree-order-persistence.spec.ts (1)

153-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Poll the persisted UI and worktree state before relaunch.

The 1-second sleep does not guarantee completion of the debounced window.api.ui.set call. Poll window.api.ui.get() for sortBy === 'manual', and query persisted worktree data for the manualOrder values. Do not use window.api.settings.get() for sortBy; it belongs to PersistedUIState.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c5dce0c-2ca1-4317-b12d-cb90091a4b31

📥 Commits

Reviewing files that changed from the base of the PR and between bc98655 and ade5f2e.

📒 Files selected for processing (16)
  • src/renderer/src/components/sidebar/WorkspaceKanbanDrawer.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/use-workspace-kanban-worktree-actions.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.test.ts
  • src/renderer/src/components/sidebar/workspace-kanban-sidebar-drop.ts
  • src/renderer/src/components/sidebar/worktree-list/drag/use-status-mutations.ts
  • src/renderer/src/components/sidebar/worktree-manual-order-catalog.test.ts
  • src/renderer/src/components/sidebar/worktree-manual-order-catalog.ts
  • src/renderer/src/components/sidebar/worktree-manual-order-ranks.ts
  • src/renderer/src/components/sidebar/worktree-manual-order.test.ts
  • src/renderer/src/components/sidebar/worktree-manual-order.ts
  • src/renderer/src/store/slices/folder-workspace-owner-routed-mutations.test.ts
  • src/renderer/src/store/slices/worktrees-metadata-persistence.test.ts
  • src/renderer/src/store/slices/worktrees/listing/worktree-owner-settings.ts
  • src/renderer/src/store/slices/worktrees/metadata/update-worktrees-meta.ts
  • tests/e2e/manual-worktree-order-persistence.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit c8567eb into main Aug 25, 2026
51 checks passed
@Jinwoo-H
Jinwoo-H deleted the aug25-sta3921-manual-order-pr-review branch August 25, 2026 23:46
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 28, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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