Skip to content

feat(sidebar): search the workspace switcher when a user has many workspaces#5893

Merged
waleedlatif1 merged 2 commits into
stagingfrom
worktree-workspace-switcher-search
Jul 23, 2026
Merged

feat(sidebar): search the workspace switcher when a user has many workspaces#5893
waleedlatif1 merged 2 commits into
stagingfrom
worktree-workspace-switcher-search

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two sidebar improvements:

1. Workspace switcher search (workspace-header.tsx)

Restores searchable, keyboard-navigable workspace selection for users with many workspaces — the switcher becomes hard to navigate once the list is long.

  • Search input appears once the list exceeds WORKSPACE_SEARCH_THRESHOLD (> 3 workspaces).
  • Case-insensitive name filter; ↑/↓ move through results, Enter switches, empty-state for no matches.
  • Keyboard highlight rides the existing chipVariants({ active }) so it matches hover/active exactly.
  • Input reuses the emcn ChipInput (icon prop) — no hand-rolled field chrome.
  • Robustness: the highlighted index is clamped against the current results on read, and search/highlight reset via an effect keyed on the menu-open state so every close path (select, Escape, click-away) clears them. All the search machinery is gated on showSearch, so users at ≤3 workspaces get zero extra work.

Reuses the pattern that previously lived on an unmerged branch, ported onto current code with the anti-flash refinements (prefetched list means showSearch is stable from first paint; the input only mounts inside the opened, already-hydrated dropdown).

2. Settings-sidebar last-item hover clip (settings-sidebar.tsx)

The scrollable settings-nav container had top padding but no bottom padding, so the last item's rounded hover pill was clipped against the overflow edge (visible on "Custom blocks", the final Enterprise item). Fixed with symmetric py-1.5 on the scroll container — item spacing is unchanged.

Testing

  • bun typecheck + biome clean on both files.
  • Comprehensive /cleanup pass (effects, state, memo, callback, React Query, url-state, emcn, comments) over both surfaces — no anti-patterns; only inlined a trivial filter memo and collapsed a padding shorthand.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 23, 2026 6:56pm

Request Review

@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Sidebar UI and interaction only; no API, auth, or data-layer changes.

Overview
Workspace switcher gains a ChipInput search field when the user has more than three workspaces. The list filters by name (case-insensitive), supports ↑/↓ and Enter to switch, shows an empty state when nothing matches, and reuses chipVariants({ active }) for keyboard highlight. Highlighting tracks workspace id (not index), scrolls the active row into view, resets search/highlight whenever the menu closes, and uses onMouseMove instead of mouseEnter so keyboard scrolling doesn't steal selection from the pointer.

Settings sidebar changes the scroll container from top-only padding (pt-1.5) to symmetric py-1.5 so the last nav item's rounded hover isn't clipped at the bottom edge.

Reviewed by Cursor Bugbot for commit 04534ce. Configure here.

@waleedlatif1
waleedlatif1 force-pushed the worktree-workspace-switcher-search branch from 5d2477d to 4854375 Compare July 23, 2026 18:14
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Search and navigation enhancements for the workspace switcher, plus bottom padding for the settings sidebar.

  • Adds conditional workspace search, keyboard navigation, identity-based highlighting, and an empty-results state.
  • Adds symmetric vertical padding to prevent the final settings item’s hover treatment from being clipped.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failures remain within the scope of the previous review threads.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx Adds searchable, keyboard-navigable workspace selection and completes the previously requested identity-based highlight handling without a remaining eligible blocking failure.
apps/sim/components/settings/settings-sidebar.tsx Adds bottom padding to the scrollable settings navigation container without changing item spacing.

Reviews (4): Last reviewed commit: "fix(settings): pad settings-sidebar scro..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile Addressed the positional-index finding: the highlighted row is now clamped against the current filtered results on read (activeIndex), so a live workspace-list change while the dropdown is open can't leave keyboard selection pointing at a stale or out-of-range row. Enter, the visual highlight, and the scroll-into-view all consume the clamped index.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

The clamping is clean and the consumption is consistent — activeIndex is the single source of truth for Enter, the isKeyboardHighlighted computation, and the scrollIntoView selector. No path can diverge.

One minor note: the clamp always resets to 0 on out-of-range rather than filteredWorkspaces.length - 1. So if a user is highlighted at index 3 and the results shrink to 2 items (e.g. typing narrows them), focus jumps to the top instead of the new last item. Both behaviors are defensible — resetting to 0 is simpler and avoids a confusing "always stuck at bottom" feel. Just confirming this is intentional, not an oversight.

Otherwise the fix is solid. Thanks for addressing it.

@waleedlatif1
waleedlatif1 force-pushed the worktree-workspace-switcher-search branch from c34ead2 to c553795 Compare July 23, 2026 18:23
@waleedlatif1
waleedlatif1 force-pushed the worktree-workspace-switcher-search branch from c553795 to 43b8fe4 Compare July 23, 2026 18:27
@waleedlatif1
waleedlatif1 force-pushed the worktree-workspace-switcher-search branch from 43b8fe4 to a1d7bb1 Compare July 23, 2026 18:35
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
waleedlatif1 force-pushed the worktree-workspace-switcher-search branch from a1d7bb1 to 6404d68 Compare July 23, 2026 18:47
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

…kspaces

Shows a search input in the workspace dropdown once the list exceeds
WORKSPACE_SEARCH_THRESHOLD (3). ArrowUp/Down move through results, Enter
switches, and the query resets on close. All the search machinery is gated on
showSearch so users with few workspaces get no extra re-renders. The input
reuses the emcn ChipInput chrome (icon prop) rather than hand-rolling the field.

The highlight tracks the highlighted workspace by identity (a stored id, not a
numeric position). An effect keeps that id pinned to a workspace that is actually
in the current results — seeding the first result on open and re-seeding when a
query filters the current one out — so even the default highlight is identity-
stable. A live list change while the menu is open (shrink, grow, or reorder from
a membership change or background refetch) therefore carries the highlight and
Enter along with the same workspace instead of stranding them on whatever now
sits at that row. `activeIndex` derives from the id and is the single source of
truth for Enter, the visual highlight, and the scroll target.

Search and highlight reset via an effect keyed on the menu-open state, so closing
by any path (selecting a workspace, Escape, click-away) clears them — not only
the Radix-driven close that routes through onOpenChange. Hover-highlight is wired
to mousemove rather than mouseenter so a keyboard-driven scrollIntoView can't fire
a synthetic enter that hijacks the keyboard selection, and composition keys are
ignored while an IME is active so confirming a candidate can't switch workspace.
…ver isn't clipped

The scrollable settings-nav container had `pt-1.5` but no bottom padding, so
the last item's rounded `--surface-active` hover pill was clipped against the
container's overflow edge (visible on "Custom blocks", the final Enterprise
item). Give it symmetric vertical padding (`py-1.5`) so the last row gets
equal breathing room. Padding sits on the scroll container, not between
items, so item spacing is unchanged.
@waleedlatif1
waleedlatif1 force-pushed the worktree-workspace-switcher-search branch from 6404d68 to 04534ce Compare July 23, 2026 18:56
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 04534ce. Configure here.

@waleedlatif1
waleedlatif1 merged commit d39b193 into staging Jul 23, 2026
15 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-workspace-switcher-search branch July 23, 2026 19:02
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