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
fix(hotkeys): shift-modified split navigation to avoid collapse/expand conflict (#2653)
gbirman61e618f12665
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsxindex 1f5c34e54a..2534d48e96 100644--- a/js/app/packages/app/component/GlobalHotkeys.tsx+++ b/js/app/packages/app/component/GlobalHotkeys.tsx@@ -187,7 +187,6 @@ export default function GlobalShortcuts() {};registerHotkey({- hotkeyToken: TOKENS.global.createNewSplit,hotkey: 'cmd+\\',scopeId: 'global',description: 'Create new split',@@ -197,6 +196,7 @@ export default function GlobalShortcuts() {});registerHotkey({+ hotkeyToken: TOKENS.global.createNewSplit,hotkey: '\\',scopeId: 'global',description: 'Create new split',diff --git a/js/app/packages/app/component/SoupChatInput.tsx b/js/app/packages/app/component/SoupChatInput.tsxindex e8a1fbefe4..b27efcaa02 100644--- a/js/app/packages/app/component/SoupChatInput.tsx+++ b/js/app/packages/app/component/SoupChatInput.tsx@@ -22,7 +22,7 @@ import { invalidateAllSoup } from '@queries/soup/cache';import { cognitionApiServiceClient } from '@service-cognition/client';import { ChatInput } from 'core/component/AI/component/input/ChatInput';import { registerHotkey, useHotkeyDOMScope } from 'core/hotkey/hotkeys';-import { onMount, Show } from 'solid-js';+import { createSignal, onCleanup, onMount, Show } from 'solid-js';import { useSplitPanelOrThrow } from './split-layout/layoutUtils';function SoupChatInputInner() {@@ -47,18 +47,27 @@ function SoupChatInputInner() {const [attachHotkeys] = useHotkeyDOMScope('soup.chatInput');- const metaHeld = () => pressedKeys().has('cmd');+ const [chatHasFocus, setChatHasFocus] = createSignal(false);+ const metaHeld = () => chatHasFocus() && pressedKeys().has('cmd');onMount(() => {attachHotkeys(containerRef);+ const focusIn = () => setChatHasFocus(true);+ const focusOut = () => setChatHasFocus(false);+ containerRef.addEventListener('focusin', focusIn);+ containerRef.addEventListener('focusout', focusOut);+ onCleanup(() => {+ containerRef.removeEventListener('focusin', focusIn);+ containerRef.removeEventListener('focusout', focusOut);+ });});- // cmd+j - Focus the soup chat input+ // cmd+j - Focus AI chatregisterHotkey({hotkey: 'cmd+j',scopeId: splitPanelContext.splitHotkeyScope,hotkeyToken: TOKENS.chat.input.focus,- description: 'Focus chat input',+ description: 'Focus AI chat',keyDownHandler: () => {editor.controls.focus();return true;diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex c7ff7cd482..11e5207fe4 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -23,7 +23,6 @@ import {} from '@app/component/next-soup/soup-view/soup-view-cache-key';import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';import { useSoupViewHotkeys } from './use-soup-view-hotkeys';-import { useSplitLayout } from '@app/component/split-layout/layout';import {openEntityInNewTab,openEntityInSplitFromUnifiedList,@@ -408,7 +407,6 @@ export const SoupViewList = (props: SoupViewListProps) => {assigneeFilter,setAssigneeFilter,} = useSoupView();- const { getSplitCount } = useSplitLayout();const { hasActiveRefinements, resetToTabDefaults } = useFilterRefinements();const { isKeypressActive } = useIsKeyPressActive();@@ -418,10 +416,6 @@ export const SoupViewList = (props: SoupViewListProps) => {const [soupViewRef, setSoupViewRef] = createSignal<HTMLElement | undefined>();- const [previewPanelRef, setPreviewPanelRef] = createSignal<- HTMLElement | undefined- >();-const focusFirstEntity = () => {const next = soup.navigate.toFirst();@@ -485,7 +479,6 @@ export const SoupViewList = (props: SoupViewListProps) => {soup,splitHandle: panel.handle,virtualizerHandle,- previewPanelRef,});// Register entity action hotkeys@@ -510,7 +503,6 @@ export const SoupViewList = (props: SoupViewListProps) => {splitHandle: panel.handle,virtualizerHandle,previewState: () => !!soup.previewEntity(),- getSplitCount,currentView,activeTab,applyTabPreset,@@ -1008,7 +1000,6 @@ export const SoupViewList = (props: SoupViewListProps) => {}><PreviewPanel- ref={setPreviewPanelRef}selectedEntity={soup.focus.item()}orchestrator={orchestrator}splitPanelContext={panel}diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.tsindex 02544b92a5..e0c04b186e 100644--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts@@ -2,7 +2,6 @@ import { TOKENS } from '@core/hotkey/tokens';import type { VirtualizerHandle } from 'virtua/solid';import { onCleanup, type Accessor } from 'solid-js';import type { SoupState } from '../create-soup-state';-import { useMaybePreviewPanel } from '@app/component/PreviewPanel';import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';import type { SplitHandle } from '@app/component/split-layout/layoutManager';import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';@@ -18,7 +17,6 @@ type UseSoupNavigationHotkeysOptions = {soup: SoupState;splitHandle: SplitHandle;virtualizerHandle: Accessor<VirtualizerHandle | undefined>;- previewPanelRef: Accessor<HTMLElement | undefined>;};export const useSoupNavigationHotkeys = (@@ -196,8 +194,6 @@ export const useSoupNavigationHotkeys = (hide: true,}).withGroup(group);- const previewPanel = useMaybePreviewPanel();-const getCollapsibleToggle = () => {const focusedId = soup.focus.id();if (!focusedId) return undefined;@@ -211,7 +207,7 @@ export const useSoupNavigationHotkeys = (registerHotkey({hotkey: ['h', 'arrowleft'],scopeId,- description: 'Navigate to parent context',+ description: 'Collapse item',hotkeyToken: TOKENS.unifiedList.navigation.parent,keyDownHandler: () => {const toggle = getCollapsibleToggle();@@ -220,11 +216,7 @@ export const useSoupNavigationHotkeys = (return true;}- if (!previewPanel) return false;-- previewPanel.onFocusOut();-- return true;+ return false;},registrationType: 'add',handlerPriority: 4,@@ -234,7 +226,7 @@ export const useSoupNavigationHotkeys = (registerHotkey({hotkey: ['l', 'arrowright'],scopeId,- description: 'Navigate to child context',+ description: 'Expand item',hotkeyToken: TOKENS.unifiedList.navigation.child,keyDownHandler: () => {const toggle = getCollapsibleToggle();@@ -243,24 +235,7 @@ export const useSoupNavigationHotkeys = (return true;}- const previewPanelContent = options.previewPanelRef();- // If there is no preview or the preview already contains focus, skip- if (- !previewPanelContent ||- previewPanelContent.contains(document.activeElement)- )- return false;-- const previewPanelSoup = previewPanelContent?.querySelector(- 'div[data-soup-view]'- );-- // If it doesn't contain soup, skip- if (!previewPanelSoup || !(previewPanelSoup instanceof HTMLElement))- return false;-- previewPanelSoup.focus();- return true;+ return false;},registrationType: 'add',handlerPriority: 4,diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.tsindex eda622c9af..f95741eef4 100644--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts@@ -34,7 +34,6 @@ type UseSoupViewHotkeysOptions = {splitHandle: SplitHandle;virtualizerHandle: Accessor<VirtualizerHandle | undefined>;previewState: Accessor<boolean>;- getSplitCount: () => number;currentView: Accessor<ListView | undefined>;activeTab: Accessor<string | undefined>;applyTabPreset: (view: ListView, tabId: string) => void;@@ -47,7 +46,6 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {splitHandle,virtualizerHandle,previewState,- getSplitCount,currentView,activeTab,applyTabPreset,@@ -57,12 +55,10 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {const splitIsUnifiedList = () => isListViewID(splitHandle.content().id);- // escape - Multi-purpose: Clear selection / Close spotlight / Close split / Go home+ // escape - Multi-purpose: Clear selection / Close spotlightconst clearMultiCondition = () =>soup.selection.count() > 0 && splitIsUnifiedList();const closeSpotlightCondition = () => splitHandle.isSpotLight();- const goHomeCondition = () => !splitIsUnifiedList();- const closeSplitCondition = () => splitIsUnifiedList() && getSplitCount() > 1;const escapeDescription = () => {if (clearMultiCondition()) {@@ -71,12 +67,6 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {if (closeSpotlightCondition()) {return 'Close spotlight';}- if (closeSplitCondition()) {- return 'Close split';- }- if (goHomeCondition()) {- return 'Go home';- }return '';};@@ -277,16 +267,12 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {runWithInputFocused: true,}).withGroup(group);- // escape - Multi-purpose: Clear selection / Close spotlight / Close split / Go home+ // escape - Multi-purpose: Clear selection / Close spotlightregisterHotkey({hotkey: ['escape'],scopeId,description: escapeDescription,- condition: () =>- clearMultiCondition() ||- closeSpotlightCondition() ||- closeSplitCondition() ||- goHomeCondition(),+ condition: () => clearMultiCondition() || closeSpotlightCondition(),keyDownHandler: () => {if (clearMultiCondition()) {const length = soup.selection.count();diff --git a/js/app/packages/app/component/settings/Shortcuts.tsx b/js/app/packages/app/component/settings/Shortcuts.tsxindex 3cbee12186..592ccddc0e 100644--- a/js/app/packages/app/component/settings/Shortcuts.tsx+++ b/js/app/packages/app/component/settings/Shortcuts.tsx@@ -1,13 +1,13 @@import { IS_MAC } from '@core/constant/isMac';import { CustomScrollbar } from '@core/component/CustomScrollbar';import { Hotkey } from '@core/component/Hotkey';-import { createSignal, For } from 'solid-js';+import { createSignal, For, type JSX } from 'solid-js';const cmdOrCtrl = IS_MAC ? 'cmd' : 'ctrl';type ShortcutItem = {keys: string[];- description: string;+ description: JSX.Element;};type ShortcutSection = {@@ -17,52 +17,56 @@ type ShortcutSection = {const shortcutSections: ShortcutSection[] = [{- title: 'Core Shortcuts',+ title: 'Core',items: [- { keys: ['c'], description: 'Open the create menu (new email, new doc, etc.)' },+ { keys: ['c'], description: 'Open the create menu' },{ keys: [`${cmdOrCtrl}+k`], description: 'Open the command menu' },+ {+ keys: ['g'],+ description: (+ <>+ Go to a view (e.g. <Kbd shortcut="g" /> then <Kbd shortcut="i" /> for inbox)+ </>+ ),+ },+ { keys: ['/'], description: 'Go to search view' },+ { keys: [`${cmdOrCtrl}+f`], description: 'Search in current view' },+ { keys: [`${cmdOrCtrl}+j`], description: 'Focus AI chat' },+ { keys: [`${cmdOrCtrl}+;`], description: 'Open settings panel' },],},{- title: 'Unified List Navigation',+ title: 'Unified List',items: [{ keys: ['j', 'arrowdown'], description: 'Move down' },{ keys: ['k', 'arrowup'], description: 'Move up' },- { keys: ['e'], description: 'Mark done' },- { keys: ['x'], description: `Select items (then ${IS_MAC ? '⌘' : 'Ctrl'}+K to bring up actions)` },{ keys: ['shift+j', 'shift+arrowdown'], description: `Select down` },{ keys: ['shift+k', 'shift+arrowup'], description: `Select up` },- { keys: ['space'], description: 'Preview an item in the side panel' },- { keys: ['enter'], description: 'Open an item fullscreen' },- { keys: [`${cmdOrCtrl}+f`], description: 'Search (uses current filters)' },- ],- },- {- title: 'Filtering the List',- items: [- { keys: ['d'], description: 'Filter to docs' },- { keys: ['l'], description: 'Filter to email' },- { keys: ['p'], description: 'Filter to people (direct messages)' },- { keys: ['m'], description: 'Filter to teams' },- { keys: ['f'], description: 'Filter to files' },- ],- },- {- title: 'Splits & Navigation',- items: [- { keys: ['\\'], description: 'Create a split' },- { keys: ['escape'], description: 'Return to the list, or close split if already on list' },- { keys: ['cmd+escape'], description: 'Close the split' },- { keys: ['arrowleft'], description: 'Focus split to the left' },- { keys: ['arrowright'], description: 'Focus split to the right' },+ { keys: ['e'], description: 'Mark done' },+ {+ keys: ['x'],+ description: (+ <>+ Select items (then <Kbd shortcut={`${cmdOrCtrl}+k`} /> to bring up actions)+ </>+ ),+ },+ { keys: ['f'], description: 'Open filter menu' },+ { keys: ['h', 'arrowleft'], description: 'Collapse item' },+ { keys: ['l', 'arrowright'], description: 'Expand item' },+ { keys: ['space'], description: 'Preview item' },+ { keys: ['click', 'enter'], description: 'Open item in current split' },+ { keys: ['shift+click', 'shift+enter'], description: 'Open item in a new split' },],},{- title: 'Miscellaneous',+ title: 'Splits',items: [- { keys: [`${cmdOrCtrl}+j`], description: 'Open popover AI chat' },- { keys: [`${cmdOrCtrl}+/`], description: 'Open sidebar AI chat' },- { keys: [`${cmdOrCtrl}+;`], description: 'Open settings panel' },+ { keys: ['\\', `${cmdOrCtrl}+\\`], description: 'Create a split' },+ { keys: [`opt+escape`], description: 'Go home in current split, close split if home' },+ { keys: ['shift+escape'], description: 'Spotlight split' },+ { keys: ['shift+h', 'shift+arrowleft'], description: 'Focus split to the left' },+ { keys: ['shift+l', 'shift+arrowright'], description: 'Focus split to the right' },{ keys: [`opt+[`], description: 'Go back in current split' },{ keys: [`opt+]`], description: 'Go forward in current split' },],@@ -72,7 +76,7 @@ const shortcutSections: ShortcutSection[] = [function Kbd(props: { shortcut: string; class?: string }) {return (<span- class={`inline-flex items-center font-mono text-xs px-1.5 py-0.5 rounded border border-accent/30 bg-accent/10 text-accent ${props.class ?? ''}`}+ class={`inline-flex items-center font-mono text-xs px-1.5 py-0.5 rounded border border-accent/30 bg-accent/10 text-accent uppercase ${props.class ?? ''}`}><Hotkey shortcut={props.shortcut} class="flex gap-[2px]" lowercase /></span>@@ -94,7 +98,7 @@ function ShortcutRow(props: { item: ShortcutItem }) {function ShortcutSectionComponent(props: { section: ShortcutSection }) {return (- <div class="mb-6">+ <div class="mb-3"><h3 class="text-accent font-medium text-lg mb-2 px-3 flex items-center gap-2">{/*<span class="w-1.5 h-1.5 rounded-full bg-accent" />*/}{props.section.title}@@ -118,10 +122,10 @@ export function Shortcuts() {class="absolute inset-0 overflow-auto p-6 scrollbar-hidden"><div class="max-w-2xl mx-auto">- <div class="mb-8">+ <div class="mb-4"><h2 class="text-xl font-semibold text-ink mb-2">Keyboard Shortcuts</h2><p class="text-ink-muted text-sm">- Shortcuts without a {IS_MAC ? 'cmd' : 'ctrl'}/option modifier key require text inputs to be unfocused. For example, pressing <kbd>j</kbd> in a document will insert a j, but will move down the list if the document text is unfocused.+ Shortcuts without a {cmdOrCtrl}/option modifier key require text inputs to be unfocused. For example, pressing <kbd>j</kbd> in a document will insert a j, but will move down the list if the document text is unfocused.</p></div>diff --git a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx b/js/app/packages/app/component/split-layout/components/SplitPanel.tsxindex 1695b1cd96..22271b7d24 100644--- a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx@@ -10,7 +10,7 @@ import { useSplitLayout } from '../layout';import type { SplitHandle, SplitState } from '../layoutManager';import { createHeaderCollapser } from '../utils/createHeaderCollapser';import { registerSplitHotkeys } from '../registerSplitHotkeys';-import { isListViewID } from '@app/constants/list-views';+import { isListViewID, LIST_VIEW_ID } from '@app/constants/list-views';import { isMobile } from '@core/mobile/isMobile';export type SplitPanelProps = {@@ -48,7 +48,11 @@ export function SplitPanel(props: SplitPanelProps) {goBack: () => props.handle.goBack(),canGoForward: () => props.handle.canGoForward(),goForward: () => props.handle.goForward(),- replaceSplit: splitLayoutHelpers.replaceSplit,+ goHome: () =>+ props.handle.replace({+ next: { type: 'component', id: LIST_VIEW_ID.inbox },+ referredFrom: 'hotkey',+ }),splitName: () => props.handle.displayName(),getSplitCount: () => splitLayoutHelpers.getSplitCount(),isNotUnifiedList: () => {diff --git a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts b/js/app/packages/app/component/split-layout/registerSplitHotkeys.tsindex 3e01c27138..02b1477e91 100644--- a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts+++ b/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts@@ -2,10 +2,9 @@ import { TOKENS } from '@core/hotkey/tokens';import { registerHotkey } from 'core/hotkey/hotkeys';import { globalSplitManager } from '../../signal/splitLayout';import { fireMacroJump } from '../MacroJump';-import type { ReferredFrom, SplitContent } from './layoutManager';+import type { SplitContent } from './layoutManager';import { focusAdjacentSplit } from './layoutUtils';import { canSpotlight } from './utils/canSpotlight';-import { LIST_VIEW_ID } from '@app/constants/list-views';export function registerSplitHotkeys(args: {splitHotkeyScope: string;@@ -16,10 +15,7 @@ export function registerSplitHotkeys(args: {goBack: () => void;canGoForward: () => boolean;goForward: () => void;- replaceSplit: (options: {- content: SplitContent;- referredFrom?: ReferredFrom;- }) => void;+ goHome: () => void;splitName: () => string;getSplitCount: () => number;isNotUnifiedList: () => boolean;@@ -35,22 +31,18 @@ export function registerSplitHotkeys(args: {splitName,getSplitCount,isNotUnifiedList,- replaceSplit,+ goHome,} = args;- const splitManager = globalSplitManager();registerHotkey({scopeId: splitHotkeyScope,- hotkey: 'cmd+escape',- condition: () => getSplitCount() > 1 || isNotUnifiedList(),- description: () => (getSplitCount() > 1 ? 'Close split' : 'Go home'),+ hotkey: 'opt+escape',+ condition: () => isNotUnifiedList() || getSplitCount() > 1,+ description: () => (isNotUnifiedList() ? 'Go home' : 'Close split'),keyDownHandler: () => {- if (getSplitCount() > 1) {+ if (isNotUnifiedList()) {+ goHome();+ } else if (getSplitCount() > 1) {closeSplit();- } else {- replaceSplit({- content: { type: 'component', id: LIST_VIEW_ID.inbox },- referredFrom: 'hotkey',- });}return true;},@@ -65,6 +57,7 @@ export function registerSplitHotkeys(args: {hotkeyToken: TOKENS.window.spotlight.toggle,description: () => `Maximize ${splitName()}`,condition: () => {+ const splitManager = globalSplitManager();if (!splitManager) return false;return canSpotlight(splitManager);},@@ -117,7 +110,7 @@ export function registerSplitHotkeys(args: {registerHotkey({hotkeyToken: TOKENS.window.focusSplitRight,- hotkey: ['l', 'arrowright'],+ hotkey: ['shift+l', 'shift+arrowright'],scopeId: splitHotkeyScope,description: 'Focus split right',condition: () => getSplitCount() > 1,@@ -130,7 +123,7 @@ export function registerSplitHotkeys(args: {registerHotkey({hotkeyToken: TOKENS.window.focusSplitLeft,- hotkey: ['h', 'arrowleft'],+ hotkey: ['shift+h', 'shift+arrowleft'],scopeId: splitHotkeyScope,description: 'Focus split left',condition: () => getSplitCount() > 1,