Skip to content

feat(sidebar): filter workspaces and agents by label without hiding the selection - #1851

Merged
devswha merged 4 commits into
mainfrom
feat/sidebar-label-filter
Oct 24, 2026
Merged

devswha merged 4 commits into
mainfrom
feat/sidebar-label-filter

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

What it does for the user

A Filter field sits above the sidebar's lists. Typing narrows the PC, workspace and agent rows to the ones whose labels match, using the command palette's fuzzy matcher. Rows keep herdr's order, their PC, group, card, pins and folds.

  • The selected pane's row and the rows above it stay visible, dimmed and marked Selected, so you never lose your place.
  • A folded PC, worktree group or Agents list that contains a match opens while the filter is on. Its caret folds and opens it for that time only, and no saved fold is written.
  • When nothing matches, one status line says so: "No workspaces or agents match", and "on the PCs that answered" while a PC's roster hasn't arrived. It suggests other words or clearing the filter.
  • The query is never stored. A clear, Escape in the field, closing the phone drawer or a reload empties it. Escape in a field with text clears it first; Escape in an empty field still closes the drawer.
  • Reordering (drag, a finger's lift, Alt+↑/↓) waits until the filter is cleared, so herdr never learns an order with rows missing.

The design is explained in DESIGN.md (Sidebar roster row and footer). Search as in finding anything and acting on it stays in the command palette, as in the Codex and Claude apps. This filter only narrows the lists in place by the words the rows show (maintainer-approved in #1043). The idea of keeping a row when it, a header above it or a row below it matches is adapted from agent-of-empires and credited in THIRD_PARTY_NOTICES.md.

Why this PR

This is the local feat/sidebar-label-filter branch (7 commits), cut about 180 commits behind main and never pushed, ported onto current main:

  • The drawer's Escape handling moved with main's App split into src/lib/useSidebarLayout.ts.
  • The filter's strings are in the src/lib/i18n/machines.* parts. "Selected" moved from the palette parts to the base dictionaries, since the palette and the sidebar both use it now.
  • The drawerOpen prop passes through main's ReorderContext wrapper.
  • The demo regression uses the ovis:* storage keys, and the browser lane counts 84 scripts.
  • New fix: main's reorder coordinator (fix(sidebar): reconcile workspace order by pending generations #1593) can draw a worktree under a different head than herdr's order while a move lands. The filter now keeps a group when one of its worktrees is kept, drawing the head as context, instead of losing the match. A test covers it.

How it was verified

  • bun run check fast: pass on b90cec1 (unit: 455 test files). An earlier run under heavy load had one unrelated failure, server/rpc-diagnostics.test.ts (3 requests counted instead of 4); this branch touches nothing in server/, and the test passes on its own 3/3.
  • src/lib/sidebarFilter.test.ts (8 tests, including the reorder case, which failed before the fix), plus the i18n, palette search and browser-lane tests: all pass.
  • bun scripts/sidebar-filter-demo-regression.ts on the demo: 26/26 scenarios pass at 390 and 1440 px, dark and light, plus Korean (90 screenshots under UI_EVIDENCE_DIR).
  • Reviews: omo-native-code-reviewer (approve, no HIGH) and Codex gpt-6-astra (no HIGH). Codex's one real MEDIUM, the reorder case above, is fixed. Its other two findings were false reverts from a stale base.

Known follow-ups (from review, MEDIUM/LOW, kept out to hold the original scope)

  • With "Two lines" rows, a workspace whose visible headline is its pane's title is drawn as context when only that title matched.
  • Workspace rows can't be dragged into the pane area to split while the filter is on. Agent rows still can.
  • Each filter session mounts the roster of every folded PC, which re-runs its worktree lookups.
  • While the filter is on, a file dropped on a workspace row is not caught (onDrop returns before preventDefault).

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between b04e1be and 5b0584b.

Files selected for processing: 28
  • DESIGN.md
  • THIRD_PARTY_NOTICES.md
  • changelog.d/sidebar-label-filter.md
  • docs/development.md
  • scripts/ci-browser.sh
  • scripts/pane-find-regression.ts
  • scripts/sidebar-filter-demo-regression.ts
  • src/App.tsx
  • src/components/AgentSidebar.tsx
  • src/components/MachineSidebar.tsx
  • src/components/Machines.css
  • src/components/Sidebar.css
  • src/components/Sidebar.tsx
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/i18n/machines.ja.ts
  • src/lib/i18n/machines.ko.ts
  • src/lib/i18n/machines.zh.ts
  • src/lib/i18n/palette.ja.ts
  • src/lib/i18n/palette.ko.ts
  • src/lib/i18n/palette.zh.ts
  • src/lib/paletteSearch.ts
  • src/lib/sidebarFilter.test.ts
  • src/lib/sidebarFilter.ts
  • src/lib/sidebarFilterContext.ts
  • src/lib/useSidebarLayout.ts
  • src/styles.css
  • Autofix · 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.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work for b90cec1: REVIEW FAILED on one fold case. Everything else passed.

Blocker: opening a worktree from its dialog while the filter is on erases the saved fold. src/components/Sidebar.tsx:820 always calls setWorktreeCollapsed(repoKey, false). The gate reproduced it in the browser:

  1. With no filter, collapse checkout-api.
  2. Filter for checkout-api.
  3. From its menu, choose Open worktree… and open a checkout.
  4. Clear the filter.

ovis:worktree-group-collapsed:local:demo:/home/demo/checkout-api goes from "1" to absent, and the group stays expanded. The PR promises that no saved fold is written while filtering. Please use the temporary fold state in this callback while the filter is on, and add a regression step that clears the filter and checks the saved fold is back.

Checked and passing:

  • Tests: 42 unit tests pass (52 in the gate's own run), and the typecheck passes. The merge pass's own runs of sidebar-filter-demo-regression (26 PASS) and ui-regression (72 PASS) both pass. A mutant that drops "keep the selection" is caught.
  • Filtering: rows keep herdr's order, and the selected row and the context around it stay visible. The no-match line, the query's lifecycle and Escape on a phone all behave as described.
  • Reordering: Alt+↑/↓ is blocked while filtering (the gate tried it for real). Drag, touch lift and drop are blocked by the code.
  • Edge cases: an offline PC's selected pane, a 300-character query and PCs still loading all behave as described.
  • Conventions: herdr's focus never moves. All locales and THIRD_PARTY_NOTICES are in place.

Non-blocking:

  • The regression asserts that nothing moved without first attempting a reorder.
  • Starting a filter remounts folded PCs' rosters, which refetches their worktree lookups.
  • paneLabels has a dead branch.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Fixed the blocker in db2980e.

  • Fold: opening a checkout from Open worktree… now goes through toggleWorktrees, the same path as the group's caret. While the filter is on, the group opens only for the filter's time and the saved fold isn't written. With no filter it is written as before.
  • Regression: a new scenario in sidebar-filter-demo-regression.ts (openWorktreeUnderFilter) covers your repro.
    • It folds checkout-api, filters for it and opens a checkout from the dialog (a right-click on desktop, the ⋯ sheet on a phone).
    • It asserts ovis:worktree-group-collapsed:local:<repo> is still "1" and clears the filter. The group must be folded again and the saved fold still there.
    • Without the fix it fails ("opening a checkout under the filter writes no fold": undefined !== '1'). With the fix it passes on desktop and phone, dark and light.
  • Verified: the filter demo passes all 30 scenarios, and bun run check fast passes (6394 unit tests, 0 fail; typecheck and build ok).

Non-blocking notes:

  • Rosters of folded PCs being remounted, which re-fetches their worktree lookups, is already listed in the PR's follow-ups.
  • The reorder assertions and the dead branch in paneLabels are left as they were, to keep this commit to the blocker.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: held. "Browser regression (ui-regression)" and "Integration and browser" fail on db2980e, and the failure comes from this PR.

scripts/pane-find-regression.ts:153 fails twice in a row (the first run and the retry) with 1 !== 0 (run 40094627983):

await page.keyboard.press("Escape");
assert.equal(await page.getByRole("search").count(), 0);

The check expects no search landmark once the find bar closes. This PR adds one that stays on the page: <div className="sidebar-filter" role="search">. So after Escape the count is 1. No other recent CI run fails this check.

Pick whichever fits the design:

  • scope the pane-find check to the find bar, e.g. page.locator(".find-bar") or getByRole("search", { name: … }) with a name on the find bar;
  • or give the sidebar filter a different role or an accessible name, so the two landmarks can be told apart.

Two search landmarks on one page should each have an accessible name anyway. The merge pass checks the fix (changed range only) and puts the PR back in the queue.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: one rebase needed. #1874 is merged on main. scripts/ci-browser.test.ts no longer pins the browser lane's count; it checks the scripts on disk. This branch still edits the old toHaveLength(…) line, so it now conflicts with main. Rebase onto main and drop this PR's change to scripts/ci-browser.test.ts, keeping its run_script line in scripts/ci-browser.sh. The new test checks that line automatically. This is the last rebase a lane count will cause. The merge pass checks that the rebase changed only that file, then re-queues the PR. A rebase needs no new CodeRabbit review.

devswha and others added 4 commits October 25, 2026 00:05
A filter field above the sidebar's lists narrows the PC, workspace and
agent rows to the ones whose labels match the command palette's fuzzy
matcher, in herdr's order with their pins and folds. The selected pane's
row and the rows over it stay, drawn as context and marked Selected. The
query is never stored and clears on Escape, the clear button, closing the
phone drawer or a reload. Reordering waits until the filter is cleared.

Ported onto current main from the local feat/sidebar-label-filter
branch (7 commits): the drawer's Escape now lives in useSidebarLayout,
the filter's strings in the machines i18n parts, and "Selected" moved to
the base dictionaries since the palette and the sidebar both use it.
The reorder coordinator draws its own order while a move lands, so a
worktree can sit under a head the filter did not keep (it read herdr's
order). The group now stays when one of its children is kept, its head
drawn as context, instead of the match disappearing.
…ns under the filter

Opening a checkout from a group's Open worktree dialog wrote the group's
saved fold open even while the filter was on, so clearing the filter left
a group the user had folded expanded. The dialog now opens the group
through the same path as its caret: for the filter's time only while a
filter is on, and as the saved fold otherwise. The filter demo opens a
checkout under the filter on desktop and phone, clears it, and checks
the saved fold is back.
…ind check to the find bar

The sidebar filter adds a search landmark that stays on the page, so the
pane-find regression's check that no search landmark is left once the
find bar closes always counted one. The check now looks for the find
bar's own landmark, and the filter's landmark carries its own name so
the two can be told apart.
@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main (4c8ce30, with #1874) and fixed the CI failure.

  • Rebase: this PR no longer touches scripts/ci-browser.test.ts; it's main's version now. The run_script scripts/sidebar-filter-demo-regression.ts line stays in scripts/ci-browser.sh, and test(ci): check browser lane assignment from the scripts on disk, not a pinned count #1874's test passes (7/7). Apart from that file, the four commits are the same as before.
  • CI (pane-find-regression.ts:153): both of your options are applied, in 5b0584b:
    • the check now looks only for the find bar's landmark: getByRole("search", { name: "Find in terminal", exact: true });
    • the sidebar filter's landmark has its own name, "Filter workspaces and agents" (an existing string, so no new i18n key).
    • The old assertion is the one that failed twice in run 40094627983 on this branch, and CI runs this check again on the new head.
  • Verified: bun run check fast passes (typecheck, build and unit tests).

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work report. Overall: PASSED.

Lane Verdict Confidence
QA (code-review agent's matrix plus the merge pass's own regression runs; artifacts kept) PASS at db2980e -
Code review (omo-native-code-reviewer, programming + remove-ai-slops) PASS (WATCH) -
Gate round 1 (b90cec1) REJECT: opening a worktree from its dialog under the filter erased the saved fold HIGH
Gate round 2 (db2980e) APPROVE HIGH

QA

  • sidebar-filter-demo-regression passes 30 scenarios, run by the merge pass. Before the fix it passed 26.
  • ui-regression passes 72.
  • Unit and convention tests pass, and the typecheck passes.
  • A mutant that drops the "keep the selection" rule is caught.

Behaviour

  • Rows keep herdr's order.
  • The selected row and its context stay visible, dimmed and marked.
  • A fold that holds a match opens only while the filter is on, and no saved fold is written.
  • The query is never stored.
  • Escape clears the text first, then closes the drawer.
  • Alt+↑/↓, drag, a touch lift and a drop are all blocked while filtering.
  • herdr's focus never moves.
  • All locales and THIRD_PARTY_NOTICES are in place.

Round 1 finding, fixed in db2980e: opening a worktree from its dialog while filtering now uses the temporary fold. The saved key stays "1" and the group folds again once the filter is cleared. Without a filter the group still expands and saves, as before. Reverting the fix makes the new regression step fail on desktop and phone.

  • 5b0584b and the rebase after test(ci): check browser lane assignment from the scripts on disk, not a pinned count #1874:
    • The sidebar filter's role="search" landmark now has an accessible name, "Filter workspaces and agents", translated in ja, ko and zh.
    • The pane-find check now counts only the find bar's own landmark ("Find in terminal"), which fixes the 1 !== 0 failure in ui-regression.
    • The lane count edit is dropped.
    • The conventions, sidebarFilter and ci-browser tests pass, and so does the typecheck.

Follow-ups (MINOR)

  • Starting a filter remounts folded PCs' rosters and refetches their worktree lookups.
  • paneLabels has a dead branch.
  • Sidebar.tsx and MachineSidebar.tsx keep growing.

All required checks are green and no review thread is open.

CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it.

@devswha
devswha merged commit 77267ec into main Oct 24, 2026
10 checks passed
@devswha
devswha deleted the feat/sidebar-label-filter branch October 24, 2026 22:22
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