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): ask ai attach button (#6542)
Peter Chinman8e54e0fba58a
diff --git a/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsxindex c21e75e440..c2cae5c69e 100644--- a/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx+++ b/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx@@ -153,13 +153,11 @@ vi.mock('@core/mobile/virtualKeyboard', () => ({vi.mock('@core/mobile/useTouchOutsideToDismissKeyboard', () => ({useTouchOutsideToDismissKeyboard: () => {},}));-vi.mock('@core/util/getItemBlockName', () => ({}));vi.mock('@core/util/upload', () => ({}));vi.mock('@solid-primitives/resize-observer', () => ({createElementSize: () => ({ width: 44, height: 20 }),}));vi.mock('./Attachment', () => ({ AttachmentList: () => null }));-vi.mock('./ChatAttachMenu', () => ({ ChatAttachMenu: () => null }));vi.mock('./useAiDataConsent', () => ({useAiDataConsentGate: () => ({ ConsentDialog: () => null }),}));diff --git a/apps/web/src/lib/core/component/AI/component/input/ChatInput.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ChatInput.test.tsxindex ab7a477966..3798a011bf 100644--- a/apps/web/src/lib/core/component/AI/component/input/ChatInput.test.tsx+++ b/apps/web/src/lib/core/component/AI/component/input/ChatInput.test.tsx@@ -64,16 +64,12 @@ vi.mock('@core/mobile/isNativeMobilePlatform', () => ({vi.mock('@core/mobile/useTouchOutsideToDismissKeyboard', () => ({useTouchOutsideToDismissKeyboard: () => {},}));-vi.mock('@core/util/getItemBlockName', () => ({}));vi.mock('@core/util/upload', () => ({}));vi.mock('@solid-primitives/resize-observer', () => ({createElementSize: () => ({ width: 44, height: 20 }),}));vi.mock('./Attachment', () => ({ AttachmentList: () => null }));vi.mock('./ModelSelector', () => ({ ModelSelector: () => null }));-vi.mock('./ChatAttachMenu', () => ({- ChatAttachMenu: () => <input aria-label="Search attachments" />,-}));vi.mock('./useAiDataConsent', () => ({useAiDataConsentGate: () => ({ ConsentDialog: () => null }),}));@@ -198,7 +194,6 @@ describe('compact mobile chat drafts', () => {const attach = screen.getByRole('button', { name: 'Attach files' });attach.focus();fireEvent.click(attach);- screen.getByRole('textbox', { name: 'Search attachments' }).focus();expect(wrapper.classList.contains('max-h-5')).toBe(false);});@@ -214,19 +209,32 @@ describe('compact mobile chat drafts', () => {});});-it('opens the desktop file picker directly and uploads the selected files', () => {- mocks.touch = false;- setup();- const click = vi.spyOn(HTMLInputElement.prototype, 'click');- fireEvent.click(screen.getByRole('button', { name: 'Attach files' }));- expect(click).toHaveBeenCalledOnce();- click.mockRestore();- expect(- screen.queryByRole('textbox', { name: 'Search attachments' })- ).toBeNull();- const picker =- document.querySelector<HTMLInputElement>('input[type="file"]')!;- const file = new File(['pdf'], 'report.pdf', { type: 'application/pdf' });- fireEvent.change(picker, { target: { files: [file] } });- expect(mocks.upload).toHaveBeenCalledExactlyOnceWith([file]);-});+it.each([true, false])(+ 'opens the device file picker directly and uploads selected files (touch=%s)',+ (touch) => {+ mocks.touch = touch;+ const { input, draft } = setup();+ const picker =+ document.querySelector<HTMLInputElement>('input[type="file"]')!;+ expect(picker.isConnected).toBe(true);+ expect(picker.multiple).toBe(true);+ expect(picker.accept).toBe('.pdf,.png');+ const click = vi.spyOn(picker, 'click');+ fireEvent.click(screen.getByRole('button', { name: 'Attach files' }));+ expect(click).toHaveBeenCalledOnce();+ click.mockRestore();+ expect(screen.queryByPlaceholderText('Search Attachments')).toBeNull();++ fireEvent(picker, new Event('cancel'));+ expect(mocks.upload).not.toHaveBeenCalled();+ expect(input.textContent).toBe(draft);++ const file = new File(['pdf'], 'report.PDF', { type: 'application/pdf' });+ const image = new File(['png'], 'image.png', { type: 'image/png' });+ const unsupported = new File(['zip'], 'archive.zip');+ fireEvent.change(picker, { target: { files: [file, image, unsupported] } });+ expect(mocks.upload).toHaveBeenCalledExactlyOnceWith([file, image]);+ expect(picker.value).toBe('');+ expect(input.textContent).toBe(draft);+ }+);diff --git a/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx b/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsxindex de0871b697..38b3de741b 100644--- a/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx+++ b/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx@@ -23,7 +23,6 @@ import { isMobile } from '@core/mobile/isMobile';import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideToDismissKeyboard';-import { getItemBlockName } from '@core/util/getItemBlockName';import { handleFileFolderDrop } from '@core/util/upload';import PaperclipIcon from '@phosphor/paperclip.svg';import { createElementSize } from '@solid-primitives/resize-observer';@@ -31,7 +30,6 @@ import { createCallback } from '@solid-primitives/rootless';import { Button, ComposerSurface, cn, SendButton as UiSendButton } from '@ui';import { createEffect, createMemo, createSignal, Show } from 'solid-js';import { AttachmentList } from './Attachment';-import { ChatAttachMenu } from './ChatAttachMenu';import { useAiDataConsentGate } from './useAiDataConsent';/**@@ -134,9 +132,6 @@ export function ChatInput(props: ChatInputComponentProps) {const toolsetSignal = createSignal<ToolSet>({ type: 'all' });const { hasConsent, requestConsent, ConsentDialog } = useAiDataConsentGate();- const [showAttachMenu, setShowAttachMenu] = createSignal(false);- const [attachMenuAnchorRef, setAttachMenuAnchorRef] =- createSignal<HTMLDivElement>();const [markdownText, setMarkdownText] = createSignal('');const [isFocused, setIsFocused] = createSignal(false);@@ -248,15 +243,14 @@ export function ChatInput(props: ChatInputComponentProps) {const LeftButton = () => (<Button- ref={setAttachMenuAnchorRef}variant="ghost"size="icon-composer"class="rounded-full text-ink not-touch:text-composer-ink touch:size-6"label="Attach files"aria-label="Attach files"onClick={() => {- if (isTouchDevice()) setShowAttachMenu((prev) => !prev);- else fileInputRef?.click();+ // Open synchronously from the tap so the native picker retains user activation.+ fileInputRef?.click();}}><PaperclipIcon />@@ -331,27 +325,25 @@ export function ChatInput(props: ChatInputComponentProps) {return (<div class="relative">- <Show when={!isTouchDevice()}>- <input- ref={fileInputRef}- type="file"- class="hidden"- multiple- accept={SUPPORTED_ATTACHMENT_EXTENSIONS.map((ext) => `.${ext}`).join(- ','- )}- onChange={(event) => {- const files = Array.from(event.currentTarget.files ?? []).filter(- (file) =>- SUPPORTED_ATTACHMENT_EXTENSIONS.includes(- file.name.split('.').pop()?.toLowerCase() ?? ''- )- );- event.currentTarget.value = '';- if (files.length > 0) uploadQueue.upload(files);- }}- />- </Show>+ <input+ ref={fileInputRef}+ type="file"+ class="hidden"+ multiple+ accept={SUPPORTED_ATTACHMENT_EXTENSIONS.map((ext) => `.${ext}`).join(+ ','+ )}+ onChange={(event) => {+ const files = Array.from(event.currentTarget.files ?? []).filter(+ (file) =>+ SUPPORTED_ATTACHMENT_EXTENSIONS.includes(+ file.name.split('.').pop()?.toLowerCase() ?? ''+ )+ );+ event.currentTarget.value = '';+ if (files.length > 0) uploadQueue.upload(files);+ }}+ /><ComposerSurfaceclass={cn('h-auto',@@ -377,27 +369,6 @@ export function ChatInput(props: ChatInputComponentProps) {<Attachments /></Show>- <Show when={showAttachMenu()}>- <ChatAttachMenu- anchorRef={attachMenuAnchorRef()!}- close={() => setShowAttachMenu(false)}- containerRef={containerRef}- open={showAttachMenu()}- onAttach={(attachment, item) => {- analytics.track('ai_attachment_add');- attachments.addAttachment(attachment);- insertChatAttachmentMention(- props.editor.controls.getLexical(),- {- documentId: item.id,- documentName: item.name,- blockName: getItemBlockName(item, true),- }- );- }}- />- </Show>-<divdata-chat-input-layout=""data-composer-compact={diff --git a/bun.lock b/bun.lockindex f0f7012326..9d8c307d59 100644--- a/bun.lock+++ b/bun.lock@@ -969,7 +969,7 @@"@img/sharp-win32-x64": ["@img/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw=="],- "@inkibra/tauri-plugins": ["@inkibra/tauri-plugins@github:macro-inc/tauri-plugins#6ddd660", { "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" } }, "macro-inc-tauri-plugins-6ddd660"],+ "@inkibra/tauri-plugins": ["@inkibra/tauri-plugins@github:macro-inc/tauri-plugins#6ddd660", { "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1" } }, "macro-inc-tauri-plugins-6ddd660", "sha512-7+0ebEOYqedkOY67Clwu65Np3qJ3aJc/H/NjNxmjgA/7HIu0C+DSoKAArG7HTdTVpdcAtHyhrqsJujdEAyJf6Q=="],"@inquirer/ansi": ["@inquirer/[email protected]", "", {}, "sha512-3eTuUO1vH2cZm2ZKHeQxnOqlTi9EfZDGgIe3BL3I4u+rJHocr9Fz86M4fjYABPvFnQG/gGK551HqDiIcETwU6Q=="],@@ -2933,7 +2933,7 @@"pathval": ["[email protected]", "", {}, "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ=="],- "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6"],+ "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6", "sha512-HDFaPbCxLG2GHpf1smUG97nku5aPGBGaCcIbK05dGdp07TBLUlDcXsM4WcE82mO5W4RBPIBVYobX5N/6M6NFrA=="],"pend": ["[email protected]", "", {}, "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg=="],diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.mdindex b3ec6e1395..77ee9f681b 100644--- a/docs/AGENT_GUIDE/ai-chat.md+++ b/docs/AGENT_GUIDE/ai-chat.md@@ -40,6 +40,10 @@ is available, the AI composer returns with its draft intact, including indocuments without a comment composer. Type aprompt, optionally choose a model orattach context, and tap **Send** to create the chat and send its first message.+The paperclip (**Attach files**) opens the device file chooser directly, including+in the native iPhone app; it does not open a Macro file browser. Select supported+files to upload and attach them, or cancel to return to the unchanged draft.+Existing Macro documents can still be attached through an `@mention`.On touch devices, the accessory hides whenever an editable field outside itsAsk AI composer is focused, including email recipients, subject, and body fields.It returns with the same draft when focus leaves that field. While typing in