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.

feat(mobile): better create menu (#4239)

Peter Chinman85211af686f9
diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsx
index e43d6e4145..c16977817c 100644
--- a/js/app/packages/app/component/Launcher.tsx
+++ b/js/app/packages/app/component/Launcher.tsx
@@ -125,7 +125,13 @@ const createBlock = async (spec: {
});
} else {
openWithSplit(
- { type: blockName, id },
+ {
+ type: blockName,
+ id,
+ ...(createMdParams
+ ? { params: createMdParams, preserveParams: true }
+ : {}),
+ },
{
referredFrom: 'launcher',
preferNewSplit: spec.shouldInsert,
@@ -281,6 +287,36 @@ export type CreatableBlock = Omit<HotkeyRegistrationOptions, 'scopeId'> & {
};
export const CREATABLE_BLOCKS: CreatableBlock[] = [
+ {
+ label: 'Email',
+ icon: WideEmail,
+ animatedIcon: AnimatedEmailIcon,
+ description: 'Create email',
+ keywords: ['new', 'make', 'add', 'compose'],
+ blockName: 'email',
+ hotkeyToken: TOKENS.create.email,
+ altHotkeyToken: TOKENS.create.emailNewSplit,
+ hotkey: 'e',
+ keyDownHandler: () => {
+ runCreateAction('email', { shouldInsert: pressedKeys().has('shift') });
+ return true;
+ },
+ },
+ {
+ label: 'Agent',
+ icon: WideStar,
+ animatedIcon: AnimatedStarIcon,
+ description: 'Create AI chat',
+ keywords: ['new', 'make', 'add', 'agent'],
+ blockName: 'chat',
+ hotkeyToken: TOKENS.create.chat,
+ altHotkeyToken: TOKENS.create.chatNewSplit,
+ hotkey: 'a',
+ keyDownHandler: () => {
+ runCreateAction('chat', { shouldInsert: pressedKeys().has('shift') });
+ return true;
+ },
+ },
{
label: 'Doc',
icon: WideFileMd,
@@ -326,21 +362,6 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
return true;
},
},
- {
- label: 'Email',
- icon: WideEmail,
- animatedIcon: AnimatedEmailIcon,
- description: 'Create email',
- keywords: ['new', 'make', 'add', 'compose'],
- blockName: 'email',
- hotkeyToken: TOKENS.create.email,
- altHotkeyToken: TOKENS.create.emailNewSplit,
- hotkey: 'e',
- keyDownHandler: () => {
- runCreateAction('email', { shouldInsert: pressedKeys().has('shift') });
- return true;
- },
- },
{
label: 'Message',
icon: WideChat,
@@ -356,21 +377,6 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
return true;
},
},
- {
- label: 'Agent',
- icon: WideStar,
- animatedIcon: AnimatedStarIcon,
- description: 'Create AI chat',
- keywords: ['new', 'make', 'add', 'agent'],
- blockName: 'chat',
- hotkeyToken: TOKENS.create.chat,
- altHotkeyToken: TOKENS.create.chatNewSplit,
- hotkey: 'a',
- keyDownHandler: () => {
- runCreateAction('chat', { shouldInsert: pressedKeys().has('shift') });
- return true;
- },
- },
{
label: 'Canvas',
icon: WideDiagram,
diff --git a/js/app/packages/app/component/mobile/MobileDock.css b/js/app/packages/app/component/mobile/MobileDock.css
index cf43889845..3e9a76f51b 100644
--- a/js/app/packages/app/component/mobile/MobileDock.css
+++ b/js/app/packages/app/component/mobile/MobileDock.css
@@ -1,23 +1,23 @@
-@keyframes more-popover-show {
+@keyframes mobile-dock-menu-show {
from {
width: 10rem;
height: 5rem;
}
to {
width: var(
- --more-popover-width,
+ --mobile-dock-menu-width,
calc(100vw - 2 * var(--mobile-chrome-gutter, 0.75rem))
);
- height: var(--more-popover-height, 23.5rem);
+ height: var(--mobile-dock-menu-height, 23.5rem);
}
}
-@keyframes more-popover-hide {
+@keyframes mobile-dock-menu-hide {
from {
width: var(
- --more-popover-width,
+ --mobile-dock-menu-width,
calc(100vw - 2 * var(--mobile-chrome-gutter, 0.75rem))
);
- height: var(--more-popover-height, 23.5rem);
+ height: var(--mobile-dock-menu-height, 23.5rem);
opacity: 1;
}
to {
@@ -26,9 +26,9 @@
opacity: 0;
}
}
-.more-popover-content {
- animation: more-popover-hide 120ms ease-in forwards;
+.mobile-dock-menu-content {
+ animation: mobile-dock-menu-hide 120ms ease-in forwards;
}
-.more-popover-content[data-expanded] {
- animation: more-popover-show 150ms cubic-bezier(0.2, 1.05, 1, 1.1);
+.mobile-dock-menu-content[data-expanded] {
+ animation: mobile-dock-menu-show 150ms cubic-bezier(0.2, 1.05, 1, 1.1);
}
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index b8413441e1..04069ed5d7 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -1,6 +1,12 @@
import './MobileDock.css';
-import { isListViewID, type ListView } from '@app/constants/list-views';
+import type { ListView } from '@app/constants/list-views';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { globalSplitManager } from '@app/signal/splitLayout';
+import {
+ ENABLE_ANIMATED_ICONS,
+ ENABLE_SNIPPETS_FLAG,
+ ENABLE_SNIPPETS_OVERRIDE,
+} from '@core/constant/featureFlags';
import { useSettingsState } from '@core/constant/SettingsState';
import { triggerFocusInput } from '@core/directive/focusInput';
import { hapticImpact } from '@core/mobile/haptics';
@@ -22,9 +28,9 @@ import PlusIcon from '@phosphor/plus.svg';
import { createElementSize } from '@solid-primitives/resize-observer';
import { useLocation } from '@solidjs/router';
import { cn, Layer } from '@ui';
-import { type Component, createSignal, For, type JSX, Show } from 'solid-js';
+import { type Component, createSignal, For, Show } from 'solid-js';
import { Dynamic, Portal } from 'solid-js/web';
-import { setCreateMenuOpen } from '../Launcher';
+import { CREATABLE_BLOCKS, runCreateAction } from '../Launcher';
import { useSplitLayout } from '../split-layout/layout';
import { SearchState } from './mobileSearchState';
import { pressPulse } from './pressPulse';
@@ -34,9 +40,12 @@ false && pressPulse;
type DockId = ListView | 'home';
-type IconComponent = Component<
- JSX.SvgSVGAttributes<SVGSVGElement> | { triggerAnimation?: boolean }
->;
+type IconComponentProps = {
+ triggerAnimation?: boolean;
+ class?: string;
+};
+
+type IconComponent = Component<IconComponentProps>;
type MobileDockButtonProps = {
icon: IconComponent;
@@ -76,8 +85,13 @@ function MobileDockButton(props: MobileDockButtonProps) {
}}
// Default: fires on release — the press pulse holds the on-state while
// touched. (Not on fireOnPress buttons, which already fired above.)
- onClick={() => {
- if (!props.fireOnPress) props.onClick();
+ onClick={(e) => {
+ if (props.fireOnPress) {
+ // Keyboard/assistive activation dispatches click without pointerdown.
+ if (e.detail === 0) props.onClick();
+ return;
+ }
+ props.onClick();
}}
onTouchMove={props.onTouchMove}
onTouchEnd={props.onTouchEnd}
@@ -111,13 +125,22 @@ const MORE_VIEWS: { id: ListView; label: string; icon: IconComponent }[] = [
{ id: 'folders', label: 'Folders', icon: AnimatedFolderIcon },
];
-// The More button opens the menu on pointer-down (see fireOnPress), which also
-// arms the hold-and-drag-to-select gesture. The opening touch lifts after the
+type MobileDockMenuItem = {
+ id: string;
+ label: string;
+ icon?: IconComponent;
+ active?: () => boolean;
+ animateIcon?: boolean;
+ onSelect: () => void;
+};
+
+// Dock menu triggers open on pointer-down (see fireOnPress), which also arms
+// the hold-and-drag-to-select gesture. The opening touch lifts after the
// overlay is up, and its trailing synthesized click would land on whatever is
-// now under the finger: a freshly-mounted menu item (accidental selection) or,
-// once a drag-release dismisses the menu, the adjacent Create button. Swallow
-// that one click (capture phase, one-shot) so the opening touch can't leak
-// through. The timeout clears the listener if no ghost click arrives.
+// now under the finger: a freshly-mounted menu item (accidental selection) or
+// another dock button after a drag-release dismisses the menu. Swallow that one
+// click (capture phase, one-shot) so the opening touch can't leak through. The
+// timeout clears the listener if no ghost click arrives.
function suppressNextClick() {
const onClick = (e: MouseEvent) => {
e.stopPropagation();
@@ -132,11 +155,13 @@ function suppressNextClick() {
document.addEventListener('click', onClick, true);
}
-function MorePopover(props: {
- isActive: (id: DockId) => boolean;
- onNavigate: (id: DockId) => void;
+function MobileDockMenu(props: {
+ triggerIcon: IconComponent;
+ triggerAriaLabel: string;
+ footerLabel: string;
+ footerCaretClass?: string;
+ items: MobileDockMenuItem[];
}) {
- const { settingsOpen, toggleSettings } = useSettingsState();
// `open` drives the show/hide animation (via data-expanded); `mounted`
// keeps the overlay in the DOM until the hide animation finishes.
const [open, setOpen] = createSignal(false);
@@ -170,28 +195,27 @@ function MorePopover(props: {
setHoveredId(null);
};
+ const getItem = (id: string | null) =>
+ id ? props.items.find((item) => item.id === id) : undefined;
+
const handleTouchMove = (e: TouchEvent) => {
if (!open()) return;
const touch = e.touches[0];
const el = document.elementFromPoint(touch.clientX, touch.clientY);
- const button = el?.closest('[data-more-item]') as HTMLElement | null;
- const id = button?.dataset.moreItem ?? null;
+ const button = el?.closest(
+ '[data-mobile-dock-menu-item]'
+ ) as HTMLElement | null;
+ const id = button?.dataset.mobileDockMenuItem ?? null;
if (id !== hoveredId()) {
setHoveredId(id);
if (id) hapticImpact('light');
}
};
- // Acts on a row by id. 'settings' toggles the settings panel; list-view ids
- // navigate. Shared by tap (onClick) and the hold-and-drag-release gesture.
const select = (id: string | null) => {
- if (id === 'settings') {
- toggleSettings();
- } else if (isListViewID(id)) {
- props.onNavigate(id);
- } else {
- return;
- }
+ const item = getItem(id);
+ if (!item) return;
+ item.onSelect();
dismissMenu();
};
@@ -204,8 +228,8 @@ function MorePopover(props: {
return (
<>
<MobileDockButton
- icon={CaretUpIcon}
- ariaLabel="More views"
+ icon={props.triggerIcon}
+ ariaLabel={props.triggerAriaLabel}
animateIcon={false}
fireOnPress
onClick={() => (open() ? closeMenu() : openMenu())}
@@ -237,13 +261,13 @@ function MorePopover(props: {
edge (so it stays put vertically and is unmasked top-down as
the box grows upward). */}
<div
- class="more-popover-content flex items-end justify-start overflow-hidden rounded-2xl bg-surface ring ring-edge"
+ class="mobile-dock-menu-content flex items-end justify-start overflow-hidden rounded-2xl bg-surface ring ring-edge"
data-expanded={open() ? '' : undefined}
style={{
- '--more-popover-width': menuSize.width
+ '--mobile-dock-menu-width': menuSize.width
? `${menuSize.width}px`
: undefined,
- '--more-popover-height': menuSize.height
+ '--mobile-dock-menu-height': menuSize.height
? `${menuSize.height}px`
: undefined,
}}
@@ -259,32 +283,14 @@ function MorePopover(props: {
class="flex w-[calc(100vw-2*var(--mobile-chrome-gutter))] shrink-0 flex-col gap-1 p-1"
ref={setMenuRef}
>
- <button
- type="button"
- data-more-item="settings"
- class={cn(
- 'flex h-11 items-center gap-2 rounded-lg px-3 text-sm',
- settingsOpen() ? 'text-accent' : 'text-ink',
- hoveredId() === 'settings' ? 'bg-hover' : 'hover:bg-hover'
- )}
- onClick={() => {
- hapticImpact('light');
- select('settings');
- }}
- >
- <div class="size-4 shrink-0 [&_svg]:size-4">
- <IconGear />
- </div>
- <span>Settings</span>
- </button>
- <For each={MORE_VIEWS}>
+ <For each={props.items}>
{(item) => (
<button
type="button"
- data-more-item={item.id}
+ data-mobile-dock-menu-item={item.id}
class={cn(
'flex h-11 items-center gap-2 rounded-lg px-3 text-sm',
- props.isActive(item.id) ? 'text-accent' : 'text-ink',
+ item.active?.() ? 'text-accent' : 'text-ink',
hoveredId() === item.id
? 'bg-hover'
: 'hover:bg-hover'
@@ -294,12 +300,21 @@ function MorePopover(props: {
select(item.id);
}}
>
- <div class="size-4 shrink-0 [&_svg]:size-4">
- <Dynamic
- component={item.icon}
- triggerAnimation={hoveredId() === item.id}
- />
- </div>
+ <Show when={item.icon}>
+ {(Icon) => (
+ <div class="size-4 shrink-0 [&_svg]:size-4">
+ <Show
+ when={item.animateIcon !== false}
+ fallback={<Dynamic component={Icon()} />}
+ >
+ <Dynamic
+ component={Icon()}
+ triggerAnimation={hoveredId() === item.id}
+ />
+ </Show>
+ </div>
+ )}
+ </Show>
<span>{item.label}</span>
</button>
)}
@@ -314,9 +329,14 @@ function MorePopover(props: {
closeMenu();
}}
>
- <span>Views</span>
- {/* Center the caret over the dock's More trigger (this menu's opener) so it lines up with that button's caret. */}
- <CaretUpIcon class="mr-11 size-6 rotate-180 text-ink" />
+ <span>{props.footerLabel}</span>
+ {/* Align the caret with this menu's dock trigger. */}
+ <CaretUpIcon
+ class={cn(
+ 'size-6 rotate-180 text-ink',
+ props.footerCaretClass
+ )}
+ />
</button>
</div>
</div>
@@ -328,6 +348,68 @@ function MorePopover(props: {
);
}
+function MoreViewsMenu(props: {
+ isActive: (id: DockId) => boolean;
+ onNavigate: (id: DockId) => void;
+}) {
+ const { settingsOpen, toggleSettings } = useSettingsState();
+
+ return (
+ <MobileDockMenu
+ triggerIcon={CaretUpIcon}
+ triggerAriaLabel="More views"
+ footerLabel="Views"
+ footerCaretClass="mr-11"
+ items={[
+ {
+ id: 'settings',
+ label: 'Settings',
+ icon: IconGear,
+ active: settingsOpen,
+ animateIcon: false,
+ onSelect: toggleSettings,
+ },
+ ...MORE_VIEWS.map((item) => ({
+ id: item.id,
+ label: item.label,
+ icon: item.icon,
+ active: () => props.isActive(item.id),
+ onSelect: () => props.onNavigate(item.id),
+ })),
+ ]}
+ />
+ );
+}
+
+function CreateMenu() {
+ const snippetsFlag = useFeatureFlag(ENABLE_SNIPPETS_FLAG, {
+ enabledOverride: ENABLE_SNIPPETS_OVERRIDE,
+ });
+
+ const blocks = () =>
+ CREATABLE_BLOCKS.filter(
+ (block) => block.blockName !== 'snippet' || snippetsFlag().enabled
+ ).toReversed();
+
+ return (
+ <MobileDockMenu
+ triggerIcon={PlusIcon}
+ triggerAriaLabel="Create"
+ footerLabel="Create"
+ items={blocks().map((block) => {
+ const useAnimatedIcon = ENABLE_ANIMATED_ICONS && block.animatedIcon;
+ return {
+ id: block.blockName,
+ label: block.label,
+ icon: useAnimatedIcon ? block.animatedIcon : block.icon,
+ animateIcon: !!useAnimatedIcon,
+ onSelect: () => runCreateAction(block.blockName),
+ };
+ })}
+ />
+ );
+}
+
export function MobileDock() {
const { openWithSplit } = useSplitLayout();
const location = useLocation();
@@ -384,14 +466,8 @@ export function MobileDock() {
SearchState.open();
}}
/>
- <MorePopover isActive={isActive} onNavigate={navigate} />
- <MobileDockButton
- icon={PlusIcon}
- animateIcon={false}
- ariaLabel="Create"
- class="size-10 rounded-full"
- onClick={() => setCreateMenuOpen(true)}
- />
+ <MoreViewsMenu isActive={isActive} onNavigate={navigate} />
+ <CreateMenu />
</div>
);
}
diff --git a/js/app/packages/block-email/component/compose/Compose.tsx b/js/app/packages/block-email/component/compose/Compose.tsx
index a1f9443751..1128e56800 100644
--- a/js/app/packages/block-email/component/compose/Compose.tsx
+++ b/js/app/packages/block-email/component/compose/Compose.tsx
@@ -762,9 +762,6 @@ export function EmailCompose(props: EmailComposeProps) {
</SplitHeaderLeft>
</Show>
<div class="relative flex flex-col size-full min-h-0 overflow-hidden text-sm">
- <Show when={hasLinkError()}>
- <EmailPermissionsBanner />
- </Show>
<div class="macro-message-width sm:macro-message-padding mx-auto w-full min-h-120 max-h-full my-2 sm:my-12 mobile:my-0 px-2 sm:px-4 mobile:px-0 overflow-hidden mobile:overflow-y-auto mobile:scrollbar-hidden mobile:min-h-full">
<WrapUnlessMobile
wrapper={(children) => (
@@ -775,6 +772,7 @@ export function EmailCompose(props: EmailComposeProps) {
>
<ComposeLayout
toolbar={<EmailComposeToolbar editor={editor} />}
+ notice={hasLinkError() ? <EmailPermissionsBanner /> : undefined}
class="size-full p-4 bg-surface max-h-full mobile:max-h-none overflow-hidden flex flex-col min-h-0 mobile:min-h-full"
/>
</WrapUnlessMobile>
diff --git a/js/app/packages/block-email/component/compose/ComposeLayout.tsx b/js/app/packages/block-email/component/compose/ComposeLayout.tsx
index c8d2361c3a..2d0c562c9b 100644
--- a/js/app/packages/block-email/component/compose/ComposeLayout.tsx
+++ b/js/app/packages/block-email/component/compose/ComposeLayout.tsx
@@ -27,6 +27,7 @@ type ComposeLayoutRefs = {
export function ComposeLayout(props: {
toolbar?: JSX.Element;
header?: JSX.Element;
+ notice?: JSX.Element;
class?: string;
bodyDebugName?: string;
}) {
@@ -247,6 +248,10 @@ export function ComposeLayout(props: {
</div>
</div>
+ <Show when={props.notice}>
+ <div class="mb-4">{props.notice}</div>
+ </Show>
+
<ComposeRecipients
toRef={registerRef('directRecipientsSelector')}
ccRef={registerRef('ccRecipientsSelector')}
diff --git a/js/app/packages/core/component/EmailPermissionsBanner.tsx b/js/app/packages/core/component/EmailPermissionsBanner.tsx
index 350a28e419..a0c159955a 100644
--- a/js/app/packages/core/component/EmailPermissionsBanner.tsx
+++ b/js/app/packages/core/component/EmailPermissionsBanner.tsx
@@ -1,22 +1,26 @@
-import { useLogout } from '@core/auth/logout';
+import { useAddInboxFlow } from '@core/email-link';
import Caution from '@phosphor/warning.svg';
import { Button } from '@ui';
export function EmailPermissionsBanner() {
- const logout = useLogout();
+ const startAddInbox = useAddInboxFlow();
return (
<div class="w-full bg-alert-bg border-y border-alert/20 text-alert-ink p-2">
- <div class="flex items-center justify-between gap-2">
- <Caution class="size-4" />
- <span class="text-sm">
- Email requires additional Google permissions. Select the permissions
- on sign-in to enable.
- </span>
- <span class="grow" />
- <Button variant="base" size="sm" class="px-2" onClick={() => logout()}>
- Logout
- </Button>
+ <div class="flex items-center gap-4">
+ <Caution class="size-8 shrink-0" />
+ <div class="flex flex-wrap flex-1 min-w-0 gap-2">
+ <div class="text-sm shrink-0">No email account connected.</div>
+ <span class="grow" />
+ <Button
+ variant="active"
+ size="sm"
+ class="px-4"
+ onClick={() => void startAddInbox()}
+ >
+ Connect Gmail
+ </Button>
+ </div>
</div>
</div>
);