= ({ getSlashContext
{
- setActivePrompt(null);
- setPromptError(null);
- setQuery("");
+ resetPaletteState();
close();
}}
>
@@ -367,6 +377,18 @@ export const CommandPalette: React.FC = ({ getSlashContext
className="bg-separator border-border text-lighter font-primary w-[min(720px,92vw)] overflow-hidden rounded-lg border shadow-[0_10px_40px_rgba(0,0,0,0.4)]"
onMouseDown={(e: React.MouseEvent) => e.stopPropagation()}
shouldFilter={shouldUseCmdkFilter}
+ filter={(value, search) => {
+ // When using ">" prefix, filter using the text after ">"
+ if (isCommandQuery && search.startsWith(">")) {
+ const actualSearch = search.slice(1).trim().toLowerCase();
+ if (!actualSearch) return 1;
+ if (value.toLowerCase().includes(actualSearch)) return 1;
+ return 0;
+ }
+ // Default cmdk filtering for other cases
+ if (value.toLowerCase().includes(search.toLowerCase())) return 1;
+ return 0;
+ }}
>
= ({ getSlashContext
? currentField.type === "text"
? (currentField.placeholder ?? "Type value…")
: (currentField.placeholder ?? "Search options…")
- : `Type a command… (${formatKeybind(KEYBINDS.CANCEL)} to close, ${formatKeybind(KEYBINDS.SEND_MESSAGE)} to send in chat)`
+ : `Switch workspaces or type > for all commands, / for slash commands…`
}
autoFocus
onKeyDown={(e: React.KeyboardEvent) => {
@@ -391,9 +413,7 @@ export const CommandPalette: React.FC = ({ getSlashContext
} else if (e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
- setActivePrompt(null);
- setPromptError(null);
- setQuery("");
+ resetPaletteState();
close();
}
return;
diff --git a/src/utils/commands/sources.ts b/src/utils/commands/sources.ts
index 6a24e2644..f0658f673 100644
--- a/src/utils/commands/sources.ts
+++ b/src/utils/commands/sources.ts
@@ -44,13 +44,26 @@ export interface BuildSourcesParams {
const THINKING_LEVELS: ThinkingLevel[] = ["off", "low", "medium", "high"];
+/**
+ * Command palette section names
+ * Exported for use in filtering and command organization
+ */
+export const COMMAND_SECTIONS = {
+ WORKSPACES: "Workspaces",
+ NAVIGATION: "Navigation",
+ CHAT: "Chat",
+ MODE: "Modes & Model",
+ HELP: "Help",
+ PROJECTS: "Projects",
+} as const;
+
const section = {
- workspaces: "Workspaces",
- navigation: "Navigation",
- chat: "Chat",
- mode: "Modes & Model",
- help: "Help",
- projects: "Projects",
+ workspaces: COMMAND_SECTIONS.WORKSPACES,
+ navigation: COMMAND_SECTIONS.NAVIGATION,
+ chat: COMMAND_SECTIONS.CHAT,
+ mode: COMMAND_SECTIONS.MODE,
+ help: COMMAND_SECTIONS.HELP,
+ projects: COMMAND_SECTIONS.PROJECTS,
};
export function buildCoreSources(p: BuildSourcesParams): Array<() => CommandAction[]> {