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(desktop): respect browser zoom hotkeys (#8524)
Eric Hayes7b323f9a1a7c
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 314645c6c4..f421d95433 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -244,6 +244,21 @@ desktop delivery, including buffered launch taps before device registration.This requires a native macOS release; see the[notification walkthrough](../../docs/agent-guide/notifications.md).+## Desktop page zoom++The desktop app binds `Ctrl/Cmd` with `+`, `-`, and `0` itself in+`src/lib/tauri/zoom.ts`; nothing underneath provides them. Wry's+`zoomHotkeysEnabled` is Windows-only and Tauri's default menu has no zoom items.+The hotkeys call the webview's `setZoom`, which needs+`core:webview:allow-set-webview-zoom` in `tauri/src-tauri/capabilities/desktop.json`,+so a build without that permission fails the call at runtime. That permission+lives in a `desktop`-named capability rather than `default.json` because the iOS+and Android native gates hash every file under `tauri/` whose path doesn't name a+platform: editing `default.json` would demand a store release for a command that+only exists on desktop. The saved factor is+re-applied on launch because the webview always starts at 100%. `RootFrame`, not+`GlobalHotkeys`, registers them, so zoom also works on pages without app chrome.+## Desktop file dropsKeep `app.windows[].dragDropEnabled` false in `tauri/src-tauri/tauri.macos.conf.json`.diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsxindex 5cb5cb1566..e4119ff4db 100644--- a/apps/web/src/components/app/Layout.tsx+++ b/apps/web/src/components/app/Layout.tsx@@ -50,6 +50,7 @@ import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';import { hasLoginCookie, updateCookie } from '@core/util/cookies';import { lazyNamed } from '@core/util/lazyNamed';import { isPlatform } from '@core/util/platform';+import { useDesktopZoom } from '@macro/tauri/zoom';import { useUserInfoQuery } from '@queries/auth/user-info';import { queryClient } from '@queries/client';import { useLocation, useNavigate } from '@solidjs/router';@@ -128,6 +129,9 @@ export function RootFrame(props: ParentProps) {onCleanup(observeAiUsageLimitMutations(queryClient));useAppSquishHandlers();+ // Here rather than in GlobalShortcuts so zoom also works on the pages that+ // render without app chrome (login, booking, meetings).+ useDesktopZoom();// save last_path to cookiecreateEffect(() => {diff --git a/apps/web/src/lib/core/hotkey/tokens.ts b/apps/web/src/lib/core/hotkey/tokens.tsindex fa183c9d38..b28824c69e 100644--- a/apps/web/src/lib/core/hotkey/tokens.ts+++ b/apps/web/src/lib/core/hotkey/tokens.ts@@ -111,6 +111,9 @@ export const TOKENS = {inviteTeam: 'global.inviteTeam',undo: 'global.undo',redo: 'global.redo',+ zoomIn: 'global.zoomIn',+ zoomOut: 'global.zoomOut',+ zoomReset: 'global.zoomReset',},// sidebar navigationdiff --git a/apps/web/src/lib/tauri/zoom.test.ts b/apps/web/src/lib/tauri/zoom.test.tsnew file mode 100644index 0000000000..3ddf9de860--- /dev/null+++ b/apps/web/src/lib/tauri/zoom.test.ts@@ -0,0 +1,119 @@+import { createRoot } from 'solid-js';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++const mocks = vi.hoisted(() => ({+ setZoom: vi.fn(async (_factor: number) => {}),+ isDesktopPlatform: vi.fn(() => true),+}));++vi.mock('@core/mobile/isTouchDevice', () => ({ isTouchDevice: () => false }));+vi.mock('@tauri-apps/api/webview', () => ({+ getCurrentWebview: () => ({ setZoom: mocks.setZoom }),+}));+vi.mock('@core/util/platform', () => ({+ isDesktopPlatform: mocks.isDesktopPlatform,+}));++const disposers: (() => void)[] = [];++function shutDown() {+ for (const dispose of disposers.splice(0)) dispose();+}++/**+ * Starts the app with a fresh module graph, so each launch restores the saved+ * zoom the way a relaunch does. The hotkey root has to come from the same+ * graph as the zoom module, or they hold separate scope trees.+ */+async function launch() {+ vi.resetModules();+ const [{ useHotKeyRoot }, { useDesktopZoom }] = await Promise.all([+ import('@core/hotkey/hotkeys'),+ import('./zoom'),+ ]);+ createRoot((dispose) => {+ disposers.push(dispose);+ useHotKeyRoot();+ useDesktopZoom();+ });+}++/** jsdom is not a Mac, so the hotkey system reads cmd off the control key. */+function press(key: string, modifiers: { shiftKey?: boolean } = {}) {+ const init = { key, ctrlKey: true, ...modifiers };+ document.dispatchEvent(new KeyboardEvent('keydown', init));+ document.dispatchEvent(new KeyboardEvent('keyup', init));+}++beforeEach(() => {+ localStorage.clear();+ mocks.setZoom.mockClear();+ mocks.isDesktopPlatform.mockReturnValue(true);+});++afterEach(shutDown);++describe('desktop zoom hotkeys', () => {+ it('zooms out a step', async () => {+ await launch();++ press('-');++ expect(mocks.setZoom).toHaveBeenCalledExactlyOnceWith(0.9);+ });++ it('zooms in a step', async () => {+ await launch();++ press('=');++ expect(mocks.setZoom).toHaveBeenCalledExactlyOnceWith(1.1);+ });++ it('zooms in on the shifted plus a keyboard actually sends', async () => {+ await launch();++ press('+', { shiftKey: true });++ expect(mocks.setZoom).toHaveBeenCalledExactlyOnceWith(1.1);+ });++ it('returns to actual size', async () => {+ await launch();++ press('=');+ press('=');+ press('0');++ expect(mocks.setZoom).toHaveBeenLastCalledWith(1);+ });++ it('stops at the smallest step', async () => {+ await launch();++ for (let i = 0; i < 8; i++) press('-');++ expect(mocks.setZoom).toHaveBeenLastCalledWith(0.5);+ expect(mocks.setZoom).toHaveBeenCalledTimes(4);+ });++ it('re-applies the saved zoom on the next launch', async () => {+ await launch();+ press('-');+ shutDown();+ mocks.setZoom.mockClear();++ await launch();++ expect(mocks.setZoom).toHaveBeenCalledExactlyOnceWith(0.9);+ });++ it('leaves the keys to the browser on the web', async () => {+ mocks.isDesktopPlatform.mockReturnValue(false);++ await launch();+ press('-');++ expect(mocks.setZoom).not.toHaveBeenCalled();+ });+});diff --git a/apps/web/src/lib/tauri/zoom.ts b/apps/web/src/lib/tauri/zoom.tsnew file mode 100644index 0000000000..2d3485c188--- /dev/null+++ b/apps/web/src/lib/tauri/zoom.ts@@ -0,0 +1,128 @@+import { makePersistedState } from '@app/lib/persistence';+import { registerHotkey } from '@core/hotkey/hotkeys';+import { TOKENS } from '@core/hotkey/tokens';+import { fireAndForget } from '@core/util/fireAndForget';+import { isDesktopPlatform } from '@core/util/platform';+import MagnifyingGlass from '@phosphor/magnifying-glass.svg';+import MagnifyingGlassMinus from '@phosphor/magnifying-glass-minus.svg';+import MagnifyingGlassPlus from '@phosphor/magnifying-glass-plus.svg';+import { getCurrentWebview } from '@tauri-apps/api/webview';+import { createSignal } from 'solid-js';+import { z } from 'zod';++/**+ * Page zoom for the desktop app. The webview has none of its own: wry's+ * `zoomHotkeysEnabled` is Windows-only and Tauri's default menu has no zoom+ * items, so cmd/ctrl with +, - and 0 does nothing until the app binds them.+ */++/** Chrome's zoom stops, trimmed to the range the app layout stays usable in. */+const ZOOM_STEPS = [0.5, 0.67, 0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2] as const;+const DEFAULT_ZOOM = 1;+const STORAGE_KEY = 'macro:desktop:zoom';++const zoomSchema = z+ .number()+ .min(ZOOM_STEPS[0])+ .max(ZOOM_STEPS[ZOOM_STEPS.length - 1]);++function readStoredZoom(): number | undefined {+ if (typeof localStorage === 'undefined') return;+ try {+ const raw = localStorage.getItem(STORAGE_KEY);+ if (raw === null) return;+ const parsed = zoomSchema.safeParse(Number(raw));+ return parsed.success ? parsed.data : undefined;+ } catch {+ // Storage may be unavailable or blocked; 100% is a fine starting point.+ return;+ }+}++function writeStoredZoom(value: number): void {+ if (typeof localStorage === 'undefined') return;+ try {+ localStorage.setItem(STORAGE_KEY, String(value));+ } catch {+ // Storage may be unavailable or full. The zoom still applies this session.+ }+}++const [zoom, setZoom] = makePersistedState(createSignal<number>(DEFAULT_ZOOM), {+ storages: { restore: readStoredZoom, write: writeStoredZoom },+});++function apply(factor: number): void {+ setZoom(factor);+ // Rejects while the webview is being torn down or reloaded, where the next+ // launch re-applies the saved factor anyway.+ fireAndForget(getCurrentWebview().setZoom(factor), 'desktop-zoom');+}++/** Moves to the neighbouring stop, so an off-step saved factor still steps. */+function stepZoom(direction: 1 | -1): void {+ const current = zoom();+ const next =+ direction === 1+ ? ZOOM_STEPS.find((step) => step > current)+ : ZOOM_STEPS.findLast((step) => step < current);+ if (next === undefined) return;+ apply(next);+}++/**+ * Applies the saved zoom and binds the browser zoom hotkeys. Every launch+ * starts the webview at 100%, so the saved factor has to be re-applied.+ */+export function useDesktopZoom(): void {+ if (!isDesktopPlatform()) return;++ if (zoom() !== DEFAULT_ZOOM) apply(zoom());++ registerHotkey({+ hotkeyToken: TOKENS.global.zoomIn,+ // '+' alone covers the numeric keypad, which sends it without shift.+ hotkey: ['cmd+=', 'shift+cmd+=', 'cmd++'],+ scopeId: 'global',+ description: 'Zoom in',+ keyDownHandler: (e) => {+ e?.preventDefault();+ stepZoom(1);+ return true;+ },+ runWithInputFocused: true,+ icon: MagnifyingGlassPlus,+ keywords: ['zoom', 'bigger', 'larger', 'text size'],+ });++ registerHotkey({+ hotkeyToken: TOKENS.global.zoomOut,+ hotkey: 'cmd+-',+ scopeId: 'global',+ description: 'Zoom out',+ keyDownHandler: (e) => {+ e?.preventDefault();+ stepZoom(-1);+ return true;+ },+ runWithInputFocused: true,+ icon: MagnifyingGlassMinus,+ keywords: ['zoom', 'smaller', 'text size'],+ });++ registerHotkey({+ hotkeyToken: TOKENS.global.zoomReset,+ hotkey: 'cmd+0',+ scopeId: 'global',+ description: () => `Actual size (${Math.round(zoom() * 100)}%)`,+ condition: () => zoom() !== DEFAULT_ZOOM,+ keyDownHandler: (e) => {+ e?.preventDefault();+ apply(DEFAULT_ZOOM);+ return true;+ },+ runWithInputFocused: true,+ icon: MagnifyingGlass,+ keywords: ['zoom', 'reset', '100%'],+ });+}diff --git a/apps/web/tauri/src-tauri/capabilities/desktop.json b/apps/web/tauri/src-tauri/capabilities/desktop.jsonnew file mode 100644index 0000000000..4372837f37--- /dev/null+++ b/apps/web/tauri/src-tauri/capabilities/desktop.json@@ -0,0 +1,9 @@+{+ "identifier": "desktop-capability",+ "description": "permissions the desktop app needs, kept out of the mobile binaries",+ "platforms": ["macOS", "windows", "linux"],+ "windows": ["main"],+ "permissions": [+ "core:webview:allow-set-webview-zoom"+ ]+}diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex 3e14d4fb96..34ea1ea4a1 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -954,6 +954,10 @@ restart rules still apply.- In Email and Tasks search, `Escape` returns focus to the list and keeps the query.Use the search field's clear button to clear it.- Splits: `` ` `` split, `Shift+H`/`Shift+L` move focus, `Shift+Esc` maximize.+- Desktop app only: `Ctrl/Cmd` with `+`, `-`, and `0` zoom the page and reset it,+ through the same stops a browser uses. The level persists across relaunches,+ and the commands appear in the command menu as Zoom in / Zoom out / Actual+ size. In a browser tab these stay the browser's own zoom.- In any text surface: `@` mentions (bidirectional links), `#` tags, `/` block commands,`:` emoji. Clicking a rendered tag opens a Search split filtered to that tag.