feat: order worktree list by session and pr state#289
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
webmux | 33ba804 | Commit Preview URL Branch Preview URL |
Jul 16 2026, 10:04 AM |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @hugocasa's task in 1m 54s —— View job Code Review — PR #289Verdict: LGTM. Clean, well-scoped change. The comparator is a single shared source of truth, the ordering fields are normalized identically on both surfaces, and the test coverage matches the behavior described. No blocking issues found. A couple of minor notes below.
What I verified
Minor notes (non-blocking)
Nothing here needs to change to merge. Nice, focused PR with good test coverage. |
Summary
Worktree lists were sorted alphabetically by branch, which buried the worktrees you actually care about. They now rank by relevance: open worktrees first, then closed ones ordered by how much attention their PR still needs.
The order is:
Within each group the previous alphabetical-by-branch order is kept as a tiebreaker.
Three judgment calls worth flagging for review:
mux), which is what the sidebar'sclosedbadge already keys off — so the ordering matches the label rendered next to it.Ordering was already server-side (a single sort in
buildWorktreeSnapshots; the frontend only filters and nests), so this is one shared comparator rather than a per-surface change.Changes
compareWorktreeOrder/WorktreeOrderFieldstobackend/src/domain/policies.ts— a pure comparator over the normalized fields ordering depends on (branch,open,prStates).buildWorktreeSnapshots(snapshot-service.ts), replacing the alphabetical sort. This drives the frontend sidebar.wt list(bin/src/worktree-commands.ts), which sorted alphabetically on its own and would otherwise have disagreed with the sidebar. It builds rows from disk rather than from the snapshot, so it now reads the cached PR file per worktree viareadWorktreePrs— one extra local read, no network.Not changed
In a stacked worktree the parent's rank still determines where the whole subtree sits, so a closed parent drags its open children down with it. That falls out of the existing
baseBranchnesting inbuildWorktreeListRows, not the sort, and is left as-is.Test plan
bun run test— full suite passes (838 tests)bun run --cwd backend check— typecheckswebmux wt list— confirm the CLI order matches the sidebarGenerated with Claude Code