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
feat(list): tab and number key shortcuts for soup view tab groups (#1914)
Seamus36049e038e2a
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsxindex 00a11d3f97..8c3c2eea7f 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx@@ -22,7 +22,7 @@ import {type SegmentedControlRootProps,} from '@kobalte/core/segmented-control';-const useApplyPreset = () => {+export const useApplyPreset = () => {const soup = useSoup();const { setQueryFilters, setActiveTab } = useSoupView();const user = useUserContext();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 b8cb9b4a6e..67252b5e1d 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@@ -80,7 +80,11 @@ import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-oimport { usePropertyEditorHotkeys } from '@app/component/property-edit-modal/hooks/usePropertyEditorHotkeys';import type { SoupItemsQueryFilters } from '@queries/soup/items';import type { FilterID } from '@app/component/next-soup/filters/filters';-import { SoupViewTabs } from '@app/component/next-soup/soup-view/soup-view-tabs';+import {+ SoupViewTabs,+ useApplyPreset,+} from '@app/component/next-soup/soup-view/soup-view-tabs';+import { isListViewID } from '@app/constants/list-views';import {SplitHeaderLeft,SplitHeaderRight,@@ -376,6 +380,13 @@ export const SoupViewList = (props: SoupViewListProps) => {});// Register soup view hotkeys (jump navigation, enter, escape, cmd+k, etc.)+ const { applyTabPreset } = useApplyPreset();+ const currentView = () => {+ const { type, id } = panel.handle.content();+ if (type !== 'component') return;+ return isListViewID(id) ? id : undefined;+ };+useSoupViewHotkeys({splitId: panel.handle.id,scopeId: scopeId(),@@ -384,6 +395,9 @@ export const SoupViewList = (props: SoupViewListProps) => {virtualizerHandle,previewState: () => !!soup.previewEntity(),getSplitCount,+ currentView,+ activeTab,+ applyTabPreset,});// Register previewed entity for auto-attachdiff --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 2c34ea88aa..8b3f640cf3 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@@ -15,7 +15,8 @@ import { onCleanup, type Accessor } from 'solid-js';import type { VirtualizerHandle } from 'virtua/solid';import type { SoupState } from '../create-soup-state';import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';-import { isListViewID } from '@app/constants/list-views';+import { isListViewID, type ListView } from '@app/constants/list-views';+import { VIEW_TAB_PRESETS } from '@app/component/app-sidebar/soup-filter-presets';type UseSoupViewHotkeysOptions = {splitId: string;@@ -25,6 +26,9 @@ type UseSoupViewHotkeysOptions = {virtualizerHandle: Accessor<VirtualizerHandle | undefined>;previewState: Accessor<boolean>;getSplitCount: () => number;+ currentView: Accessor<ListView | undefined>;+ activeTab: Accessor<string | undefined>;+ applyTabPreset: (view: ListView, tabId: string) => void;};export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {@@ -35,6 +39,9 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {virtualizerHandle,previewState,getSplitCount,+ currentView,+ activeTab,+ applyTabPreset,} = options;const splitIsUnifiedList = () => isListViewID(splitHandle.content().id);@@ -295,5 +302,90 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {hide: true,}).withGroup(group);+ const getTabKeys = () => {+ const view = currentView();+ if (!view) return [];+ const config = VIEW_TAB_PRESETS[view];+ if (!config) return [];+ return Object.keys(config.tabs);+ };++ const switchToTabIndex = (index: number) => {+ const view = currentView();+ if (!view) return false;+ const tabKeys = getTabKeys();+ if (index < 0 || index >= tabKeys.length) return false;+ applyTabPreset(view, tabKeys[index]!);+ return true;+ };++ // 1-9 number keys to jump to specific tabs+ const tabNumberKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] as const;+ for (let i = 0; i < tabNumberKeys.length; i++) {+ const index = i;+ const key = tabNumberKeys[i]!;+ registerHotkey({+ hotkey: key,+ scopeId,+ hotkeyToken: TOKENS.soup.tabs[key],+ description: `Switch to tab ${key}`,+ condition: () => getTabKeys().length > index,+ keyDownHandler: () => switchToTabIndex(index),+ hide: true,+ }).withGroup(group);+ }++ // fall back to the view's default tab if the soup view active tab accessor+ // returns undefined+ const getCurrentTabIndex = () => {+ const tabKeys = getTabKeys();+ const current = activeTab();+ if (current) {+ const idx = tabKeys.indexOf(current);+ if (idx !== -1) return idx;+ }+ const view = currentView();+ if (!view) return 0;+ const config = VIEW_TAB_PRESETS[view];+ if (!config) return 0;+ const defaultIdx = tabKeys.indexOf(config.default);+ return defaultIdx !== -1 ? defaultIdx : 0;+ };++ // tab - Next tab+ registerHotkey({+ hotkey: ['tab'],+ scopeId,+ hotkeyToken: TOKENS.soup.tabs.next,+ description: 'Next tab',+ condition: () => getTabKeys().length > 1,+ keyDownHandler: () => {+ const view = currentView();+ if (!view) return false;+ const tabKeys = getTabKeys();+ const nextIndex = (getCurrentTabIndex() + 1) % tabKeys.length;+ applyTabPreset(view, tabKeys[nextIndex]!);+ return true;+ },+ }).withGroup(group);++ // shift+tab - Previous tab+ registerHotkey({+ hotkey: ['shift+tab'],+ scopeId,+ hotkeyToken: TOKENS.soup.tabs.prev,+ description: 'Previous tab',+ condition: () => getTabKeys().length > 1,+ keyDownHandler: () => {+ const view = currentView();+ if (!view) return false;+ const tabKeys = getTabKeys();+ const prevIndex =+ (getCurrentTabIndex() - 1 + tabKeys.length) % tabKeys.length;+ applyTabPreset(view, tabKeys[prevIndex]!);+ return true;+ },+ }).withGroup(group);+onCleanup(() => group.dispose());};diff --git a/js/app/packages/core/hotkey/tokens.ts b/js/app/packages/core/hotkey/tokens.tsindex 0f0ae9b875..1499aff774 100644--- a/js/app/packages/core/hotkey/tokens.ts+++ b/js/app/packages/core/hotkey/tokens.ts@@ -13,6 +13,8 @@ export const TOKENS = {'7': 'soup.tabs.7','8': 'soup.tabs.8','9': 'soup.tabs.9',+ next: 'soup.tabs.next',+ prev: 'soup.tabs.prev',},},