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
description: "Mobile UI uses the shared touch helpers, chrome, and sheets." paths: - "apps/web/src//*.tsx" - "apps/web/src//.css" - "apps/web/src/lib/core/mobile/" globs: "apps/web/src//.tsx,apps/web/src//*.css,apps/web/src/lib/core/mobile/" alwaysApply: false
Build mobile UI with the shared touch helpers
The web app is also the iOS and Android apps. Mobile bugs come from hover-only UI, taps that drop the keyboard, content under chrome or safe areas, and WebKit quirks that Chrome emulation never shows.
Before building mobile UI, open the app at phone width and study how existing surfaces solve the same problem (sheets, the dock, header islands, list rows), read their code, and follow that pattern rather than inventing a new one.
Detection and input
isTouchDevice()/touch:decide input (no hover);isMobile()/mobile:decide phone layout (touch and under 640px). Hide a desktop control and show its touch replacement with the same one, or tablets get neither. Native checks (isPlatformin@core/util/platform) are for native bridges and platform-specific visual effects, not layout.- When a surface needs a different phone or touch layout, compose a separate
mobile view from shared parts (and a shared state primitive) instead of
branching on
isMobile()/isTouchDevice()throughout one component; extract the parts first if needed. The task composer (features/task-composer/views) is the reference. - Gate hover and press styles with
not-touch:; iOS leaves hover stuck. - No action lives only behind hover.
HoverCardrenders nothing on touch, so give it a tap path that opens a sheet, asUserCardTriggerdoes. - Keep tooltips disabled on touch devices, including focus and controlled-open states.
- Keep
@uiButton's touch sizing (nonoTouchResizewithout cause); rows are 44px on touch (touch:min-h-[44px]). - Long-press goes through the
touchHandlerdirective. On scrollable rows, selecting or dragging starts only after a long press; dedicated reorder handles instead drag after a small movement with no hold delay and reserve scrolling for the rest of the row. Horizontal swipes ignore the left edge (iOS back swipe). - Keep navigation, filter pills, and create-menu taps silent; keep haptics for
long press and use
hapticImpact('light')for valid message/AI sends. Navigation acts on click so held or cancelled touches do nothing.glassandislandcontrols and channel inputs get iOS-app-only press animation frominstallGlassPress; reuse it and keep Android and web free of the effect.
Sheets, menus, and dialogs
- Use
@uiDialogandConfirmDialog; they become drawers on phones. Build other sheets fromMobileDrawer(components/app/mobile), never raw@corvu/drawer, with content inMobileDrawer.ScrollBodyand height frommaxHeight/targetHeight, never hand-set. - Phone drawers have a handle and no X; drag, backdrop, or Escape dismiss, and focus returns to the opener. No submenus at phone width: drill in place with a back row.
- A sheet takes focus itself when it opens, so no row opens wearing a focus
ring; only a first tab stop that is a text field keeps it. Name another
target with
initialFocusEloronInitialFocus, never an autofocus of your own. - Actions that must stay in reach while a sheet scrolls sit in its pinned
chrome between the handle and
MobileDrawer.ScrollBody, never in a sticky band inside the scroll. A touch popover split exposes that slot asdrawerHeaderon its panel context; seeMobileEventForm. Content that grows to fill its sheet (a composer's description) callsfillDrawerfrom that context to open at a fixed height; seeMobileTaskComposer. - Pick people, projects, tags, or other searchable lists from a touch sheet
with
PickerSheet(components/app/mobile), not a dropdown: a full-height sheet stacked over the current one with Cancel, a title, and Done, and no handle or drag. Create the draft or picker session inside it so each opening starts fresh, apply it only on Done, let the list fillPickerSheet.Body, and cancelpointerdownandmousedownon the rows so the search field keeps the keyboard. It hands focus back to the field that had it when it opened, so its opener cancelspointerdownandmousedowntoo.Property.SheetEditor(entity and date properties),InlineTagsSheetPill, and the event composer's guest pill use it. Short lists (status, priority) stay dropdowns: on touch, property menus leave focus where it was. - A backdrop tap only dismisses:
MobileDrawerswallows the rest of that tap, so it never presses what the scrim covered, even when the sheet unmounts as it closes (a<Show>around it, oropenDialog). It swallows only a tap that really closed the sheet, so an owner that keeps its sheet open while another is stacked on it leaves that sheet's controls pressable. Don't add per-sheet delays or click guards for it. A drag dismissal the owner refuses (to confirm a discard, or while an action is pending) snaps the sheet back open. - A sheet opened from another sheet stacks on it under its own scrim, which
shares the sheets' layer (as Dialog's does), so the sheet beneath dims with
the page and only the top sheet's handle stands out. Open it under the
sheet's owner (in its component tree, or
openDialogwithowner, asuseAddInboxFlowdoes): a dialog mounted elsewhere starts its own dismiss stack, so its Cancel, Escape or Back also closes the sheet beneath. - Overlays are Kobalte or corvu layers or handle Escape: Android Back sends
Escape to the top layer. Own back stacks use
useAndroidBackNavigation. - Persistent prompts (
toast.customwithpersistent) go to the prompt region (useKeyedPersistentToastsdoes it). Its phone layer (z-mobile-prompt-region) sits under the modal stack, so sheets and the pickers on them cover it; a prompt in the transient region, which stays above sheets, would cover a sheet's controls. - Pass a composer typeahead or picker menu's
floatWithSelectionitsfullHeight(content cap plus panel padding) so it picks the side with room for its whole list instead of shrinking below the caret when its first render is short.
Keyboard and focus
- Focus inputs on user intent only, never on mount. On touch, Enter in a composer inserts a newline; the send button submits.
- iOS raises the keyboard only for a focus inside the tap. A tap that opens a
composer whose field mounts later calls
triggerFocusInputin the tap (seeraiseKeyboardForNewTaskTitle), or a create menu item'sraiseKeyboard; popovers and the create menu leave focus with its stand-in. - UI over an editor must not take focus: cancel
pointerdownandmousedownon its root (keepEditorFocusinTouchSelectionToolbar) or useusePreserveFocusOnButtonTaps; mark sibling regionsdata-keep-keyboard. Dismiss withuseTouchOutsideToDismissKeyboard. - Size against the keyboard with
var(--dvh,1dvh)andvar(--virtual-keyboard-height,0px), fallback included (Android leaves it unset); in JS readvirtualKeyboardVisible(). Sheets with inputs callscrollToFocusedInputfromonFocusIn. - Never remount a focused editor (keys on content ids, Suspense around it).
Collapsed inputs match the focused height (
CollapsedInput), and hidden controls usehidden, notopacity-0, so neighbors don't jump.
Layout and chrome
- Reserve
--mobile-content-inset-top(safe area plus any floating split header) withtouch:on every full-frame view, including loading/error states and record tabs; phone width alone and--safe-topalone do not cover tablets or floating navigation. UseViewShell.Headerfor collection controls; when an in-flow header consumes the inset, reset it to0pxon its content subtree so nested lists/editors do not reserve it again. Otherwise pad the scroller with the top and bottom content insets so content scrolls under the chrome. - Safe areas come from the
--safe-*CSS variables (e.g.bottom-[var(--safe-bottom,0px)]);getSafeAreaInsetonly when JS needs the number. Never measure insets yourself. - Wrap split-header contributions in
HeaderIsland(the touch header ignores taps outside islands). Bottom chrome goes throughFloatRegionorFloatRegionOrInlinewithpx-(--mobile-chrome-gutter)andpointer-events-auto. Style it withisland/glass, size it with the px--mobile-chrome-*tokens (not rem), and use Button's size and finish props. - Mark selection with
ink, neveraccent: a selected pill isbg-ink text-surface, a selected dock button or drawer row stays at full ink while its siblings dim (text-ink-extra-muted,aria-current="page"). Keep the accent for attention — unread dots and filter counts. - Phones show one pane: open in place or as a front pane, never a new split. Desktop-only layouts fall back (board to list) and update the URL.
- Suspense wraps content, never the router or chrome, with
ContentLoadingas the fallback; otherwise phones go blank. - Keep content and actions the same as desktop and change presentation. Drop a feature on phones only when it is desk work (API keys).
Platform pitfalls
- Construct Web Workers on first use, never at module load: eager module
workers deadlock iOS WKWebView. Open links with
openExternalUrl. - Virtual rows reserve media size up front (resizes during iOS momentum
scroll jump the list; see
ThreadList); virtual lists useoverscroll-none.
Verify
- Check at 390px with touch emulation (width alone doesn't set
touch:) and a tablet (touch at desktop width). Check keyboard, safe areas, and native menus in the iOS Simulator and tap/focus bugs on a physical iPhone (apps/web/AGENTS.md); Android perdocs/development/android.md.
Check: no hover-only actions, the helpers above are used, and the change was seen at phone width with touch emulation.