Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chg(command): use same categories as sidebar, update all ranking (#4323)
Seamus6fa62c4e5521
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsxindex 2006ba784f..7792543506 100644--- a/js/app/packages/app/component/GlobalHotkeys.tsx+++ b/js/app/packages/app/component/GlobalHotkeys.tsx@@ -1,4 +1,8 @@import { useAnalytics } from '@app/component/analytics-context';+import {+ COMMAND_MENU_CATEGORY_LEADER_KEY,+ COMMAND_MENU_CATEGORY_SCOPE,+} from '@app/constants/hotkeys';import { useFeatureFlag } from '@app/lib/analytics/posthog';import { useSubscribeToKeypress } from '@app/signal/hotkeyRoot';import { useHandleFileUpload } from '@app/util/handleFileUpload';@@ -14,7 +18,9 @@ import {type SettingsTab,useSettingsState,} from '@core/constant/SettingsState';+import { setActiveScope } from '@core/hotkey/state';import { TOKENS } from '@core/hotkey/tokens';+import type { ValidHotkey } from '@core/hotkey/types';import {handleFolderSelect,openFilePicker,@@ -39,10 +45,9 @@ import {themeShouldMatchSystem,themes,} from '../../theme/signals/themeSignals';-import { applyTheme } from '../../theme/utils/themeUtils';import { globalSplitManager } from '../signal/splitLayout';-import { CommandState } from './command';+import { type CategoryFilter, CommandState } from './command';import {CREATABLE_BLOCKS,createMenuOpen,@@ -51,6 +56,20 @@ import {import { openMacroMcpSetupModal } from './macro-mcp-setup-modal/MacroMcpSetupModal';import { useSplitLayout } from './split-layout/layout';+const COMMAND_MENU_CATEGORY_HOTKEYS: Array<{+ category: CategoryFilter;+ hotkey: ValidHotkey;+ label: string;+}> = [+ { category: 'all', hotkey: 'l', label: 'All' },+ { category: 'commands', hotkey: 'm', label: 'Command' },+ { category: 'chats', hotkey: 'a', label: 'Agents' },+ { category: 'documents', hotkey: 'f', label: 'Files' },+ { category: 'tasks', hotkey: 't', label: 'Tasks' },+ { category: 'channels', hotkey: 'c', label: 'Channels' },+ { category: 'dms', hotkey: 'p', label: 'People' },+];+function useHotkeyAnalytics(): void {const analytics = useAnalytics();@@ -182,6 +201,34 @@ export default function GlobalShortcuts() {runWithInputFocused: true,});+ registerHotkey({+ hotkey: COMMAND_MENU_CATEGORY_LEADER_KEY,+ scopeId: 'global',+ description: 'Open category',+ keyDownHandler: () => true,+ activateCommandScopeId: COMMAND_MENU_CATEGORY_SCOPE,+ surfaceNestedCommands: true,+ keywords: ['command menu', 'palette', 'category'],+ });++ for (const item of COMMAND_MENU_CATEGORY_HOTKEYS) {+ registerHotkey({+ hotkey: item.hotkey,+ scopeId: COMMAND_MENU_CATEGORY_SCOPE,+ description: `Open ${item.label}`,+ keyDownHandler: () => {+ setActiveScope('global');+ CommandState.setCategoryFilter(item.category);+ CommandState.setQuery('');+ CommandState.setSelectedIndex(0);+ CommandState.open();+ return true;+ },+ keywords: ['command menu', 'palette', 'category', item.label],+ runWithInputFocused: true,+ });+ }+const { openWithSplit } = useSplitLayout();const createNewSplit = () => {diff --git a/js/app/packages/app/component/command/CommandMenu.tsx b/js/app/packages/app/component/command/CommandMenu.tsxindex 17b1c4895f..62453b635d 100644--- a/js/app/packages/app/component/command/CommandMenu.tsx+++ b/js/app/packages/app/component/command/CommandMenu.tsx@@ -52,13 +52,12 @@ import {const CATEGORIES: { id: CategoryFilter; label: string }[] = [{ id: 'all', label: 'All' },- { id: 'channels', label: 'Channels' },- { id: 'dms', label: 'DMs' },- { id: 'documents', label: 'Documents' },- { id: 'tasks', label: 'Tasks' },+ { id: 'commands', label: 'Command' },{ id: 'chats', label: 'Agents' },- { id: 'projects', label: 'Folders' },- { id: 'commands', label: 'Commands' },+ { id: 'documents', label: 'Files' },+ { id: 'tasks', label: 'Tasks' },+ { id: 'channels', label: 'Channels' },+ { id: 'dms', label: 'People' },];const VIRTUAL_ITEM_HEIGHT = 40; // tailwind h-10diff --git a/js/app/packages/app/component/command/useCommandItems.ts b/js/app/packages/app/component/command/useCommandItems.tsindex 98d9fe2a32..4b0c96bb28 100644--- a/js/app/packages/app/component/command/useCommandItems.ts+++ b/js/app/packages/app/component/command/useCommandItems.ts@@ -340,7 +340,7 @@ function useQuickAccessBuckets(): Record<all: allWithCommands,channels: quickAccess.useList('channel'),dms: quickAccess.useList('dm'),- documents: quickAccess.useList('note', 'document', 'snippet'),+ documents: quickAccess.useList('note', 'document', 'snippet', 'project'),tasks: quickAccess.useList('task'),chats: quickAccess.useList('chat'),projects: quickAccess.useList('project'),@@ -388,6 +388,30 @@ export function useCommandItems(const q = query();const items = categoryItems();+ if (+ q.trim().length <= 3 &&+ categoryFilter() === 'all' &&+ CommandState.commandScopeCommands().length === 0 &&+ !CommandState.isEntityActionMode()+ ) {+ const trimmedQuery = q.trim();+ const ranked = trimmedQuery+ ? search()(items, q).map((result) => result.item)+ : items.filter(showInRecencyList);+ const topCommands = ranked.filter(isCommandItem).slice(0, 3);++ if (!trimmedQuery || topCommands.length > 0) {+ const topCommandIds = new Set(topCommands.map((item) => item.id));+ const rest = ranked.filter((item) => !topCommandIds.has(item.id));++ return [+ ...(trimmedQuery ? [makeSearchItem(q, categoryFilter())] : []),+ ...topCommands,+ ...rest,+ ];+ }+ }+const ranked = q? search()(items, q).map((result) => result.item): items.filter(showInRecencyList);diff --git a/js/app/packages/app/component/mobile/MobileSearch.tsx b/js/app/packages/app/component/mobile/MobileSearch.tsxindex 28ebd7c665..ef2efd6a84 100644--- a/js/app/packages/app/component/mobile/MobileSearch.tsx+++ b/js/app/packages/app/component/mobile/MobileSearch.tsx@@ -45,13 +45,12 @@ import { type PillTabItem, PillTabs } from './PillTabs';const CATEGORIES: PillTabItem<CategoryFilter>[] = [{ value: 'all', label: 'All' },- { value: 'channels', label: 'Channels' },- { value: 'dms', label: 'DMs' },- { value: 'documents', label: 'Documents' },+ { value: 'commands', label: 'Command' },+ { value: 'chats', label: 'Agents' },+ { value: 'documents', label: 'Files' },{ value: 'tasks', label: 'Tasks' },- { value: 'chats', label: 'Chats' },- { value: 'projects', label: 'Folders' },- { value: 'commands', label: 'Commands' },+ { value: 'channels', label: 'Channels' },+ { value: 'dms', label: 'People' },];export function MobileSearchOuter() {diff --git a/js/app/packages/app/constants/hotkeys.ts b/js/app/packages/app/constants/hotkeys.tsindex fe1d268fe1..e844dc1b56 100644--- a/js/app/packages/app/constants/hotkeys.ts+++ b/js/app/packages/app/constants/hotkeys.ts@@ -7,6 +7,13 @@ export const GO_TO_LEADER_KEY: ValidHotkey = 'g';/** Command scope for 'g' leader key (vim-style "go to" commands) */export const GO_TO_COMMAND_SCOPE = 'command-scope-go-to';+/** Leader key for opening command menu categories */+export const COMMAND_MENU_CATEGORY_LEADER_KEY: ValidHotkey = 'o';++/** Command scope for 'o' leader key (open command menu category) */+export const COMMAND_MENU_CATEGORY_SCOPE =+ 'command-scope-command-menu-category';+// Register the global GO_TO command scoperegisterScope({parentScopeId: 'global',@@ -14,3 +21,10 @@ registerScope({type: 'command',activationKeys: [GO_TO_LEADER_KEY],});++registerScope({+ parentScopeId: 'global',+ scopeId: COMMAND_MENU_CATEGORY_SCOPE,+ type: 'command',+ activationKeys: [COMMAND_MENU_CATEGORY_LEADER_KEY],+});