Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(web): paste clipboard screenshots and space name tooltips in Safari (#9575)

Peter Chinman3b6b4f5a9c63
diff --git a/apps/web/src/features/calendar/components/composer/EventGuestsEditor.tsx b/apps/web/src/features/calendar/components/composer/EventGuestsEditor.tsx
index 9058f87c7e..8cb1797909 100644
--- a/apps/web/src/features/calendar/components/composer/EventGuestsEditor.tsx
+++ b/apps/web/src/features/calendar/components/composer/EventGuestsEditor.tsx
@@ -49,9 +49,9 @@ export function EventGuestRow(props: {
<div class="min-w-0 flex-1 truncate text-sm">
{guestDisplayName(props.guest)}
<Show when={guestDisplayName(props.guest) !== guestEmail(props.guest)}>
- <span class="ml-[0.5em] text-ink-muted">
- {guestEmail(props.guest)}
- </span>
+ {/* An en space is the 0.5em gap; unlike a margin, Safari's truncated-text tooltip keeps it. */}
+ {' '}
+ <span class="text-ink-muted">{guestEmail(props.guest)}</span>
</Show>
</div>
{props.children}
diff --git a/apps/web/src/features/command/CommandItem.tsx b/apps/web/src/features/command/CommandItem.tsx
index 0f0bd1df6c..854159bad5 100644
--- a/apps/web/src/features/command/CommandItem.tsx
+++ b/apps/web/src/features/command/CommandItem.tsx
@@ -169,7 +169,9 @@ function ContactDisplay(props: { contact: CrmContactEntity }) {
<span class="truncate">
<Show when={showEmail()} fallback={props.contact.email}>
{props.contact.name}
- <span class="ml-[0.5em] opacity-50">{props.contact.email}</span>
+ {/* An en space is the 0.5em gap; unlike a margin, Safari's truncated-text tooltip keeps it. */}
+ {' '}
+ <span class="opacity-50">{props.contact.email}</span>
</Show>
</span>
</div>
@@ -189,7 +191,9 @@ function UserDisplay(props: { item: UserItem }) {
<span class="truncate">
<Show when={showEmail()} fallback={email()}>
{name()}
- <span class="ml-[0.5em] opacity-50">{email()}</span>
+ {/* An en space is the 0.5em gap; unlike a margin, Safari's truncated-text tooltip keeps it. */}
+ {' '}
+ <span class="opacity-50">{email()}</span>
</Show>
</span>
</div>
diff --git a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx
index f18b2a6d59..163ee39834 100644
--- a/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx
+++ b/apps/web/src/features/property/editors/selectors/PropertyEntitySelector.tsx
@@ -548,7 +548,9 @@ export function PropertyEntitySelector(props: EntityInputProps) {
<>
{parts().name}
<Show when={parts().email}>
- <span class="ml-[0.5em] opacity-50">
+ {/* An en space is the 0.5em gap; unlike a margin, Safari's truncated-text tooltip keeps it. */}
+ {' '}
+ <span class="opacity-50">
{parts().email}
</span>
</Show>
diff --git a/apps/web/src/lib/core/component/ForwardMessageComposer/browser-test/images.browser.e2e.ts b/apps/web/src/lib/core/component/ForwardMessageComposer/browser-test/images.browser.e2e.ts
index df2f649fde..992775633c 100644
--- a/apps/web/src/lib/core/component/ForwardMessageComposer/browser-test/images.browser.e2e.ts
+++ b/apps/web/src/lib/core/component/ForwardMessageComposer/browser-test/images.browser.e2e.ts
@@ -101,7 +101,9 @@ test('accepts a dropped image and lets an upload failure recover', async ({
);
const item = data.items.add(file);
// Hold filesystem preparation so the send guard is exercised before an
- // attachment has reached the uploader.
+ // attachment has reached the uploader. Hiding the direct file read makes
+ // the drop go through this held entry.
+ Object.defineProperty(item, 'getAsFile', { value: () => null });
Object.defineProperty(item, 'webkitGetAsEntry', {
value: () => ({
isFile: true,
diff --git a/apps/web/src/lib/core/component/RecipientSelector.tsx b/apps/web/src/lib/core/component/RecipientSelector.tsx
index b3b28610e0..ca893d5aff 100644
--- a/apps/web/src/lib/core/component/RecipientSelector.tsx
+++ b/apps/web/src/lib/core/component/RecipientSelector.tsx
@@ -347,7 +347,9 @@ function RecipientComboboxItem(props: RecipientComboboxItemProps): JSX.Element {
fallback={
<Show when={showEmail} fallback={name || email}>
{name}
- <span class="ml-[0.5em] opacity-50">{email}</span>
+ {/* An en space is the 0.5em gap; unlike a margin, Safari's truncated-text tooltip keeps it. */}
+ {' '}
+ <span class="opacity-50">{email}</span>
</Show>
}
>
diff --git a/apps/web/src/lib/core/util/dataTransfer.ts b/apps/web/src/lib/core/util/dataTransfer.ts
index 46105a9630..c916238b81 100644
--- a/apps/web/src/lib/core/util/dataTransfer.ts
+++ b/apps/web/src/lib/core/util/dataTransfer.ts
@@ -95,20 +95,21 @@ function getFileItems(
return Array.from(dataTransfer.items).filter((item) => item.kind === 'file');
}
-function itemToEntry(
- item: DataTransferItem
-): FileSystemFileEntry | FileSystemDirectoryEntry | null {
+function itemToEntry(item: DataTransferItem): FileSystemEntry | null {
const entry = item.webkitGetAsEntry?.() ?? null;
- if (entry) return entry as FileSystemFileEntry | FileSystemDirectoryEntry;
+ if (entry?.isDirectory) return entry;
- // Fallback for clipboard paste where webkitGetAsEntry returns null
+ // Read files directly rather than through their entry. Chrome gives a
+ // clipboard image no entry, and WebKit gives an in-memory clipboard image
+ // (a screenshot) an entry whose file() fails with NotFoundError, because
+ // the image has no path on disk.
const file = item.getAsFile();
- return file ? createSyntheticFileEntry(file) : null;
+ if (file) return createSyntheticFileEntry(file);
+
+ return entry;
}
-function partitionEntries(
- entries: (FileSystemFileEntry | FileSystemDirectoryEntry)[]
-): ExtractedEntries {
+function partitionEntries(entries: FileSystemEntry[]): ExtractedEntries {
const fileEntries: FileSystemFileEntry[] = [];
const directoryEntries: FileSystemDirectoryEntry[] = [];
diff --git a/apps/web/src/lib/core/util/tests/data-transfer.test.ts b/apps/web/src/lib/core/util/tests/data-transfer.test.ts
index bdd38278dd..43cc1e94f7 100644
--- a/apps/web/src/lib/core/util/tests/data-transfer.test.ts
+++ b/apps/web/src/lib/core/util/tests/data-transfer.test.ts
@@ -120,6 +120,39 @@ describe('extractFileSystemEntries', () => {
expect(result.directoryEntries).toEqual([]);
});
+ test('reads a pasted image whose WebKit entry cannot load it', async () => {
+ const pastedFile = new File(['image content'], 'image.png', {
+ type: 'image/png',
+ });
+ const unreadableEntry = {
+ isFile: true,
+ isDirectory: false,
+ name: 'image.png',
+ fullPath: '/image.png',
+ filesystem: {} as FileSystem,
+ getParent: () => {},
+ file: (
+ _success: (file: File) => void,
+ failure?: (error: DOMException) => void
+ ) => failure?.(new DOMException('Path does not exist', 'NotFoundError')),
+ } as FileSystemFileEntry;
+ const dataTransfer = createMockDataTransfer([
+ {
+ kind: 'file',
+ webkitGetAsEntry: () => unreadableEntry,
+ getAsFile: () => pastedFile,
+ },
+ ]);
+
+ const result = extractFileSystemEntries(dataTransfer);
+ expect(result.fileEntries).toHaveLength(1);
+
+ const readFile = await new Promise<File>((resolve, reject) => {
+ result.fileEntries[0].file(resolve, reject);
+ });
+ expect(readFile).toBe(pastedFile);
+ });
+
test('synthetic file entry returns correct file via file() method', async () => {
const mockFile = new File(['image content'], 'pasted-image.png', {
type: 'image/png',