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
Revert "fix(settings): fix hotkey nav and cmd k from settings" (#4605)
Aidan Holloway-Bidwell2d1b082a7134
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex c687fd6f16..2253d44330 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -1,6 +1,5 @@import {AppSidebar,- GoToHotkeys,type SidebarState,} from '@app/component/app-sidebar/sidebar';import {@@ -143,7 +142,6 @@ function LayoutInner(props: RouteSectionProps) {</Show><GlobalShortcuts /><Show when={!isMobile()}>- <GoToHotkeys /><Suspense><FavoritesCommands /><CommandMenu />diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsxindex 68d63a7157..4e6fba1aa5 100644--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx@@ -284,8 +284,13 @@ type AppSidebarProps = {};type SidebarHotkeyDeps = {+ links: () => SidebarItem[];+ hotkeyVisible: () => boolean;+ setHotkeyVisible: (visible: boolean) => void;+ resetHotkeysState: VoidFunction;isSlim: () => boolean;onOpenChange: (open: boolean) => void;+ openWithSplit: ReturnType<typeof useSplitLayout>['openWithSplit'];};type OpenWithSplitFn = ReturnType<typeof useSplitLayout>['openWithSplit'];@@ -344,74 +349,16 @@ function navigateToSidebarView(args: {}const registerSidebarHotkeys = ({+ links,isSlim,onOpenChange,+ openWithSplit,+ hotkeyVisible,+ setHotkeyVisible,+ resetHotkeysState,}: SidebarHotkeyDeps) => {- registerHotkey({- scopeId: 'global',- hotkeyToken: TOKENS.global.inviteTeam,- description: 'Send Invites',- keyDownHandler: (e) => {- e?.preventDefault();- setInviteModalOpen(true);- return true;- },- });-- registerHotkey({- hotkey: 'cmd+.',- scopeId: 'global',- hotkeyToken: TOKENS.global.toggleSidebar,- description: 'Toggle sidebar and side panels',- runWithInputFocused: true,- keyDownHandler: (e) => {- e?.preventDefault();- const show = isSlim();- onOpenChange(show);- setAllSidePanelsOpen(show);- return true;- },- });-};--/**- * Whether the "g" leader key is currently awaiting a destination key. Lives- * at module scope so it can drive the hint overlay on `AppSidebar`'s nav- * icons even though the registration below is owned by `GoToHotkeys`, which- * stays mounted regardless of whether the sidebar itself is visible.- */-const [goToHotkeyVisible, setGoToHotkeyVisible] = createSignal(false);--const resetGoToHotkeysState = () => {- setGoToHotkeyVisible(false);- // To prevent the next key from triggering the hotkey handler,- // we reset the pressed keys state and exit the command scope- clearPressedKeys();- activateClosestDOMScope();-};--/**- * Registers the "g" leader key and the per-link "go to" nav hotkeys (e.g.- * "g i" for inbox). Rendered unconditionally from `Layout` — unlike- * `AppSidebar`, which unmounts on full-cover routes like settings — so these- * shortcuts keep working everywhere in the app.- */-export const GoToHotkeys = () => {- const { openWithSplit } = useSplitLayout();-- const homeViewEnabled = useFeatureFlag('enable-home-view', {- enabledOverride: ENABLE_HOME_OVERRIDE,- });-- const links = createMemo((): SidebarItem[] =>- buildSidebarLinks(homeViewEnabled().enabled)- );-- const debounceResetHotkeysState = debounce(resetGoToHotkeysState, 2000);- const debounceSetHotkeyVisible = debounce(- () => setGoToHotkeyVisible(true),- 200- );+ const debounceResetHotkeysState = debounce(resetHotkeysState, 2000);+ const debounceSetHotkeyVisible = debounce(() => setHotkeyVisible(true), 200);// Register 'g' as a leader key that activates the global GO_TO command scoperegisterHotkey({@@ -442,7 +389,7 @@ export const GoToHotkeys = () => {// If a hotkey is going to be fired, but the hotkeys are not// visible, then it's not a sidebar nav hotkey and we can// ignore it and reset our visible state- if (!goToHotkeyVisible()) {+ if (!hotkeyVisible()) {debounceSetHotkeyVisible.clear();return false;}@@ -456,12 +403,38 @@ export const GoToHotkeys = () => {return false;}- resetGoToHotkeysState();+ resetHotkeysState();debounceResetHotkeysState.clear();return true;});+ registerHotkey({+ scopeId: 'global',+ hotkeyToken: TOKENS.global.inviteTeam,+ description: 'Send Invites',+ keyDownHandler: (e) => {+ e?.preventDefault();+ setInviteModalOpen(true);+ return true;+ },+ });++ registerHotkey({+ hotkey: 'cmd+.',+ scopeId: 'global',+ hotkeyToken: TOKENS.global.toggleSidebar,+ description: 'Toggle sidebar and side panels',+ runWithInputFocused: true,+ keyDownHandler: (e) => {+ e?.preventDefault();+ const show = isSlim();+ onOpenChange(show);+ setAllSidePanelsOpen(show);+ return true;+ },+ });+// Register navigation shortcuts in the global GO_TO command scope.// This must be reactive because prod feature flags can add links after the// initial render (e.g. Home), and Hotkey UI resolves tokens from the registry.@@ -469,8 +442,8 @@ export const GoToHotkeys = () => {const disposers = links().map((link) => {const openSidebarView = (e?: KeyboardEvent) => {e?.preventDefault();- if (goToHotkeyVisible()) {- resetGoToHotkeysState();+ if (hotkeyVisible()) {+ resetHotkeysState();debounceResetHotkeysState.clear();}@@ -516,8 +489,6 @@ export const GoToHotkeys = () => {}});});-- return null;};/** Session-only signal so a hint shows after dismissal until the user acknowledges or the timer expires. */@@ -724,30 +695,6 @@ const DASHBOARD_LINK: SidebarItem = {hotkeyToken: TOKENS.sidebar.goTo.home,};-/**- * Assemble the ordered sidebar link list: the static links plus the flag-gated- * Home and Calls entries in their correct positions. Shared by the rendered- * sidebar (`AppSidebar.visibleLinks`) and the always-mounted `GoToHotkeys`- * registrar so their link sets can't drift. Call from a reactive context — it- * reads `ENABLE_CALLS()`; `homeEnabled` is passed in so the caller tracks the- * feature-flag read. `visibleLinks` additionally drops `hiddenFromSidebar`- * entries, which have hotkeys but no sidebar row.- */-const buildSidebarLinks = (homeEnabled: boolean): SidebarItem[] => {- let links: SidebarItem[] = [...SIDEBAR_LINKS];-- if (homeEnabled) {- links = [DASHBOARD_LINK, ...links];- }-- if (ENABLE_CALLS()) {- const idx = links.findIndex((l) => l.id === 'channels');- links = [...links.slice(0, idx + 1), CALLS_LINK, ...links.slice(idx + 1)];- }-- return links;-};-/*** Settings tabs surfaced as always-visible quick links above the settings* widget. Label/icon come from the settings tab config (see@@ -760,6 +707,7 @@ const PROMOTED_SETTINGS_TABS: SettingsTab[] = [];export const AppSidebar = (props: AppSidebarProps) => {+ const layout = useSplitLayout();const { openSettings, selectTab, settingsOpen } = useSettingsState();const isTabAvailable = useSettingsTabAvailable();const callCtx = useCallContextOptional();@@ -780,11 +728,46 @@ export const AppSidebar = (props: AppSidebarProps) => {enabledOverride: ENABLE_NEW_PRICING_OVERRIDE,});- const visibleLinks = createMemo((): SidebarItem[] =>- buildSidebarLinks(homeViewEnabled().enabled).filter(- (link) => !link.hiddenFromSidebar- )- );+ const [hotkeyVisible, setHotkeyVisible] = createSignal(false);++ const visibleLinks = createMemo((): SidebarItem[] => {+ let links: SidebarItem[] = [...SIDEBAR_LINKS];++ if (homeViewEnabled().enabled) {+ links = [DASHBOARD_LINK, ...links];+ }++ if (ENABLE_CALLS()) {+ const idx = links.findIndex((l) => l.id === 'channels');+ links = [...links.slice(0, idx + 1), CALLS_LINK, ...links.slice(idx + 1)];+ }++ return links.filter((link) => !link.hiddenFromSidebar);+ });++ const hotkeyLinks = createMemo((): SidebarItem[] => {+ let links: SidebarItem[] = [...SIDEBAR_LINKS];++ if (homeViewEnabled().enabled) {+ links = [DASHBOARD_LINK, ...links];+ }++ if (ENABLE_CALLS()) {+ const idx = links.findIndex((l) => l.id === 'channels');+ links = [...links.slice(0, idx + 1), CALLS_LINK, ...links.slice(idx + 1)];+ }++ return links;+ });++ const resetHotkeysState = () => {+ setHotkeyVisible(false);++ // To prevent the next key from triggering the hotkey handler,+ // we reset the pressed keys state and exit the command scope+ clearPressedKeys();+ activateClosestDOMScope();+ };const openSettingsTab = (tab: SettingsTab) => {if (!isTabAvailable(tab)) return;@@ -806,8 +789,13 @@ export const AppSidebar = (props: AppSidebarProps) => {});registerSidebarHotkeys({+ links: hotkeyLinks,+ hotkeyVisible,+ setHotkeyVisible,+ resetHotkeysState,isSlim,onOpenChange: handleSidebarOpenChange,+ openWithSplit: layout.openWithSplit,});return (@@ -860,7 +848,7 @@ export const AppSidebar = (props: AppSidebarProps) => {component={link.id === 'mail' ? SidebarMailLink : SidebarLink}{...link}sidebarState={props.sidebarState ?? 'expanded'}- hotkeyVisible={goToHotkeyVisible()}+ hotkeyVisible={hotkeyVisible()}/></li>)}diff --git a/js/app/packages/app/component/split-layout/layout.ts b/js/app/packages/app/component/split-layout/layout.tsindex 30133e2e9c..f326220754 100644--- a/js/app/packages/app/component/split-layout/layout.ts+++ b/js/app/packages/app/component/split-layout/layout.ts@@ -1,12 +1,6 @@-import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';-import { isSettingsPath } from '@core/constant/settingsPath';import { isMobile } from '@core/mobile/isMobile';-import { useLocation, useNavigate } from '@solidjs/router';import { useContext } from 'solid-js';-import {- globalSplitManager,- whenSplitManagerReady,-} from '../../signal/splitLayout';+import { globalSplitManager } from '../../signal/splitLayout';import { SplitPanelContext } from './context';import type {OpenWithSplitOptions,@@ -16,33 +10,19 @@ import type {export function useSplitLayout() {const splitPanelContext = useContext(SplitPanelContext);- const navigate = useNavigate();- const location = useLocation();function openWithSplit(content: SplitContent,options?: OpenWithSplitOptions) {const splitManager = globalSplitManager();- const preferNewSplit = isMobile() ? false : options?.preferNewSplit;-if (!splitManager) {- if (!isSettingsPath(location.pathname)) {- console.error('No split manager found');- return;- }-- // Settings is a full-cover route with no split layout mounted, so- // hotkey/command-menu navigation triggered from there has nowhere to- // open content. Leave settings for the default workspace route, then- // finish the open once its split manager mounts.- navigate(DEFAULT_ROUTE, { replace: true });- void whenSplitManagerReady().then((manager) =>- manager.openWithSplit(content, { ...options, preferNewSplit })- );+ console.error('No split manager found');return;}+ const preferNewSplit = isMobile() ? false : options?.preferNewSplit;+return splitManager.openWithSplit(content, {...options,preferNewSplit,@@ -53,6 +33,12 @@ export function useSplitLayout() {content: SplitContent,referredFrom: ReferredFrom = null) {+ const splitManager = globalSplitManager();+ if (!splitManager) {+ console.error('No split manager found');+ return;+ }+return openWithSplit(content, {referredFrom,handle: splitPanelContext?.handle,diff --git a/js/app/packages/core/constant/SettingsState.tsx b/js/app/packages/core/constant/SettingsState.tsxindex 973da3a635..3699f56aff 100644--- a/js/app/packages/core/constant/SettingsState.tsx+++ b/js/app/packages/core/constant/SettingsState.tsx@@ -1,16 +1,14 @@import { useSplitLayout } from '@app/component/split-layout/layout';import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';+import { ROUTER_BASE } from '@app/constants/routerBase';import { globalSplitManager } from '@app/signal/splitLayout';import { isMobile } from '@core/mobile/isMobile';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { activeTabId, setActiveTabId } from '@core/signal/settingsTab';import { useLocation, useNavigate } from '@solidjs/router';import { createMemo, createSignal } from 'solid-js';-import { isSettingsPath, SETTINGS_PATH, toBaseRelative } from './settingsPath';import { settingsSlugToTab, settingsTabToSlug } from './settingsTabsConfig';-export { isSettingsPath };-export type SettingsTab =| 'Account'| 'Billing'@@ -34,9 +32,31 @@ export type SettingsTab =// which case we fall back to DEFAULT_ROUTE.const [settingsReturnTo, setSettingsReturnTo] = createSignal<string>();+const SETTINGS_PATH = '/settings';+const settingsPathFor = (tab: SettingsTab) =>`${SETTINGS_PATH}/${settingsTabToSlug(tab)}`;+/**+ * Strip the router base from a `location.pathname` (which includes it, e.g.+ * `/app/settings`) so it can be compared to — and reused with — the+ * base-relative paths that `navigate()` and route definitions use.+ */+const toBaseRelative = (pathname: string) => {+ if (ROUTER_BASE === '/') return pathname;+ if (pathname === ROUTER_BASE) return '/';+ if (pathname.startsWith(`${ROUTER_BASE}/`)) {+ return pathname.slice(ROUTER_BASE.length);+ }+ return pathname;+};++/** Whether a `location.pathname` (base included) is the settings route. */+export const isSettingsPath = (pathname: string) => {+ const path = toBaseRelative(pathname);+ return path === SETTINGS_PATH || path.startsWith(`${SETTINGS_PATH}/`);+};+/*** Drop a settings split from a split-layout path, if present. Handles both the* URL encoding (`settings/<tab>`) and the legacy internal formdiff --git a/js/app/packages/core/constant/settingsPath.ts b/js/app/packages/core/constant/settingsPath.tsdeleted file mode 100644index a2c962da8b..0000000000--- a/js/app/packages/core/constant/settingsPath.ts+++ /dev/null@@ -1,23 +0,0 @@-import { ROUTER_BASE } from '@app/constants/routerBase';--export const SETTINGS_PATH = '/settings';--/**- * Strip the router base from a `location.pathname` (which includes it, e.g.- * `/app/settings`) so it can be compared to — and reused with — the- * base-relative paths that `navigate()` and route definitions use.- */-export const toBaseRelative = (pathname: string) => {- if (ROUTER_BASE === '/') return pathname;- if (pathname === ROUTER_BASE) return '/';- if (pathname.startsWith(`${ROUTER_BASE}/`)) {- return pathname.slice(ROUTER_BASE.length);- }- return pathname;-};--/** Whether a `location.pathname` (base included) is the settings route. */-export const isSettingsPath = (pathname: string) => {- const path = toBaseRelative(pathname);- return path === SETTINGS_PATH || path.startsWith(`${SETTINGS_PATH}/`);-};