Skip to content

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

Closed
waleedlatif1 wants to merge 1 commit into
stagingfrom
workspace-switcher-search-staging
Closed

feat(sidebar): search the workspace switcher when a user has many workspaces#5894
waleedlatif1 wants to merge 1 commit into
stagingfrom
workspace-switcher-search-staging

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a search input to the workspace switcher dropdown, shown once the user has more than 3 workspaces (WORKSPACE_SEARCH_THRESHOLD)
  • ArrowUp/Down move through filtered results, Enter switches, query + highlight reset on close
  • Filtering is memoized; the highlight/reset/scroll machinery is gated on showSearch so users with few workspaces get zero extra re-renders
  • Uses the canonical ChipInput for the field chrome (leading Search icon, ref-forwarded focus) — no hand-rolled chip styling
  • Restores the search UX we used to have (Slack thread — Brandon/Emir); ported the fully-refined version from improvement/ui incl. the effect-guard/perf fixes so it doesn't flash on open

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…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. Filtering is memoized and the
highlight/reset/scroll machinery is gated on showSearch so users with few
workspaces get no extra re-renders. Uses the canonical ChipInput for the
field chrome.
@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:17pm

Request Review

@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Client-only sidebar UX in workspace-header.tsx; no API, auth, or data-model changes.

Overview
Adds search to the workspace switcher when the user has more than three workspaces, so long lists are easier to navigate.

A ChipInput with a search icon filters workspaces by name (memoized). Arrow keys move a highlight through results, Enter switches to the highlighted workspace, and the list scrolls to keep the highlight visible. Opening the menu focuses the search field; closing clears the query and highlight. Search UI and related effects only run when the threshold is exceeded, so smaller lists behave as before.

Reviewed by Cursor Bugbot for commit 847ff5a. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Duplicate of #5893 (created inadvertently by an automation agent on a stray branch). Closing; #5893 is the canonical PR — single commit, clean base off staging.

@waleedlatif1
waleedlatif1 deleted the workspace-switcher-search-staging branch July 23, 2026 18:18
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds searchable, keyboard-navigable workspace selection for users with more than three workspaces.

  • Filters workspace names from a ChipInput query.
  • Adds highlighted-result navigation and scrolling for ArrowUp and ArrowDown.
  • Switches to the highlighted workspace on Enter and resets search state when the menu closes.

Confidence Score: 3/5

The keyboard-close and stale-selection regressions should be fixed before merging.

The search handler consumes Escape without closing the dropdown, and an asynchronous workspace-list update can leave the highlighted index outside the filtered results so Enter performs no selection.

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx Adds workspace filtering and keyboard selection, but intercepts Escape without closing the dropdown and does not reconcile the highlighted index when results shrink.

Reviews (1): Last reviewed commit: "feat(sidebar): search the workspace swit..." | Re-trigger Greptile

setHighlightedIndex(0)
}}
onKeyDown={(e) => {
e.stopPropagation()

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.

P1 Escape no longer closes menu

When the auto-focused search input receives Escape, this unconditional propagation stop prevents the key from reaching the dropdown while the handler has no Escape branch, causing the workspace switcher to remain open.

} else if (e.key === 'Enter') {
e.preventDefault()
const target = filteredWorkspaces[highlightedIndex]
if (target) onWorkspaceSwitch(target)

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.

P1 Stale highlight disables selection

When the workspace query updates while this menu is open and the filtered list shrinks below the current highlighted index, the index is not clamped. Enter then reads an out-of-range element and does nothing, leaving keyboard users unable to select the displayed result until they move the highlight or reopen the menu.

@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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 847ff5a. Configure here.

if (!open && showSearch) {
setWorkspaceSearch('')
setHighlightedIndex(0)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale search after menu close

Medium Severity

Search query and highlight reset only run inside onOpenChange, but the menu is often closed by calling setIsWorkspaceMenuOpen(false) directly (new workspace, invite, manage, delete, leave, context-menu dismiss). Those paths skip the reset, so a prior query can still filter the list on the next open.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 847ff5a. Configure here.

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