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(sharing): copy standalone item links (#9367)
dev-rba300f1898b61
diff --git a/apps/web/src/features/block-pdf/signal/location.test.ts b/apps/web/src/features/block-pdf/signal/location.test.tsindex 680a9ae225..70b59685e0 100644--- a/apps/web/src/features/block-pdf/signal/location.test.ts+++ b/apps/web/src/features/block-pdf/signal/location.test.ts@@ -1,6 +1,12 @@import { createRoot, createSignal } from 'solid-js';import { afterEach, beforeEach, expect, it, vi } from 'vitest';-import { useGoToLinkLocation } from './location';+import {+ locationToUrl,+ useCreateShareUrl,+ useGoToLinkLocation,+} from './location';++const originalUrl = window.location.href;const state = vi.hoisted(() => ({persistedViewLocation: (): string | undefined => undefined,@@ -10,12 +16,15 @@ const state = vi.hoisted(() => ({vi.mock('../context/pdf-document-context', () => ({usePdfDocument: () => ({+ documentId: () => 'shared-pdf',+ shareLocation: () => undefined,persistedViewLocation: () => state.persistedViewLocation(),}),}));vi.mock('../context/pdf-viewer-context', () => ({usePdfViewer: () => ({root: {+ currentPageNumber: () => 4,isReady: () => state.ready(),hasVisiblePages: () => state.ready(),instance: () => ({ goToLocationHash: state.goToLocationHash }),@@ -28,7 +37,10 @@ beforeEach(() => {vi.useFakeTimers();vi.clearAllMocks();});-afterEach(() => vi.useRealTimers());+afterEach(() => {+ vi.useRealTimers();+ window.history.replaceState(null, '', originalUrl);+});function setup(persistedViewLocation?: string) {const [ready, setReady] = createSignal(false);@@ -62,3 +74,49 @@ it('settles without restoring when the viewer never shows pages', async () => {await expect(navigation).resolves.toBeUndefined();expect(state.goToLocationHash).not.toHaveBeenCalled();});++it('copies the viewed PDF without the surrounding route or split state', () => {+ window.history.replaceState(+ null,+ '',+ '/app/drive/folder/folder-1/md/other-document?s0.taskId=other-task&pdf_page_number=9#selection'+ );+ const shareUrl = createRoot(() => useCreateShareUrl());++ expect(shareUrl('general')).toBe(+ `${window.location.origin}/app/pdf/shared-pdf?pdf_page_number=4&pdf_page_y=0`+ );+});++it('keeps only the selected annotation in a PDF link', () => {+ window.history.replaceState(+ null,+ '',+ '/app/drive/pdf/other-pdf?s1.path=/app/task/other-task#selection'+ );++ expect(+ locationToUrl('shared-pdf', {+ type: 'annotation',+ pageIndex: 2,+ id: 'annotation-1',+ })+ ).toBe(+ `${window.location.origin}/app/pdf/shared-pdf?pdf_ann_id=annotation-1`+ );+});++it('preserves precise PDF coordinates rounded to three decimal places', () => {+ expect(+ locationToUrl('shared-pdf', {+ type: 'precise',+ pageIndex: 2,+ y: 0.123456,+ x: 0.234567,+ width: 0.345678,+ height: 0.456789,+ })+ ).toBe(+ `${window.location.origin}/app/pdf/shared-pdf?pdf_page_number=2&pdf_page_y=0.123&pdf_page_x=0.235&pdf_width=0.346&pdf_height=0.457`+ );+});diff --git a/apps/web/src/features/block-pdf/signal/location.ts b/apps/web/src/features/block-pdf/signal/location.tsindex 26956e6d2a..35e1f8e415 100644--- a/apps/web/src/features/block-pdf/signal/location.ts+++ b/apps/web/src/features/block-pdf/signal/location.ts@@ -109,19 +109,14 @@ const useIsViewerReadyForScroll = () => {return () => rootViewer.isReady() && rootViewer.hasVisiblePages();};-/**- * Converts a location into URL parameters for sharing.- *- * @param location - The PDF location to convert- * @returns URL with location parameters- */-export function locationToUrl(location: PdfLocation | undefined): string {- const url = new URL(window.location.href);+/** Builds a standalone PDF link with only the selected location parameters. */+export function locationToUrl(+ documentId: string,+ location: PdfLocation | undefined+): string {+ const url = new URL(buildSimpleEntityUrl({ type: 'pdf', id: documentId }));const params = url.searchParams;- // Clear existing parameters- Object.values(URL_PARAMS).forEach((param) => params.delete(param));-if (!location) {return url.toString();}@@ -199,9 +194,7 @@ export function useCreateShareUrl() {shareLocation?.type === 'annotation' ? shareLocation : undefined,};const selectedLocation = selectLocationForFidelity(fidelity, locations);- const url = locationToUrl(selectedLocation);- const params = Object.fromEntries(new URL(url).searchParams);- return buildSimpleEntityUrl({ type: 'pdf', id: pdf.documentId() }, params);+ return locationToUrl(pdf.documentId(), selectedLocation);};return createCallback(createShareUrl);}diff --git a/apps/web/src/features/drive-view/components/DriveDetailView.tsx b/apps/web/src/features/drive-view/components/DriveDetailView.tsxindex dcaae04d53..67b68817e5 100644--- a/apps/web/src/features/drive-view/components/DriveDetailView.tsx+++ b/apps/web/src/features/drive-view/components/DriveDetailView.tsx@@ -16,7 +16,6 @@ import { SidePanel } from '@components/app/side-panel';import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';import { ShareTrigger } from '@core/component/TopBar/ShareButton';import { useDocumentShareModal } from '@core/component/TopBar/shareModal';-import { useCopyLink } from '@core/util/useCopyLink';import { ErrorBoundary, For, Match, Show, Switch } from 'solid-js';import { useOptionalDriveView } from '../context/drive-context';import { driveLocationBreadcrumbs } from '../core/breadcrumbs';@@ -68,8 +67,6 @@ function hasBlockHeader(target: EntityDetailTarget) {function DriveDetailTopBar() {const navigationStack = useDriveDetailNavigation();const panel = useSplitPanelOrThrow();- const copyViewLink = useCopyLink();- const copyLink = () => copyViewLink(window.location.href);const activeDetail = () => {const target = navigationStack.active()?.data;const blockType = target ? entityDetailBlockType(target) : undefined;@@ -83,7 +80,6 @@ function DriveDetailTopBar() {return {documentId: detail.target.id,blockAlias: detail.blockType,- copyLink,};});@@ -102,7 +98,6 @@ function DriveDetailTopBar() {id={detail().target.id}blockType={detail().blockType}hotkeyScope={panel.splitHotkeyScope}- copyLink={copyLink}/>)}</Show>diff --git a/docs/agent-guide/files.md b/docs/agent-guide/files.mdindex 2bc896bc4b..bffebc073d 100644--- a/docs/agent-guide/files.md+++ b/docs/agent-guide/files.md@@ -16,6 +16,12 @@ viewer identity is available, document inserts into Shared are rejected.Files opens **Drive** using the same shell as Tasks, on desktop and touchdevices alike.+The document header's **Copy Share Link** and the Share dialog's **Copy Link**+copy a standalone link to the selected file, not the current browser URL.+Folder paths, list filters, and other open splits are not included.+PDF location links retain the selected page or annotation without unrelated+query parameters from the surrounding view.+With `enable-graphql-soup` enabled, supported file/folder/chat moves, trash,restore, permanent deletion, duplication, and share-policy changes use GraphQLmutations. Verify moving into a folder and back to root, opening the returned