Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(hotkeys): faster hotkeys with less nesting / remove visor system (#731)

Jacob Beckerman3e91cd6b47d7
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsx
index f9758c8305..df7ae84af8 100644
--- a/js/app/packages/app/component/GlobalHotkeys.tsx
+++ b/js/app/packages/app/component/GlobalHotkeys.tsx
@@ -28,8 +28,6 @@ import {
} from './command/state';
import { CREATABLE_BLOCKS, setCreateMenuOpen } from './Launcher';
import { useSplitLayout } from './split-layout/layout';
-import { fireVisor, resetVisor } from './Visor';
-import { openWhichKey, setOpenWhichKey } from './WhichKey';
export default function GlobalShortcuts() {
const [_, setBigChatOpen] = useBigChat();
@@ -68,24 +66,26 @@ export default function GlobalShortcuts() {
hotkey: block.hotkey,
scopeId: createCommandScope.commandScopeId,
description: block.description,
- keyDownHandler: () => {
- block.keyDownHandler();
- return true;
- },
runWithInputFocused: true,
- });
-
- registerHotkey({
- hotkeyToken: block.altHotkeyToken,
- hotkey: `opt+${block.hotkey}` as ValidHotkey,
- scopeId: createCommandScope.commandScopeId,
- description: `${block.description} in new split`,
keyDownHandler: () => {
block.keyDownHandler();
return true;
},
- runWithInputFocused: true,
});
+
+ if (block.altHotkeyToken) {
+ registerHotkey({
+ hotkeyToken: block.altHotkeyToken,
+ hotkey: `opt+${block.hotkey}` as ValidHotkey,
+ scopeId: createCommandScope.commandScopeId,
+ description: `${block.description} in new split`,
+ runWithInputFocused: true,
+ keyDownHandler: () => {
+ block.keyDownHandler();
+ return true;
+ },
+ });
+ }
}
registerHotkey({
@@ -130,6 +130,17 @@ export default function GlobalShortcuts() {
runWithInputFocused: true,
});
+ registerHotkey({
+ hotkey: '\\',
+ scopeId: 'global',
+ description: 'Create new split',
+ condition: canFit,
+ keyDownHandler: () => {
+ insertSplit({ type: 'component', id: 'unified-list' });
+ return true;
+ },
+ });
+
registerHotkey({
hotkeyToken: TOKENS.global.toggleSettings,
hotkey: 'cmd+;',
@@ -245,25 +256,6 @@ export default function GlobalShortcuts() {
runWithInputFocused: true,
});
- registerHotkey({
- hotkeyToken: TOKENS.global.toggleVisor,
- scopeId: 'global',
- hotkey: ['escape'],
- description: 'Toggle visor',
- keyDownHandler: () => {
- if (!openWhichKey()) {
- fireVisor();
- setOpenWhichKey(true);
- return false;
- } else {
- resetVisor();
- setOpenWhichKey(false);
- return false;
- }
- },
- runWithInputFocused: true,
- });
-
registerHotkey({
scopeId: 'global',
description: 'Toggle beveled corners',
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index fc9566808e..9de7ef2fcd 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -10,6 +10,7 @@ import { ToastRegion } from '@core/component/Toast/ToastRegion';
import { WebsocketDebugger } from '@core/component/WebsocketDebugger';
import {
ENABLE_WEBSOCKET_DEBUGGER,
+ ENABLE_WHICHKEY_OVERLAY,
PROD_MODE_ENV,
} from '@core/constant/featureFlags';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
@@ -301,7 +302,7 @@ export function Root() {
setHotkeyRoot(useHotKeyRoot());
useSubscribeToKeypress((context) => {
- if (context.commandScopeActivated) {
+ if (ENABLE_WHICHKEY_OVERLAY && context.commandScopeActivated) {
setOpenWhichKey(true);
}
});
@@ -385,7 +386,9 @@ export function Root() {
<Title>{tabTitle()}</Title>
<MacroJump />
<Visor />
- <WhichKey />
+ <Show when={ENABLE_WHICHKEY_OVERLAY}>
+ <WhichKey />
+ </Show>
<SuspenseContextComp fallback={<RootSuspenseFallback />}>
<IsomorphicRouter
transformUrl={transformShortIdInUrlPathname}
diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsx
index 8dde548c8b..a28e4396b0 100644
--- a/js/app/packages/app/component/SoupContext.tsx
+++ b/js/app/packages/app/component/SoupContext.tsx
@@ -230,14 +230,14 @@ export function createNavigationEntityListShortcut({
splitHandle,
splitHotkeyScope,
unifiedListContext,
- goScopeId,
previewState,
+ getSplitCount,
}: {
splitHandle: SplitHandle;
splitHotkeyScope: string;
unifiedListContext: UnifiedListContext;
- goScopeId: string;
previewState: Signal<boolean>;
+ getSplitCount: () => number;
}) {
const {
viewsDataStore: viewsData,
@@ -272,6 +272,40 @@ export function createNavigationEntityListShortcut({
return splitHandle.content().id === 'unified-list';
});
+ // `gg` to jump to top of list (legacy behavior) via command-scope hotkeys.
+ const goScope = registerHotkey({
+ scopeId: splitHotkeyScope,
+ hotkey: 'g',
+ description: 'Go',
+ keyDownHandler: () => true,
+ activateCommandScope: true,
+ hide: true,
+ });
+
+ registerHotkey({
+ hotkey: ['g'],
+ scopeId: goScope.commandScopeId,
+ description: 'Go to top of list',
+ condition: isViewingList,
+ keyDownHandler: () => {
+ navigateThroughList({ axis: 'start', mode: 'jump' });
+ return true;
+ },
+ hide: true,
+ });
+
+ registerHotkey({
+ hotkey: ['shift+g', 'end'],
+ scopeId: goScope.commandScopeId,
+ description: 'Go to bottom of list',
+ condition: isViewingList,
+ keyDownHandler: () => {
+ navigateThroughList({ axis: 'end', mode: 'jump' });
+ return true;
+ },
+ hide: true,
+ });
+
/**
* From the current selection, get the entity to try to select after a modal
* edit operation.
@@ -1132,27 +1166,6 @@ export function createNavigationEntityListShortcut({
hide: true,
});
- registerHotkey({
- hotkey: ['g'],
- scopeId: goScopeId,
- description: 'Go to top of list',
- keyDownHandler: () => {
- navigateThroughList({ axis: 'start', mode: 'jump' });
- return true;
- },
- });
-
- registerHotkey({
- hotkey: ['shift+g', 'end'],
- scopeId: goScopeId,
- hotkeyToken: TOKENS.entity.jump.end,
- description: 'Go to bottom of list',
- keyDownHandler: () => {
- navigateThroughList({ axis: 'end', mode: 'jump' });
- return true;
- },
- });
-
const navigateThroughViews = ({
axis,
}: {
@@ -1313,6 +1326,8 @@ export function createNavigationEntityListShortcut({
const clearMultiCondition: () => boolean = () =>
isViewingList() && viewData().multiSelectEntities.length > 0;
const closeSpotlightCondition = () => splitHandle.isSpotLight();
+ const goHomeCondition = () => !splitIsUnifiedList();
+ const closeSplitCondition = () => splitIsUnifiedList() && getSplitCount() > 1;
const escapeDescription = () => {
if (clearMultiCondition()) {
return 'Clear multi selection';
@@ -1320,13 +1335,23 @@ export function createNavigationEntityListShortcut({
if (closeSpotlightCondition()) {
return 'Close spotlight';
}
+ if (closeSplitCondition()) {
+ return 'Close split';
+ }
+ if (goHomeCondition()) {
+ return 'Go home';
+ }
return '';
};
registerHotkey({
hotkey: ['escape'],
scopeId: splitHotkeyScope,
description: escapeDescription,
- condition: () => clearMultiCondition() || closeSpotlightCondition(),
+ condition: () =>
+ clearMultiCondition() ||
+ closeSpotlightCondition() ||
+ closeSplitCondition() ||
+ goHomeCondition(),
keyDownHandler: () => {
if (clearMultiCondition()) {
const length = viewData().multiSelectEntities.length;
@@ -1337,6 +1362,14 @@ export function createNavigationEntityListShortcut({
splitHandle.toggleSpotlight();
return true;
}
+ if (closeSplitCondition()) {
+ splitHandle.close();
+ return true;
+ }
+ if (goHomeCondition()) {
+ splitHandle.replace({ type: 'component', id: 'unified-list' });
+ return true;
+ }
return false;
},
});
diff --git a/js/app/packages/app/component/custom-cursor/CursorTooltip.tsx b/js/app/packages/app/component/custom-cursor/CursorTooltip.tsx
new file mode 100644
index 0000000000..bbb8b54237
--- /dev/null
+++ b/js/app/packages/app/component/custom-cursor/CursorTooltip.tsx
@@ -0,0 +1,13 @@
+/**
+ * NOTE:
+ * This component is intentionally a no-op placeholder.
+ *
+ * We previously had an experimental cursor tooltip implementation here, but it
+ * does not belong in this PR and is not currently used by the app.
+ *
+ * Keeping the file (as an inert stub) avoids Biome `ci --changed` crashing on
+ * deleted files in some environments.
+ */
+export function CursorTooltip() {
+ return null;
+}
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index 15778133dd..f3a35732c1 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -362,7 +362,7 @@ function SplitPanel(props: SplitPanelProps) {
const [previewState, setPreviewState] = createSignal(false);
const splitLayoutHelpers = useSplitLayout();
- const { goScope } = registerSplitHotkeys({
+ registerSplitHotkeys({
splitHotkeyScope,
insertSplit: splitLayoutHelpers.insertSplit,
closeSplit: () => props.handle.close(),
@@ -384,8 +384,8 @@ function SplitPanel(props: SplitPanelProps) {
splitHandle: props.handle,
splitHotkeyScope,
unifiedListContext,
- goScopeId: goScope.commandScopeId,
previewState: [previewState, setPreviewState],
+ getSplitCount: () => splitLayoutHelpers.getSplitCount(),
});
return (
diff --git a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts b/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts
index cf8d6f8076..bc5eb1ada0 100644
--- a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts
+++ b/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts
@@ -12,21 +12,7 @@ import type { SplitContent } from './layoutManager';
import { focusAdjacentSplit } from './layoutUtils';
import { canSpotlight } from './utils/canSpotlight';
-export function registerSplitHotkeys({
- splitHotkeyScope,
- insertSplit,
- closeSplit,
- toggleSpotlight,
- canGoBack,
- goBack,
- canGoForward,
- goForward,
- setSelectedView,
- replaceSplit,
- splitName,
- getSplitCount,
- isNotUnifiedList,
-}: {
+export function registerSplitHotkeys(args: {
splitHotkeyScope: string;
insertSplit: (content: SplitContent) => void;
closeSplit: () => void;
@@ -41,44 +27,20 @@ export function registerSplitHotkeys({
getSplitCount: () => number;
isNotUnifiedList: () => boolean;
}) {
+ const {
+ splitHotkeyScope,
+ closeSplit,
+ toggleSpotlight,
+ canGoBack,
+ goBack,
+ canGoForward,
+ goForward,
+ replaceSplit,
+ splitName,
+ getSplitCount,
+ isNotUnifiedList,
+ } = args;
const splitManager = globalSplitManager();
- const canFit = () =>
- splitManager?.resizeContext()?.canFit({ minSize: 400 }) ?? true;
-
- const windowScope = registerHotkey({
- scopeId: splitHotkeyScope,
- hotkey: 'w',
- description: 'Window',
- keyDownHandler: () => {
- return true;
- },
- activateCommandScope: true,
- });
-
- registerHotkey({
- hotkeyToken: TOKENS.window.createNewSplit,
- hotkey: '\\',
- scopeId: windowScope.commandScopeId,
- description: 'Create new split',
- condition: canFit,
- keyDownHandler: () => {
- insertSplit({ type: 'component', id: 'unified-list' });
- return true;
- },
- });
-
- registerHotkey({
- scopeId: windowScope.commandScopeId,
- hotkey: 'w',
- condition: () => getSplitCount() > 1,
- description: `Close split`,
- keyDownHandler: () => {
- closeSplit();
- return true;
- },
- hotkeyToken: TOKENS.window.close,
- });
-
registerHotkey({
scopeId: splitHotkeyScope,
hotkey: 'cmd+escape',
@@ -91,9 +53,10 @@ export function registerSplitHotkeys({
hotkeyToken: TOKENS.split.close,
});
+ // Spotlight (maximize split) - legacy binding.
registerHotkey({
- scopeId: windowScope.commandScopeId,
- hotkey: 'm',
+ scopeId: splitHotkeyScope,
+ hotkey: 'shift+escape',
hotkeyToken: TOKENS.window.spotlight.toggle,
description: () => `Maximize ${splitName()}`,
condition: () => {
@@ -107,97 +70,84 @@ export function registerSplitHotkeys({
runWithInputFocused: true,
});
- const goScope = registerHotkey({
+ registerHotkey({
scopeId: splitHotkeyScope,
- hotkey: 'g',
- description: 'Go',
+ hotkey: 'h',
+ description: 'Go home',
+ condition: isNotUnifiedList,
keyDownHandler: () => {
+ replaceSplit({ type: 'component', id: 'unified-list' });
return true;
},
- activateCommandScope: true,
- hotkeyToken: TOKENS.split.goCommand,
- displayPriority: 10,
+ hotkeyToken: TOKENS.split.goHome,
+ displayPriority: 8,
});
- const goScopeId = goScope.commandScopeId;
-
+ // History back/forward - legacy bindings.
registerHotkey({
- scopeId: goScopeId,
- hotkey: '[',
+ scopeId: splitHotkeyScope,
hotkeyToken: TOKENS.split.go.back,
+ hotkey: 'opt+[',
condition: () => canGoBack(),
description: `Go back`,
keyDownHandler: () => {
goBack();
return true;
},
+ runWithInputFocused: true,
});
registerHotkey({
- scopeId: goScopeId,
- hotkey: ']',
+ scopeId: splitHotkeyScope,
hotkeyToken: TOKENS.split.go.forward,
+ hotkey: 'opt+]',
condition: () => canGoForward(),
description: `Go forward`,
keyDownHandler: () => {
goForward();
return true;
},
+ runWithInputFocused: true,
});
+ // AI side panel - legacy binding.
+ const [bigChatOpen] = useBigChat();
+ const toggleRightPanel = useToggleRightPanel();
registerHotkey({
- scopeId: goScopeId,
- hotkey: 'h',
- description: 'Go home',
- keyDownHandler: () => {
- replaceSplit({ type: 'component', id: 'unified-list' });
- return true;
- },
- hotkeyToken: TOKENS.split.go.home,
- });
-
- registerHotkey({
+ hotkeyToken: TOKENS.split.go.toggleRightPanel,
+ hotkey: 'cmd+/',
scopeId: splitHotkeyScope,
- hotkey: 'h',
- description: 'Go home',
- condition: isNotUnifiedList,
- keyDownHandler: () => {
- replaceSplit({ type: 'component', id: 'unified-list' });
- return true;
+ description: () => {
+ return isRightPanelOpen() ? 'Close AI panel' : 'Open AI panel';
},
- hotkeyToken: TOKENS.split.goHome,
- displayPriority: 8,
- });
-
- registerHotkey({
- scopeId: goScopeId,
- hotkey: 'e',
- description: 'Go to email',
keyDownHandler: () => {
- replaceSplit({ type: 'component', id: 'unified-list' });
- setSelectedView('email');
+ // Always allow closing. Only allow opening when big chat is not open.
+ toggleRightPanel(!isRightPanelOpen());
return true;
},
- hotkeyToken: TOKENS.split.go.email,
+ condition: () => !bigChatOpen() || isRightPanelOpen(),
+ runWithInputFocused: true,
});
+ // Macro Jump - legacy binding.
registerHotkey({
- scopeId: goScopeId,
- hotkey: 's',
- description: 'Go to signal',
+ hotkeyToken: TOKENS.split.go.macroJump,
+ hotkey: 'cmd+m',
+ scopeId: splitHotkeyScope,
+ description: 'Macro Jump',
keyDownHandler: () => {
- replaceSplit({ type: 'component', id: 'unified-list' });
- setSelectedView('signal');
+ fireMacroJump();
return true;
},
- hotkeyToken: TOKENS.split.go.inbox,
+ runWithInputFocused: true,
});
registerHotkey({
hotkeyToken: TOKENS.window.focusSplitRight,
- hotkey: ['arrowright', 'tab', 'l'],
- scopeId: windowScope.commandScopeId,
+ hotkey: ['arrowright'],
+ scopeId: splitHotkeyScope,
description: 'Focus split right',
+ condition: () => getSplitCount() > 1,
keyDownHandler: () => {
focusAdjacentSplit('right');
return true;
@@ -206,44 +156,15 @@ export function registerSplitHotkeys({
registerHotkey({
hotkeyToken: TOKENS.window.focusSplitLeft,
- hotkey: ['arrowleft', 'shift+tab', 'h'],
- scopeId: windowScope.commandScopeId,
+ hotkey: ['arrowleft'],
+ scopeId: splitHotkeyScope,
description: 'Focus split left',
+ condition: () => getSplitCount() > 1,
keyDownHandler: () => {
focusAdjacentSplit('left');
return true;
},
});
- const [bigChatOpen, _] = useBigChat();
- const toggleRightPanel = useToggleRightPanel();
-
- registerHotkey({
- hotkeyToken: TOKENS.split.go.toggleRightPanel,
- hotkey: 'r',
- scopeId: goScopeId,
- description: () => {
- return isRightPanelOpen() ? 'Close AI panel' : 'Open AI panel';
- },
- keyDownHandler: () => {
- toggleRightPanel();
- return true;
- },
- condition: () => {
- return !bigChatOpen();
- },
- });
-
- registerHotkey({
- hotkeyToken: TOKENS.split.go.macroJump,
- hotkey: 'j',
- scopeId: goScopeId,
- description: 'Macro Jump',
- keyDownHandler: () => {
- fireMacroJump();
- return true;
- },
- });
-
- return { windowScope, goScope };
+ return {};
}
diff --git a/js/app/packages/block-email/util/emailHotkeys.ts b/js/app/packages/block-email/util/emailHotkeys.ts
index fbfb900c38..9592fe0613 100644
--- a/js/app/packages/block-email/util/emailHotkeys.ts
+++ b/js/app/packages/block-email/util/emailHotkeys.ts
@@ -73,14 +73,4 @@ export function registerEmailHotkeys(
keyDownHandler: handlers.navigateToNextMessage,
hotkeyToken: TOKENS.email.nextMessage,
});
- registerHotkey({
- hotkey: 'escape',
- scopeId: scopeId,
- description: 'Cancel reply',
- keyDownHandler: () => {
- // handlers.setShowReply(false);
- return true;
- },
- hotkeyToken: TOKENS.email.cancelReply,
- });
}
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index 71afa12502..c161bb62ea 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -125,6 +125,8 @@ export const ENABLE_TTFT = DEV_MODE_ENV;
export const ENABLE_SOUND = false;
export const ENABLE_JACK_IN = false;
+export const ENABLE_WHICHKEY_OVERLAY = false;
+
// pure css based custom cursor
export const ENABLE_CUSTOM_CURSOR = false;
// uses javascript to detect selectable text to switch to "text" cursor type (ibeam)