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(sidebar): show g-leader key hints on rail buttons (#8900)
Jacob Beckerman70400995a9d3
diff --git a/apps/web/src/components/app/app-sidebar/sidebar.tsx b/apps/web/src/components/app/app-sidebar/sidebar.tsxindex a2b286ebe2..c076983ad7 100644--- a/apps/web/src/components/app/app-sidebar/sidebar.tsx+++ b/apps/web/src/components/app/app-sidebar/sidebar.tsx@@ -32,11 +32,10 @@ import {enableCrm,enableTasksReviews,enableWhatsappLinked,- isFeatureEnabled,} from '@core/constant/featureFlags';import { getRunnableHotkeys } from '@core/hotkey/getCommands';import { registerHotkey } from '@core/hotkey/hotkeys';-import { clearPressedKeys } from '@core/hotkey/state';+import { activeScope, clearPressedKeys } from '@core/hotkey/state';import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';import type { ValidHotkey } from '@core/hotkey/types';import { activateClosestDOMScope } from '@core/hotkey/utils';@@ -196,6 +195,14 @@ export function navigateToSidebarView(args: {/** Whether the "g" leader key is currently awaiting a destination key. */const [goToHotkeyVisible, setGoToHotkeyVisible] = createSignal(false);+/**+ * True while the "g" leader awaits a destination, so nav buttons can show+ * their destination key. Any key in the GoTo scope leaves it, including a+ * view's own GoTo command (Email's g s), so the hints clear with it.+ */+export const isGoToLeaderActive = () =>+ goToHotkeyVisible() && activeScope() === GO_TO_COMMAND_SCOPE;+const resetGoToHotkeysState = () => {setGoToHotkeyVisible(false);// To prevent the next key from triggering the hotkey handler,@@ -230,13 +237,15 @@ export const GoToHotkeys = () => {const recentViewEnabled = useRecentViewFlag();const reviews = useFeatureFlag(enableTasksReviews);const external = useFeatureFlag(enableWhatsappLinked);+ const crm = useFeatureFlag(enableCrm);const links = createMemo((): SidebarItem[] =>buildSidebarLinks(calendarUiEnabled(),activityFeedEnabled(),recentViewEnabled(),reviews().enabled,- external().enabled+ external().enabled,+ crm().enabled));@@ -431,15 +440,16 @@ const EXTERNAL_LINK: SidebarItem = {/*** Assemble the ordered sidebar link list: the static links plus the* flag-gated Recent, Activity, Calendar, Calls, Reviews, CRM, and External- * entries in their correct positions.- * Call from a reactive context — it reads `ENABLE_CALLS` / `isFeatureEnabled(enableCrm)`.+ * entries in their correct positions. Callers subscribe to the flags and pass+ * them in, so a flag that resolves after mount still rebuilds the list.*/const buildSidebarLinks = (showCalendar: boolean,showActivity: boolean,showRecent: boolean,showReviews: boolean,- showExternal: boolean+ showExternal: boolean,+ showCustomers: boolean): SidebarItem[] => {let links: SidebarItem[] = SIDEBAR_LINKS.filter((link) => showCalendar || link.id !== 'calendar'@@ -463,7 +473,7 @@ const buildSidebarLinks = (links = [...links.slice(0, idx + 1), CALLS_LINK, ...links.slice(idx + 1)];}- if (isFeatureEnabled(enableCrm)) {+ if (showCustomers) {// Customers sits just after Channels (and Calls when present).const anchorId = ENABLE_CALLS ? 'calls' : 'channels';const idx = links.findIndex((l) => l.id === anchorId);diff --git a/apps/web/src/components/app/sidebar-next/list-nav.test.tsx b/apps/web/src/components/app/sidebar-next/list-nav.test.tsxindex 7c8244d616..2327f06725 100644--- a/apps/web/src/components/app/sidebar-next/list-nav.test.tsx+++ b/apps/web/src/components/app/sidebar-next/list-nav.test.tsx@@ -25,6 +25,7 @@ const mocks = vi.hoisted(() => ({activeContent: (): { type: 'component'; id: string } | undefined => undefined,activePane: (): PaneId | undefined => undefined,navigate: vi.fn(),+ goToLeaderActive: (): boolean => false,}));vi.mock('@app/lib/analytics/analytics-context', () => ({@@ -40,6 +41,7 @@ vi.mock('@app/signal/splitLayout', () => ({}),}));vi.mock('@components/app/app-sidebar/sidebar', () => ({+ isGoToLeaderActive: () => mocks.goToLeaderActive(),navigateToSidebarView: mocks.navigate,sidebarContent: (id: string) => ({ type: 'component', id }),SidebarOpenInSplitMenu: (props: ParentProps) => props.children,@@ -58,12 +60,25 @@ vi.mock('@ui', async () => ({const [local, rest] = splitProps(props, ['label']);return <button type="button" aria-label={local.label} {...rest} />;},+ Hotkey: (props: { token: string }) => <span>{props.token}</span>,}));const home = SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'home')!;const agents = SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'agents')!;-function setup(initial = '/home', agentsPreload?: () => Promise<void>) {+function setup(+ initial = '/home',+ agentsPreload?: () => Promise<void>,+ navs: () => JSX.Element = () => (+ <>+ <ListNav item={home} />+ <ListNav item={agents} />+ <ListNav+ item={SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'calendar')!}+ />+ </>+ )+) {const history = createMemoryHistory(initial);let router!: ReturnType<typeof createSplitRouter>;let focus!: (pane: PaneId) => void;@@ -148,15 +163,7 @@ function setup(initial = '/home', agentsPreload?: () => Promise<void>) {onCleanup(() => router.dispose());return (<SplitRouter.Root router={router}>- <SidebarPrefsProvider>- <ListNav item={home} />- <ListNav item={agents} />- <ListNav- item={- SIDEBAR_NEXT_NAV_ITEMS.find((item) => item.id === 'calendar')!- }- />- </SidebarPrefsProvider>+ <SidebarPrefsProvider>{navs()}</SidebarPrefsProvider></SplitRouter.Root>);});@@ -185,6 +192,7 @@ function press(label: string) {afterEach(() => {cleanup();mocks.navigate.mockReset();+ mocks.goToLeaderActive = () => false;});describe('ListNav', () => {@@ -488,4 +496,40 @@ describe('ListNav', () => {expect(history.read().path).toBe('/settings');expectSelection();});++ it('shows each destination key while the g leader awaits one', () => {+ const [leaderActive, setLeaderActive] = createSignal(false);+ mocks.goToLeaderActive = leaderActive;+ const scheduling = SIDEBAR_NEXT_NAV_ITEMS.find(+ (item) => item.id === 'booking-links'+ )!;+ setup('/home', undefined, () => (+ <>+ <ListNav item={home} badge="12m" />+ <ListNav item={scheduling} />+ </>+ ));+ const hint = (label: string) =>+ screen+ .getByRole('button', { name: label })+ .querySelector('[data-sidebar-goto-hint]');+ const badge = () =>+ screen+ .getByRole('button', { name: 'Home' })+ .querySelector('[data-sidebar-badge]');++ expect(hint('Home')).toBeNull();+ expect(badge()).not.toBeNull();++ setLeaderActive(true);+ expect(hint('Home')).not.toBeNull();+ // Scheduling has no GoTo shortcut, so it gets no hint.+ expect(hint('Scheduling')).toBeNull();+ // The hint takes the meeting badge's place rather than overlapping it.+ expect(badge()).toBeNull();++ setLeaderActive(false);+ expect(hint('Home')).toBeNull();+ expect(badge()).not.toBeNull();+ });});diff --git a/apps/web/src/components/app/sidebar-next/list-nav.tsx b/apps/web/src/components/app/sidebar-next/list-nav.tsxindex 4dcc4d7a8a..047e1b928e 100644--- a/apps/web/src/components/app/sidebar-next/list-nav.tsx+++ b/apps/web/src/components/app/sidebar-next/list-nav.tsx@@ -3,6 +3,7 @@ import { useAnalytics } from '@app/lib/analytics/analytics-context';import { useSplitRouter } from '@app/lib/split-router';import { globalSplitManager } from '@app/signal/splitLayout';import {+ isGoToLeaderActive,navigateToSidebarView,SidebarOpenInSplitMenu,sidebarContent,@@ -12,7 +13,7 @@ import { MenuItem, MenuSeparator } from '@core/component/ContextMenu';import { TOKENS } from '@core/hotkey/tokens';import { fireAndForget } from '@core/util/fireAndForget';import PhoneCallIcon from '@icon/system/fill/phone-call-fill.svg';-import { Button, cn } from '@ui';+import { Button, cn, Hotkey } from '@ui';import { Show } from 'solid-js';import { NavGlyph } from './nav-glyph';import type { SidebarNextNavItem } from './nav-items';@@ -33,8 +34,9 @@ export type ListNavProps = {* behind it — active detection, navigation, shift-click into a new split, the* open-in-split context menu.*- * There is no room for a label or a `g`-leader hint in a 36px square, so both- * live in the tooltip instead.+ * There is no room for a label in a 40px square, so it lives in the tooltip+ * along with the full `g`-leader shortcut. After `g` is pressed, a small+ * badge in the corner shows the destination key, as the legacy sidebar did.** Named for the shape it grows into: each nav is expected to expand into a list* of its own live items (Email accounts, Chat channels, Drive files). The slot@@ -184,7 +186,7 @@ export const ListNav = (props: ListNavProps) => {<PhoneCallIcon class="size-full" /></span></Show>- <Show when={props.badge}>+ <Show when={!isGoToLeaderActive() && props.badge}>{(badge) => (<spanaria-hidden="true"@@ -195,6 +197,19 @@ export const ListNav = (props: ListNavProps) => {</span>)}</Show>+ <Show when={isGoToLeaderActive() && props.item.hotkeyToken}>+ {(token) => (+ <span+ aria-hidden="true"+ data-sidebar-goto-hint+ class="pointer-events-none absolute right-0.5 bottom-0.5 flex size-4 items-center justify-center overflow-hidden rounded-xs bg-page text-xs"+ >+ <span class="flex size-full items-center justify-center rounded-xs border border-accent/30 bg-accent/10 text-accent">+ <Hotkey token={token()} />+ </span>+ </span>+ )}+ </Show></Button></SidebarOpenInSplitMenu>);diff --git a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsxindex 13425563a6..4b9af17cee 100644--- a/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx+++ b/apps/web/src/components/app/sidebar-next/sidebar-rail.tsx@@ -33,8 +33,8 @@ function CalendarListNav(props: Omit<ListNavProps, 'badge'>) {* Always narrow by design — there is no slim mode or hover-peek overlay.* `cmd+.` toggles navigation in the active workspace. The `g`-prefixed* nav shortcuts are registered by `GoToHotkeys`, which `Layout` mounts- * separately. There is no room for leader-key hints on the buttons, so each- * button's tooltip carries its shortcut instead.+ * separately. Each button's tooltip carries its shortcut, and after `g` is+ * pressed each button shows its destination key in a corner badge.*/export const SidebarRail = () => (<SidebarPrefsProvider>