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: mobile app squish (#1029)
Peter Chinmanc69e929e7dd2
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex 53e8c0814e..9bc9707ea1 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -10,7 +10,7 @@ import {} from '@core/signal/layout';import { type RouteSectionProps, useLocation } from '@solidjs/router';import { attachGlobalDOMScope } from 'core/hotkey/hotkeys';-import { createEffect, onCleanup, onMount, Show, Suspense } from 'solid-js';+import { createEffect, onMount, Show, Suspense } from 'solid-js';import { updateCookie } from '../util/updateCookie';import Banner from './banner/Banner';import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';@@ -22,6 +22,9 @@ import { Paywall } from './paywall/Paywall';import { RightbarWrapper } from './rightbar/Rightbar';import { SettingsWrapper } from './settings/SettingsWrapper';import { ShortcutsHelper } from './settings/ShortcutsHelper';+import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';+import { cn } from '@ui/utils/classname';+import { useAppSquishHandlers } from './useAppSquishHandlers';const AUTH_URLS = ['/app/login',@@ -37,6 +40,8 @@ export function Layout(props: RouteSectionProps) {const { paywallOpen, showPaywall } = usePaywallState();const location = useLocation();+ useAppSquishHandlers();+// save last_path to cookiecreateEffect(() => {const path = location.pathname;@@ -53,37 +58,13 @@ export function Layout(props: RouteSectionProps) {});});- // We are tracking viewport height, and using that to set a CSS variable and the viewport offset, so that we can properly constrain the viewport-height for mobile in response to changes such as the virtual keyboard appearing- const handleResize = () => {- if (window.visualViewport) {- // Set the CSS variable with the calculated height- document.documentElement.style.setProperty(- '--viewport-height',- `${window.visualViewport.height}px`- );- }- };-onMount(() => {- if (window.visualViewport) {- window.visualViewport.addEventListener('resize', handleResize);- window.visualViewport.addEventListener('scroll', handleResize);- handleResize();- }-if (sessionStorage.getItem('showUpgradeModal') === 'true') {showPaywall();sessionStorage.removeItem('showUpgradeModal');}});- onCleanup(() => {- if (window.visualViewport) {- window.visualViewport.removeEventListener('resize', handleResize);- window.visualViewport.removeEventListener('scroll', handleResize);- }- });-// This effect handles transitioning from desktop to mobile width to ensure sidebar state is properly resetcreateEffect((_prevMobileWidth: boolean | undefined) => {const currentMobileWidth = isMobileWidth();@@ -111,12 +92,16 @@ export function Layout(props: RouteSectionProps) {return (<div- class="relative flex flex-col justify-between w-dvw h-dvh"+ class={cn(+ 'relative flex flex-col justify-between w-dvw h-[calc(var(--dvh,1dvh)*100)]',+ {+ 'pb-[max(env(safe-area-inset-bottom,0px),var(--tauri-inset-bottom,0px))]':+ !virtualKeyboardVisible(),+ }+ )}style={{'padding-top':'max(env(safe-area-inset-top, 0px), var(--tauri-inset-top, 0px))',- 'padding-bottom':- 'max(env(safe-area-inset-bottom, 0px), var(--tauri-inset-bottom, 0px))','padding-left':'max(env(safe-area-inset-left, 0px), var(--tauri-inset-left, 0px))','padding-right':diff --git a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx b/js/app/packages/app/component/split-layout/components/SplitContainer.tsxindex db6452c371..c07a9a2a6f 100644--- a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitContainer.tsx@@ -18,6 +18,7 @@ import { SplitDrawerGroup } from './SplitDrawerContext';import { SplitHeader } from './SplitHeader';import { SplitModalProvider } from './SplitModalContext';import { SplitToolbar } from './SplitToolbar';+import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';import { ClippedPanel } from '@core/component/ClippedPanel';import { globalSplitManager } from '@app/signal/splitLayout';@@ -110,7 +111,13 @@ export function SplitContainer(<Show when={panel.handle.isSpotLight()}><MacroJump tabbableParent={ref} /></Show>- <Show when={isTouchDevice() && isMobileWidth()}>+ <Show+ when={+ isTouchDevice() &&+ isMobileWidth() &&+ !virtualKeyboardVisible()+ }+ ><MobileDock /></Show></div>diff --git a/js/app/packages/app/component/useAppSquishHandlers.ts b/js/app/packages/app/component/useAppSquishHandlers.tsnew file mode 100644index 0000000000..00a14a339d--- /dev/null+++ b/js/app/packages/app/component/useAppSquishHandlers.ts@@ -0,0 +1,94 @@+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { setVirtualKeyboardVisible } from '@core/mobile/virtualKeyboard';+import { isEditableInput } from '@core/util/isEditableInput';+import { isIOS } from '@solid-primitives/platform';+import { onCleanup, onMount } from 'solid-js';++/**+ * Functionality for responding to virtual keyboard appearance in web app and native mobile app.+ */+export function useAppSquishHandlers() {+ if (isIOS) {+ // We are tracking viewport height, and using that to set a CSS variable and the viewport offset,+ // so that we can properly constrain the viewport-height for mobile in response to changes such as+ // the virtual keyboard appearing.+ let previousViewportHeight = window.visualViewport?.height || 0;+ const handleResize = () => {+ if (window.visualViewport) {+ const newViewportHeight = window.visualViewport.height;+ if (newViewportHeight < previousViewportHeight) {+ setVirtualKeyboardVisible(true);+ const vh = newViewportHeight * 0.01;+ document.documentElement.style.setProperty('--dvh', `${vh}px`);+ setTimeout(() => {+ window.scrollTo(0, 0);+ });+ } else {+ setVirtualKeyboardVisible(false);+ document.documentElement.style.setProperty('--dvh', '1dvh');+ }+ previousViewportHeight = newViewportHeight;+ }+ };++ const handleFocusOut = (e: FocusEvent) => {+ if (+ e.target instanceof Element &&+ isEditableInput(e.target) &&+ (!e.relatedTarget ||+ (e.relatedTarget instanceof Element &&+ !isEditableInput(e.relatedTarget)))+ ) {+ document.documentElement.style.setProperty('--dvh', '1dvh');+ setVirtualKeyboardVisible(false);+ }+ };++ onMount(() => {+ if (window.visualViewport) {+ window.visualViewport.addEventListener('resize', handleResize);+ handleResize();+ window.visualViewport.addEventListener('scroll', handleResize);+ }+ document.addEventListener('focusout', handleFocusOut);++ onCleanup(() => {+ if (window.visualViewport) {+ window.visualViewport.removeEventListener('resize', handleResize);+ window.visualViewport.removeEventListener('scroll', handleResize);+ }+ document.removeEventListener('focusout', handleFocusOut);+ });+ });+ }++ if (isNativeMobilePlatform()) {+ type VirtualKeyboardEvent = CustomEventInit<{+ height: number;+ duration: number;+ }>;++ const handleKeyboardWillShow = (event: VirtualKeyboardEvent) => {+ setVirtualKeyboardVisible(true);+ const newViewportHeight =+ (window.visualViewport?.height ?? 0) - (event.detail?.height ?? 0);+ const vh = newViewportHeight * 0.01;+ document.documentElement.style.setProperty('--dvh', `${vh}px`);+ };++ const handleKeyboardWillHide = () => {+ setVirtualKeyboardVisible(false);+ document.documentElement.style.setProperty('--dvh', '1dvh');+ };++ onMount(() => {+ window.addEventListener('keyboardWillShow', handleKeyboardWillShow);+ window.addEventListener('keyboardWillHide', handleKeyboardWillHide);++ onCleanup(() => {+ window.removeEventListener('keyboardWillShow', handleKeyboardWillShow);+ window.removeEventListener('keyboardWillHide', handleKeyboardWillHide);+ });+ });+ }+}diff --git a/js/app/packages/app/index.html b/js/app/packages/app/index.htmlindex 60eb537379..8417fafe76 100644--- a/js/app/packages/app/index.html+++ b/js/app/packages/app/index.html@@ -36,7 +36,7 @@<body><noscript>You need to enable JavaScript to run this app.</noscript>- <div id="root" class="h-dvh touch:h-screen"></div>+ <div id="root" class="h-[calc(var(--dvh,1dvh)*100)]"></div><div id="modal" class="z-modal"></div><!--Entrypointdiff --git a/js/app/packages/core/mobile/virtualKeyboard.ts b/js/app/packages/core/mobile/virtualKeyboard.tsnew file mode 100644index 0000000000..bb5f22c332--- /dev/null+++ b/js/app/packages/core/mobile/virtualKeyboard.ts@@ -0,0 +1,4 @@+import { createSignal } from 'solid-js';++export const [virtualKeyboardVisible, setVirtualKeyboardVisible] =+ createSignal(false);diff --git a/js/app/tauri/Cargo.lock b/js/app/tauri/Cargo.lockindex 516b45f7a5..a35302a8c5 100644--- a/js/app/tauri/Cargo.lock+++ b/js/app/tauri/Cargo.lock@@ -100,6 +100,7 @@ dependencies = ["tauri-plugin-os","tauri-plugin-safe-area-insets","tauri-plugin-single-instance",+ "tauri-plugin-virtual-keyboard","tauri-plugin-websocket","thiserror 2.0.17","tokio",@@ -4725,6 +4726,17 @@ dependencies = ["zbus",]+[[package]]+name = "tauri-plugin-virtual-keyboard"+version = "0.1.0"+source = "git+https://github.com/voxelbee/tauri-plugin-virtual-keyboard?branch=main#70e8e8325b5ff7d681ef5f3b996ac083d4fc5a01"+dependencies = [+ "serde",+ "tauri",+ "tauri-plugin",+ "thiserror 2.0.17",+]+[[package]]name = "tauri-plugin-websocket"version = "2.4.0"diff --git a/js/app/tauri/src-tauri/Cargo.toml b/js/app/tauri/src-tauri/Cargo.tomlindex 606a1e14ed..2f29b1046b 100644--- a/js/app/tauri/src-tauri/Cargo.toml+++ b/js/app/tauri/src-tauri/Cargo.toml@@ -52,6 +52,7 @@ tauri-plugin-notification = "2"navigation_plugin = { path = "../navigation_plugin" }tauri-plugin-notifications = { git = "https://github.com/seanaye/tauri-plugins", branch = "seanaye+mnlphlp/add/android-notifications" }tauri-plugin-os = "2"+tauri-plugin-virtual-keyboard = { git = "https://github.com/voxelbee/tauri-plugin-virtual-keyboard", branch = "main" }[target."cfg(any(target_os = \"macos\", windows, target_os = \"linux\"))".dependencies]diff --git a/js/app/tauri/src-tauri/src/lib.rs b/js/app/tauri/src-tauri/src/lib.rsindex 8aa907bb52..4931029c88 100644--- a/js/app/tauri/src-tauri/src/lib.rs+++ b/js/app/tauri/src-tauri/src/lib.rs@@ -110,7 +110,9 @@ pub fn run() {// register mobile specific pluginsbuilder = builder.plugin(tauri_plugin_safe_area_insets::init())- .plugin(tauri_plugin_notifications::init());+ .plugin(tauri_plugin_notifications::init())+ .plugin(tauri_plugin_virtual_keyboard::init());+}builder