-
Notifications
You must be signed in to change notification settings - Fork 11
🤖 refactor: make command palette a workspace switcher by default #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Refinement: Only Switching, No MutationsRefined the default filter to be even more focused - now shows only workspace switching commands (
These management commands are still accessible via Rationale:
Testing: // Default view: Only ws:switch:* commands
testFiltering("") // → ["Switch to Workspace A", "Switch to Workspace B"] ✅
// With > prefix: All commands including mutations
testFiltering(">") // → All 8+ commands including create/delete/rename ✅ |
|
Fixed the cmdk filtering issue for |
|
fyi @ThomasK33 — I think this is a good compromise |
bb8102c to
23eea4b
Compare
Make the command palette primarily a workspace switcher while keeping all commands accessible via prefix keys. This focuses the palette on the most common use case (switching workspaces) without sacrificing functionality. **Changes:** - Default view shows only workspace commands (switch, create, rename, etc.) - Type `>` prefix to see all commands across all sections - Type `/` prefix for slash commands (existing behavior) - Updated placeholder text to reflect new behavior **Code quality improvements:** - Extracted repeated state reset logic into `resetPaletteState()` helper - Exported command section names as `COMMAND_SECTIONS` constant - Removed unused `searchQuery` variable - Updated documentation and Storybook stories **Documentation:** - Added command palette section to docs/keybinds.md explaining three modes - Updated Storybook story with accurate feature descriptions _Generated with `cmux`_
Changed the default filter to only show `ws:switch:*` commands, excluding workspace mutations like create, delete, and rename. These management commands are still accessible via the `>` prefix. **Why:** - Workspace switching is the primary use case - Create/delete/rename are mutations that should require explicit intent - Keeps the default palette extremely focused and fast **Changes:** - Filter by command ID prefix `ws:switch:*` instead of section name - Updated documentation to clarify "switching" vs "workspace management" - Updated Storybook story descriptions
Fixed an issue where typing `>abc` wouldn't filter commands because
`shouldUseCmdkFilter` was set to false for command queries. Now cmdk
filtering is enabled for `>` queries so users can search through all commands.
Addresses Codex review comment about unsearchable "all commands" mode.
**Before:**
- `shouldFilter={false}` for `>` queries
- Custom filter was never called
- Typing `>abc` showed all commands unfiltered
**After:**
- `shouldFilter={true}` for `>` queries
- Custom filter strips `>` prefix and filters normally
- Typing `>abc` narrows down to matching commands
23eea4b to
aa1228e
Compare
Fixed bug where typing ">" still showed workspace switching commands along with all other commands. Now cleanly separates: - Default: only switching commands (ws:switch:*) - With ">": all other commands (mutations, nav, chat, etc.) EXCEPT switching This creates a clean mental model: the palette is a switcher by default, and ">" shows "everything else". **Changes:** - Fixed filter to exclude ws:switch:* when showAllCommands is true - Added comprehensive test suite (6 tests) in CommandPalette.test.ts - Updated docs to clarify "two modes" behavior - Updated AGENTS.md to require tests in repo when doing TDD **Tests verify:** - Default shows only 2 switching commands - Default excludes mutations (new/remove/rename) - ">" shows 6 commands, all non-switching - Clean separation: no overlap between modes - Together both modes cover all commands
Extracted command palette filtering logic to `commandPaletteFiltering.ts` to eliminate duplication between implementation and tests. **Changes:** - Created `filterCommandsByPrefix()` utility function - Updated CommandPalette.tsx to use the utility - Updated tests to test the actual utility (not duplicate logic) - Added comprehensive JSDoc documentation **Benefits:** - Single source of truth for filtering logic - Tests verify actual implementation, not duplicate - Logic can be reused if needed elsewhere - Better separation of concerns Addresses review feedback about duplication.
Refactored tests to focus on behavioral properties rather than specific mock data. Tests now verify the filtering rules themselves, not hardcoded expectations about specific command counts. **Changes:** - Removed large mockActions array - Each test creates minimal data to test specific property - Tests organized by property (e.g., "default mode shows only ws:switch:*") - Tests are resilient to command list changes **Properties tested:** 1. Default mode only returns ws:switch:* commands 2. > mode never returns ws:switch:* commands 3. Modes partition the command space (no overlap, no gaps) 4. / prefix always returns empty 5. Text after > doesn't affect our filter (cmdk handles it) **Benefits:** - Tests won't break when commands are added/removed - Clear intent - each test verifies one property - More maintainable - minimal test data per property - Better test names describe what they verify Addresses review feedback about brittle tests.
77bc625 to
113bf09
Compare
Create single source of truth for command ID patterns to eliminate
magic string duplication across the codebase.
**Changes:**
- Add src/utils/commandIds.ts with CommandIds builders and CommandIdMatchers
- Update sources.ts to use centralized builders (e.g., CommandIds.workspaceSwitch(id))
- Update filtering logic to use CommandIdMatchers.isWorkspaceSwitch()
- Update tests to use centralized builders, ensuring consistency
**Benefits:**
- Single source of truth for all command ID patterns
- No more duplicated magic strings ('ws:switch:', etc.)
- Type-safe ID construction
- Easy to find all command ID patterns in one place
- Changes to ID format only need to happen in one file
Move COMMAND_ID_PREFIXES definition before CommandIds to use prefixes
in builder functions, eliminating string literal duplication.
**Before:**
- Builder: `ws:switch:${workspaceId}`
- Prefix: "ws:switch:"
**After:**
- Prefix defined once: "ws:switch:"
- Builder: `${COMMAND_ID_PREFIXES.WS_SWITCH}${workspaceId}`
Makes the command palette primarily a workspace switcher by default, with all commands still accessible via prefix keys.
Motivation
The command palette was showing all commands by default, but workspace switching is the most common use case. This change optimizes for the common case while keeping everything accessible.
Changes
Behavior
>prefix: Shows all commands across all sections (Navigation, Chat, Modes, Projects, Help)/prefix: Shows slash commands for chat input (existing behavior)Code Quality
Took this opportunity to clean up surrounding code:
resetPaletteState()helper - State reset logic was duplicated 4 times across the componentCOMMAND_SECTIONSconstant - Section names are now centralized and type-safesearchQuerywas declared but never used>prefix in cmdk filteringDocumentation
docs/keybinds.mdexplaining the three modesTesting
Before/After
Before:
After:
>to instantly see all other commands when neededGenerated with
cmux