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(command): fix ghost hotkeys (#919)
Seamus72bec39f1cfc
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsxindex d78e97ae37..e911bd6959 100644--- a/js/app/packages/app/component/Soup.tsx+++ b/js/app/packages/app/component/Soup.tsx@@ -209,7 +209,7 @@ const PreviewPanel: Component<{splitPanelContext: SplitPanelContextType;}> = (props) => {return (- <div class="flex flex-row size-full sm:w-[70%] max-sm:h-[50%] max-sm:border-t border-edge-muted shrink-0 sm:shadow-inner">+ <div class="flex flex-row size-full sm:w-[70%] max-sm:h-[50%] max-sm:border-t border-edge-muted shrink-0"><Showwhen={props.selectedEntity?.type !== 'project' && props.selectedEntity}>diff --git a/js/app/packages/app/component/command/KonsoleItem.tsx b/js/app/packages/app/component/command/KonsoleItem.tsxindex 8858e80962..6cab21c028 100644--- a/js/app/packages/app/component/command/KonsoleItem.tsx+++ b/js/app/packages/app/component/command/KonsoleItem.tsx@@ -20,7 +20,7 @@ import {} from '@core/hotkey/getCommands';import { pressedKeys } from '@core/hotkey/state';import type { HotkeyCommand } from '@core/hotkey/types';-import { runCommand } from '@core/hotkey/utils';+import { hasValidHotkey, runCommand } from '@core/hotkey/utils';import type { BlockOrchestrator } from '@core/orchestrator';import { type ChannelWithParticipants, idToDisplayName } from '@core/user';import PushPin from '@phosphor-icons/core/regular/push-pin.svg?component-solid';@@ -47,6 +47,7 @@ import {onCleanup,onMount,type Setter,+ Show,Switch,} from 'solid-js';import { createStore } from 'solid-js/store';@@ -631,17 +632,19 @@ export function CommandItemCard(props: CommandItemProps) {};const CommandItemHotkey = () => {- if (props.item.type !== 'command') return null;- if (props.item.data.command.hotkeys?.length === 0) return null;+ const token = () => {+ if (props.item.type !== 'command') return;+ return props.item.data.command.hotkeyToken;+ };+ const validToken = () => hasValidHotkey(token());return (- <div class="pr-2 flex items-center justify-center text-[0.75rem] font-medium text-ink-extra-muted">- <div class="p-2 py-0.5 border border-edge-muted/50 rounded-xs">- <Hotkey- shortcut={props.item.data.command.hotkeys?.at(0)}- class="flex gap-1 items-center"- />+ <Show when={validToken()}>+ <div class="pr-2 flex items-center justify-center text-[0.75rem] font-medium text-ink-extra-muted">+ <div class="p-2 py-0.5 border border-edge-muted/50 rounded-xs">+ <Hotkey token={token()} class="flex gap-1 items-center" />+ </div></div>- </div>+ </Show>);};diff --git a/js/app/packages/core/component/Hotkey.tsx b/js/app/packages/core/component/Hotkey.tsxindex ffa40e907b..6d4a16024d 100644--- a/js/app/packages/core/component/Hotkey.tsx+++ b/js/app/packages/core/component/Hotkey.tsx@@ -150,25 +150,37 @@ export const Hotkey = (props: HotkeyProps) => {: key.map((k) => k.toUpperCase());};+ // Don't render anything if there are no modifiers and no key+ const hasContent = () => {+ const h = hotkey();+ const key = normalizedKey();+ return (+ h.modifiers.length > 0 ||+ (key && (typeof key === 'string' ? key.length > 0 : key.length > 0))+ );+ };+return (- <div {...rest}>- <For each={hotkey().modifiers}>- {(mod) => (- <>- <span class="text-current">- {modifierMap[mod as keyof typeof modifierMap] || mod}- </span>+ <Show when={hasContent()}>+ <div {...rest}>+ <For each={hotkey().modifiers}>+ {(mod) => (+ <>+ <span class="text-current">+ {modifierMap[mod as keyof typeof modifierMap] || mod}+ </span>- <Show when={local.showPlus}>- <span class="text-current"> + </span>- </Show>- </>- )}- </For>- <Show when={normalizedKey()}>- <span class="text-current">{normalizedKey()}</span>- </Show>- </div>+ <Show when={local.showPlus}>+ <span class="text-current"> + </span>+ </Show>+ </>+ )}+ </For>+ <Show when={normalizedKey()}>+ <span class="text-current">{normalizedKey()}</span>+ </Show>+ </div>+ </Show>);};diff --git a/js/app/packages/core/hotkey/utils.ts b/js/app/packages/core/hotkey/utils.tsindex 8f671885d0..a13ab6dc8a 100644--- a/js/app/packages/core/hotkey/utils.ts+++ b/js/app/packages/core/hotkey/utils.ts@@ -510,3 +510,20 @@ export const useIsInCommandScope = () => {return scopeNode?.type === 'command';});};++/**+ * Look up a hotkey token and return true if a usable hotkey is mapped to that+ * token right now.+ * @param shortcut+ * @returns+ */+export const hasValidHotkey = (shortcut?: HotkeyToken) => {+ if (!shortcut) return false;+ const tokenShortcut = getPrettyHotkeyStringByToken(shortcut);+ if (!tokenShortcut) return false;+ const parts = tokenShortcut+ .split('+')+ .map((part) => part.trim())+ .filter(Boolean);+ return parts.length > 0 && parts.some((part) => part.length > 0);+};