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(docx): move download into the document menu (#9042)
gbirmana644e578b69a
diff --git a/apps/web/src/features/block-write/DocxBlock.tsx b/apps/web/src/features/block-write/DocxBlock.tsxindex cc8ed6f258..2700a3a993 100644--- a/apps/web/src/features/block-write/DocxBlock.tsx+++ b/apps/web/src/features/block-write/DocxBlock.tsx@@ -1,4 +1,5 @@import { ChatWithAgentButton } from '@app/features/chat/ChatWithAgentButton';+import { t } from '@app/lib/i18n';import {ResponsiveBlockToolbar,ResponsivePermissionsBadge,@@ -141,7 +142,9 @@ export default function DocxBlock(props: { share?: string }) {{ op: 'moveToProject' },{group: 'file',- label: 'Download',+ get label() {+ return t('entityActions.downloadDocx');+ },icon: DownloadSimple,action: () =>fireAndForget(docxDownload.download(), 'docx-download'),diff --git a/apps/web/src/features/block-write/browser-test/collaboration.browser.e2e.ts b/apps/web/src/features/block-write/browser-test/collaboration.browser.e2e.tsindex 3e06a50f17..54bf0c9e48 100644--- a/apps/web/src/features/block-write/browser-test/collaboration.browser.e2e.ts+++ b/apps/web/src/features/block-write/browser-test/collaboration.browser.e2e.ts@@ -192,9 +192,10 @@ test('two people edit the same DOCX live through the sync service', async ({if (SHOTS) await bob.screenshot({ path: `${SHOTS}/03-comments.png` });// Download produces a clean .docx carrying everyone's edits.+ await bob.getByRole('button', { name: 'Document options' }).click();const [download] = await Promise.all([bob.waitForEvent('download'),- bob.getByRole('button', { name: 'Download .docx' }).click(),+ bob.getByRole('menuitem', { name: 'Download' }).click(),]);if (SHOTS) await download.saveAs(`${SHOTS}/edited.docx`);const files = unzipSync(@@ -392,9 +393,10 @@ test('headers and footers are edited in place and shared', async ({await expect.poll(() => joined(bob)).toContain('[body]');// Bob's download carries the new header.+ await bob.getByRole('button', { name: 'Document options' }).click();const [download] = await Promise.all([bob.waitForEvent('download'),- bob.getByRole('button', { name: 'Download .docx' }).click(),+ bob.getByRole('menuitem', { name: 'Download' }).click(),]);const files = unzipSync(new Uint8Array(await readFile((await download.path())!))@@ -526,9 +528,10 @@ test('comments in the file show beside their text', async ({ browser }) => {).toBeVisible();if (SHOTS) await page.screenshot({ path: `${SHOTS}/06-word-comments.png` });// The comments stay in the downloaded file.+ await page.getByRole('button', { name: 'Document options' }).click();const [download] = await Promise.all([page.waitForEvent('download'),- page.getByRole('button', { name: 'Download .docx' }).click(),+ page.getByRole('menuitem', { name: 'Download' }).click(),]);const files = unzipSync(new Uint8Array(await readFile((await download.path())!))@@ -609,9 +612,10 @@ test('footnotes are edited where they are and shared', async ({ browser }) => {await expect.poll(() => story(alice)).toBe('body');// Bob's download carries the edited note and keeps the separators.+ await bob.getByRole('button', { name: 'Document options' }).click();const [download] = await Promise.all([bob.waitForEvent('download'),- bob.getByRole('button', { name: 'Download .docx' }).click(),+ bob.getByRole('menuitem', { name: 'Download' }).click(),]);const files = unzipSync(new Uint8Array(await readFile((await download.path())!))diff --git a/apps/web/src/features/block-write/browser-test/fixture.tsx b/apps/web/src/features/block-write/browser-test/fixture.tsxindex 4e48eb9983..23d27c1e6b 100644--- a/apps/web/src/features/block-write/browser-test/fixture.tsx+++ b/apps/web/src/features/block-write/browser-test/fixture.tsx@@ -1,3 +1,4 @@+import { Dropdown } from '@ui/components/Dropdown';import '@fontsource-variable/inter';import '../../../index.css';import { ThrownResultError } from '@core/util/result';@@ -435,6 +436,16 @@ function Fixture() {onSelection={session.setSelection}commentRoots={roots}onReady={setEditor}+ actions={(download) => (+ <Dropdown>+ <Dropdown.Trigger label="Document options">+ …+ </Dropdown.Trigger>+ <Dropdown.Content>+ <Dropdown.Item onSelect={download}>Download</Dropdown.Item>+ </Dropdown.Content>+ </Dropdown>+ )}onDownload={(bytes) => {const url = URL.createObjectURL(new Blob([bytes.slice().buffer], {@@ -558,7 +569,30 @@ function LocalFixture() {peers={() => []}displayName={shortName}onReady={index() === 0 ? setEditor : undefined}- onDownload={() => {}}+ actions={(download) => (+ <Dropdown>+ <Dropdown.Trigger label="Document options">+ …+ </Dropdown.Trigger>+ <Dropdown.Content>+ <Dropdown.Item onSelect={download}>+ Download+ </Dropdown.Item>+ </Dropdown.Content>+ </Dropdown>+ )}+ onDownload={(bytes) => {+ const url = URL.createObjectURL(+ new Blob([bytes.slice().buffer], {+ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',+ })+ );+ const anchor = document.createElement('a');+ anchor.href = url;+ anchor.download = 'fixture.docx';+ anchor.click();+ setTimeout(() => URL.revokeObjectURL(url), 1_000);+ }}onError={(error) => console.error('[docx-fixture]', error)}/></div>diff --git a/apps/web/src/features/block-write/components/DocxToolbar.tsx b/apps/web/src/features/block-write/components/DocxToolbar.tsxindex 7850c79c27..d0d25d5ab6 100644--- a/apps/web/src/features/block-write/components/DocxToolbar.tsx+++ b/apps/web/src/features/block-write/components/DocxToolbar.tsx@@ -5,7 +5,6 @@ import AsteriskSimple from '@icon/system/regular/asterisk-simple.svg';import ChatCircleText from '@icon/system/regular/chat-circle-text.svg';import Check from '@icon/system/regular/check.svg';import Checks from '@icon/system/regular/checks.svg';-import DownloadSimple from '@icon/system/regular/download-simple.svg';import Eye from '@icon/system/regular/eye.svg';import EyeSlash from '@icon/system/regular/eye-slash.svg';import GitDiff from '@icon/system/regular/git-diff.svg';@@ -174,7 +173,6 @@ export type DocxToolbarProps = {onComment: () => void;/** Open find (and replace). */onFind: () => void;- onDownload: () => void;};const INLINE: Array<{@@ -624,12 +622,6 @@ export function DocxToolbar(props: DocxToolbarProps) {><MagnifyingGlass /></Toolbar.Button>- <Toolbar.Button- label="Download .docx"- onClick={() => props.onDownload()}- >- <DownloadSimple />- </Toolbar.Button></Toolbar></div>);diff --git a/apps/web/src/features/block-write/primitives/create-docx-download.ts b/apps/web/src/features/block-write/primitives/create-docx-download.tsindex 1328c4cf3f..074b6e1757 100644--- a/apps/web/src/features/block-write/primitives/create-docx-download.ts+++ b/apps/web/src/features/block-write/primitives/create-docx-download.ts@@ -7,9 +7,9 @@ const DOCX_MIME ='application/vnd.openxmlformats-officedocument.wordprocessingml.document';/**- * Saving a Word document as a `.docx`, for the editor toolbar and the file- * menu alike. The mounted editor saves its live state, unsynced edits- * included; before it mounts, the server's export is the latest copy.+ * Saving a Word document as a `.docx` from the file menu. The mounted editor+ * saves its live state, unsynced edits included; before it mounts, the server's+ * export is the latest copy.*/export function createDocxDownload(options: {documentId: string;diff --git a/apps/web/src/features/block-write/views/DocxEditorView.tsx b/apps/web/src/features/block-write/views/DocxEditorView.tsxindex b3f4cbbc67..71db3d9455 100644--- a/apps/web/src/features/block-write/views/DocxEditorView.tsx+++ b/apps/web/src/features/block-write/views/DocxEditorView.tsx@@ -73,6 +73,7 @@ export type DocxEditorViewProps = {margin?: (context: DocxMarginContext) => JSX.Element;/** Content below the page (discussion, detached comments). */footer?: (comments: DocxComments) => JSX.Element;+ actions?: (download: () => void) => JSX.Element;onDownload: (bytes: Uint8Array) => void;onError?: (error: unknown) => void;/** The mounted editor, for actions outside its toolbar (file menu Download). */@@ -81,6 +82,13 @@ export type DocxEditorViewProps = {/** The collaborative DOCX editor: toolbar, pages, collaborators and comments. */export function DocxEditorView(props: DocxEditorViewProps) {+ const download = () => {+ editor+ .idle()+ .then(() => editor.save())+ .then(props.onDownload)+ .catch((error: unknown) => props.onError?.(error));+ };const [scroller, setScroller] = createSignal<HTMLDivElement>();let input: HTMLTextAreaElement | undefined;let selectionTimer: ReturnType<typeof setTimeout> | undefined;@@ -329,6 +337,7 @@ export function DocxEditorView(props: DocxEditorViewProps) {.docx-find-current { background-color: oklch(from var(--color-orange) l c h / 0.6); box-shadow: 0 0 0 1px oklch(from var(--color-orange) l c h / 0.9); }.docx-veil { background: rgb(255 255 255 / 0.55); }.docx-story-edge { border-color: oklch(from var(--color-accent, #3b82f6) l c h / 0.8); }`}</style>+ {props.actions?.(download)}<DocxToolbarcanEdit={props.canEdit}canComment={@@ -405,13 +414,6 @@ export function DocxEditorView(props: DocxEditorViewProps) {onReject={(all) => editor.run([{ op: 'rejectChanges', all }])}onComment={beginComment}onFind={() => find.show(false)}- onDownload={() => {- editor- .idle()- .then(() => editor.save())- .then(props.onDownload)- .catch((error: unknown) => props.onError?.(error));- }}/><div class="relative flex min-h-0 flex-1 flex-col"><divdiff --git a/apps/web/src/lib/i18n/locales/en/entity-actions.ts b/apps/web/src/lib/i18n/locales/en/entity-actions.tsindex a838ffcae6..cd695544ac 100644--- a/apps/web/src/lib/i18n/locales/en/entity-actions.ts+++ b/apps/web/src/lib/i18n/locales/en/entity-actions.ts@@ -40,6 +40,7 @@ export default {copyBranchNameCommand: 'Copy branch name',copyId: 'Copy ID',share: 'Share',+ downloadDocx: 'Download',senderToSignal: 'Sender → Signal',senderToNoise: 'Sender → Noise',blockSender: 'Block Sender',diff --git a/docs/agent-guide/documents.md b/docs/agent-guide/documents.mdindex b58c6c9ed3..8944b4672a 100644--- a/docs/agent-guide/documents.md+++ b/docs/agent-guide/documents.md@@ -2891,10 +2891,9 @@ updates live and shows each collaborator's caret with their namedelete rows and columns or the table), the `Insert footnote or endnote`menu (`[data-docx-menu="notes"]`, in the body), `Track changes`, `Hide trackedchanges` / `Show tracked changes`, `Comment on selection`, `Find and- replace` and `Download .docx` (viewers get `Find and replace` and- `Download .docx`). The header's "…" file menu also has **Download**, which- saves the same live `.docx`, or the server's export before the editor has- loaded.+ replace` (viewers get `Find and replace`). The header's three-dot file menu+ has **Download** on desktop and mobile, which saves the live `.docx`, or the+ server's export before the editor has loaded.While tracking is on (or the caret is on a tracked change) it also shows`Accept change`, `Reject change`, `Accept all changes` and `Reject allchanges`.@@ -2963,7 +2962,7 @@ updates live and shows each collaborator's caret with their nameWord comments (`addComment`), both attributed to the requesting user byname rather than to the agent. Its comments are written into the file, sothey appear as `In the document` cards and travel with the download.-- `Download .docx` exports the current collaborative state with every edit,+- `Download` exports the current collaborative state with every edit,including headers, footers and tracked changes. Macro comment threads arenot written into the file; Word comments (including the agent's`addComment` ones) are.