Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(create): chg mobile soup create btn to onClick, removce duplicate hk registraction for create (#3172)

Seamusfa4e809b876d
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsx
index 02276eedea..0d9d17944f 100644
--- a/js/app/packages/app/component/GlobalHotkeys.tsx
+++ b/js/app/packages/app/component/GlobalHotkeys.tsx
@@ -7,7 +7,6 @@ import { toast } from '@core/component/Toast/Toast';
import { LOCAL_ONLY } from '@core/constant/featureFlags';
import { useSettingsState } from '@core/constant/SettingsState';
import { TOKENS } from '@core/hotkey/tokens';
-import type { ValidHotkey } from '@core/hotkey/types';
import {
handleFolderSelect,
openFilePicker,
@@ -34,11 +33,7 @@ import {
import { applyTheme } from '../../theme/utils/themeUtils';
import { globalSplitManager } from '../signal/splitLayout';
import { CommandState } from './command';
-import {
- CREATABLE_BLOCKS,
- createMenuOpen,
- setCreateMenuOpen,
-} from './Launcher';
+import { createMenuOpen, setCreateMenuOpen } from './Launcher';
import { openMacroMcpSetupModal } from './macro-mcp-setup-modal/MacroMcpSetupModal';
import { useSplitLayout } from './split-layout/layout';
@@ -111,7 +106,7 @@ export default function GlobalShortcuts() {
CommandState.toggle();
};
- const createCommandScope = registerHotkey({
+ registerHotkey({
hotkeyToken: TOKENS.global.createCommand,
hotkey: 'c',
scopeId: 'global',
@@ -130,34 +125,6 @@ export default function GlobalShortcuts() {
activateCommandScope: true,
});
- for (const block of CREATABLE_BLOCKS) {
- registerHotkey({
- hotkeyToken: block.hotkeyToken,
- hotkey: block.hotkey,
- scopeId: createCommandScope.commandScopeId,
- description: block.description,
- runWithInputFocused: true,
- keyDownHandler: () => {
- block.keyDownHandler();
- return true;
- },
- });
-
- if (block.altHotkeyToken) {
- registerHotkey({
- hotkeyToken: block.altHotkeyToken,
- hotkey: `opt+${block.hotkey}` as ValidHotkey,
- scopeId: createCommandScope.commandScopeId,
- description: `${block.description} in new split`,
- runWithInputFocused: true,
- keyDownHandler: () => {
- block.keyDownHandler();
- return true;
- },
- });
- }
- }
-
registerHotkey({
hotkeyToken: TOKENS.global.commandMenu,
hotkey: 'cmd+k',
diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsx
index dc2cb23c19..37b5ad1a70 100644
--- a/js/app/packages/app/component/Launcher.tsx
+++ b/js/app/packages/app/component/Launcher.tsx
@@ -3,9 +3,12 @@ import { setAutomationComposerOpen } from '@block-automation/component';
import type { BlockAlias, BlockName } from '@core/block';
import { getIconConfig } from '@core/component/EntityIcon';
import { Hotkey } from '@core/component/Hotkey';
-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';
import { ENABLE_ANIMATED_ICONS } from '@core/constant/featureFlags';
-import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
+import {
+ createHotkeyGroup,
+ registerHotkey,
+ useHotkeyDOMScope,
+} from '@core/hotkey/hotkeys';
import { pressedKeys } from '@core/hotkey/state';
import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';
import type {
@@ -358,8 +361,6 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
},
];
-const USE_ENTITY_COLORS = true;
-
export const [createMenuOpen, setCreateMenuOpen] = createControlledOpenSignal(
false,
{ id: 'launcher' }
@@ -381,10 +382,7 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {
}
});
- const textFg = () =>
- USE_ENTITY_COLORS
- ? getIconConfig(props.creatableBlock.blockName).foreground
- : 'text-accent';
+ const textFg = () => getIconConfig(props.creatableBlock.blockName).foreground;
const StaticIcon = props.creatableBlock.icon;
const AnimatedIcon = props.creatableBlock.animatedIcon;
@@ -393,7 +391,7 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {
<Layer depth={2}>
<button
class={cn(
- ' size-28 relative flex flex-col sm:gap-4 gap-2 items-center isolate justify-center bg-panel border border-edge-muted transition-transform ease-click duration-200',
+ ' size-28 relative flex flex-col sm:gap-4 gap-2 items-center isolate justify-center bg-panel ring ring-edge-muted transition-transform ease-click duration-200 rounded-sm',
`create-menu-${props.creatableBlock.label.toLowerCase()}`,
{
'-translate-y-2 text-ink bg-active': props.focused,
@@ -409,28 +407,6 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {
buttonRef?.focus();
}}
>
- {/** TODO (seamus): we need to pool/cache these canvases. they brick the color picker/or any other gl context
- because they do not get garbage collected fast enough */}
- {/*<div
- class="inset-0 absolute bg-panel opacity-2 mask-b-from-0% mask-b-to-100%"
- classList={{
- 'text-ink-extra-muted opacity-2': !props.focused,
- [textFg() + ' opacity-50']: props.focused,
- }}
- >
- <PcNoiseGrid
- cellSize={21 / 2}
- rounding={10}
- warp={0}
- freq={0.002}
- crunch={0.4}
- size={[0.0, 0.2]}
- fill={1}
- stroke={0}
- speed={[props.focused ? 0.3 : 0, 0]}
- />
- </div>*/}
-
<div
class={cn(
'absolute size-full inset-0 transition-transform origin-top opacity-20 ease duration-200 mix-blend-color',
@@ -491,6 +467,7 @@ type LauncherInnerProps = {
};
export const LauncherInner = (props: LauncherInnerProps) => {
+ const hkGroup = createHotkeyGroup();
const blocks = () => props.blocks ?? CREATABLE_BLOCKS;
const [attachHotkeys, launcherScope] = useHotkeyDOMScope('create-menu', true);
@@ -562,20 +539,20 @@ export const LauncherInner = (props: LauncherInnerProps) => {
props.onClose(false);
return true;
},
- });
+ }).withGroup(hkGroup);
if (item.altHotkeyToken) {
registerHotkey({
hotkeyToken: item.altHotkeyToken,
hotkey: `shift+${item.hotkey}` as ValidHotkey,
scopeId: launcherScope,
- description: `${item.description} in current split`,
+ description: `${item.description} in new split`,
keyDownHandler: () => {
item.keyDownHandler();
props.onClose();
return true;
},
- });
+ }).withGroup(hkGroup);
}
});
@@ -588,20 +565,21 @@ export const LauncherInner = (props: LauncherInnerProps) => {
setCreateMenuOpen(false);
return true;
},
- });
+ }).withGroup(hkGroup);
+
registerHotkey({
hotkey: ['arrowleft', 'h'],
scopeId: launcherScope,
description: 'Navigate Left',
keyDownHandler: () => moveFocus(-1),
- });
+ }).withGroup(hkGroup);
registerHotkey({
hotkey: ['arrowright', 'l'],
scopeId: launcherScope,
description: 'Navigate Right',
keyDownHandler: () => moveFocus(1),
- });
+ }).withGroup(hkGroup);
registerHotkey({
hotkey: ['arrowup', 'k'],
@@ -611,7 +589,7 @@ export const LauncherInner = (props: LauncherInnerProps) => {
e?.preventDefault();
return moveFocus(-getColumnCount());
},
- });
+ }).withGroup(hkGroup);
registerHotkey({
hotkey: ['arrowdown', 'j'],
@@ -621,7 +599,7 @@ export const LauncherInner = (props: LauncherInnerProps) => {
e?.preventDefault();
return moveFocus(getColumnCount());
},
- });
+ }).withGroup(hkGroup);
registerHotkey({
hotkey: 'escape',
@@ -631,10 +609,10 @@ export const LauncherInner = (props: LauncherInnerProps) => {
props.onClose();
return true;
},
- });
+ }).withGroup(hkGroup);
registerHotkey({
- hotkey: 'enter',
+ hotkey: 'shift+enter',
scopeId: launcherScope,
description: 'Open in new split',
keyDownHandler: () => {
@@ -644,7 +622,7 @@ export const LauncherInner = (props: LauncherInnerProps) => {
},
runWithInputFocused: true,
displayPriority: 7,
- });
+ }).withGroup(hkGroup);
registerHotkey({
hotkey: 'enter' as ValidHotkey,
@@ -657,7 +635,7 @@ export const LauncherInner = (props: LauncherInnerProps) => {
},
runWithInputFocused: true,
displayPriority: 8,
- });
+ }).withGroup(hkGroup);
onMount(() => {
const onKeyDown = (e: KeyboardEvent) => {
@@ -673,18 +651,17 @@ export const LauncherInner = (props: LauncherInnerProps) => {
onMount(() => {
if (!ref) return;
-
attachHotkeys(ref);
-
setTimeout(() => {
const firstItem = blocks()[0];
-
if (firstItem) {
focusMenuItem(firstItem.label);
}
- }, 0);
+ });
});
+ onCleanup(hkGroup.dispose);
+
// horrible but tailwind requires the full strings
const gridColsClass = () => {
const length = blocks().length;
@@ -757,34 +734,10 @@ type LauncherProps = {
};
export const Launcher = (props: LauncherProps) => {
- const useJuicedScrim = false;
-
return (
<Dialog open={props.open} onOpenChange={props.onOpenChange} modal={true}>
<Dialog.Portal>
- <Dialog.Overlay
- class={cn(
- 'fixed inset-0 z-modal bg-modal-overlay pattern-diagonal-4 pattern-edge-muted',
- {
- 'backdrop-filter-[blur(0.5px)]': useJuicedScrim,
- }
- )}
- >
- <Show when={useJuicedScrim}>
- <div class="absolute pointer-events-none size-full inset-0 bg-modal-overlay text-ink opacity-5">
- <PcNoiseGrid
- cellSize={20}
- crunch={0.379}
- size={[0, 1]}
- speed={[0.03, 0.4]}
- circleMask={1}
- stroke={1}
- fill={0}
- />
- </div>
- </Show>
- </Dialog.Overlay>
-
+ <Dialog.Overlay class="fixed inset-0 z-modal bg-modal-overlay pattern-diagonal-4 pattern-edge-muted"></Dialog.Overlay>
<Dialog.Content>
<Layer depth={1}>
<div
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx
index 52cb229113..bb46d63b3d 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-mobile-create-button.tsx
@@ -96,11 +96,12 @@ export function SoupViewMobileCreateButton(props: {
<button
type="button"
class="absolute bottom-4 right-4 z-10 pl-3 pr-4 py-2 rounded-full bg-panel ring text-accent flex items-center justify-center gap-2 shadow-md ring-accent/20"
- onPointerDown={() => {
+ onClick={() => {
hapticImpact('light');
setAnimating(true);
setTimeout(() => setAnimating(false), ICON_ANIMATION_DURATION_MS);
- createAction()?.();
+ // Defer to next frame to avoid focus race with Dialog
+ requestAnimationFrame(() => createAction()?.());
}}
>
<div class="size-5 [&_svg]:size-5">