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(channels): focus video playback when opening the viewer (#9519)

gbirmancd6e639a0d1c
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 67b135330a..9ddd5b1e38 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -1017,10 +1017,12 @@ while preparing a share, retain the bytes and let the same action's next tap
open the system sheet synchronously. Browser success means handoff, not confirmed
disk completion. See the native bridge's `tauri/file_export_plugin/AGENTS.md`.
Keep download confirmations title-only and lightbox Download controls icon-only.
+Keep the expanded video first in the dialog's tab order so initial Space presses
+control native playback; restore focus to its opener on close.
The backend-free browser regression downloads real fixture bytes from channel
cards, the expanded viewer, and the shared Drive/standalone header on desktop,
-phone, and tablet:
+phone, and tablet, and checks Space playback on opening and reopening the viewer:
`bunx playwright test --config src/lib/core/component/FileDownload/browser-test/playwright.config.ts`.
See the [download walkthrough](../../docs/agent-guide/files.md#downloading-files).
diff --git a/apps/web/src/features/channel/Media/MediaViewerDialog.tsx b/apps/web/src/features/channel/Media/MediaViewerDialog.tsx
index b6cae351ac..47591f0f97 100644
--- a/apps/web/src/features/channel/Media/MediaViewerDialog.tsx
+++ b/apps/web/src/features/channel/Media/MediaViewerDialog.tsx
@@ -91,6 +91,17 @@ function VideoViewerContent(props: {
}
}}
>
+ <div class="flex size-full items-center justify-center">
+ <video
+ class="max-h-[80vh] max-w-[90vw] rounded-2xl bg-[black]"
+ tabIndex={0}
+ controls
+ autoplay
+ playsinline
+ src={props.item().fullSrc}
+ />
+ </div>
+
<LightboxToolbar isVisible={true}>
<FileDownloadButton download={props.download} iconOnly />
<Dialog.CloseButton
@@ -136,16 +147,6 @@ function VideoViewerContent(props: {
<ChevronRightIcon class="size-5 text-ink" />
</button>
</Show>
-
- <div class="flex size-full items-center justify-center">
- <video
- class="max-h-[80vh] max-w-[90vw] rounded-2xl bg-[black]"
- controls
- autoplay
- playsinline
- src={props.item().fullSrc}
- />
- </div>
</Dialog.Content>
</div>
);
diff --git a/apps/web/src/lib/core/component/FileDownload/browser-test/download.browser.e2e.ts b/apps/web/src/lib/core/component/FileDownload/browser-test/download.browser.e2e.ts
index 4e0bb0f21b..f70a1254aa 100644
--- a/apps/web/src/lib/core/component/FileDownload/browser-test/download.browser.e2e.ts
+++ b/apps/web/src/lib/core/component/FileDownload/browser-test/download.browser.e2e.ts
@@ -51,7 +51,15 @@ test('downloads the original video from the message and expanded viewer', async
const secondDownload = page.waitForEvent('download');
await clickDownload();
expect((await secondDownload).suggestedFilename()).toBe('Team demo.webm');
- await page.keyboard.press('Escape');
+ await expect(
+ page
+ .getByRole('dialog')
+ .getByRole('button', { name: 'Download', exact: true })
+ ).toBeFocused();
+ await page
+ .getByRole('dialog')
+ .getByRole('button', { name: 'Close', exact: true })
+ .click();
await expect(
page.getByRole('button', { name: 'Open video viewer', exact: true }).first()
).toBeFocused();
@@ -61,6 +69,38 @@ test('downloads the original video from the message and expanded viewer', async
);
});
+test('Space controls video playback when the viewer opens and reopens', async ({
+ page,
+}) => {
+ const downloads: string[] = [];
+ page.on('download', (download) =>
+ downloads.push(download.suggestedFilename())
+ );
+ const opener = page
+ .getByRole('button', { name: 'Open video viewer', exact: true })
+ .first();
+
+ for (let opening = 0; opening < 2; opening++) {
+ await opener.click();
+ const video = page.getByRole('dialog').locator('video');
+ // Keep the short fixture playing until the keyboard pauses it.
+ await video.evaluate((element: HTMLVideoElement) => {
+ element.loop = true;
+ });
+ await expect(video).toHaveJSProperty('paused', false);
+ await page.keyboard.press('Space');
+ await expect(video).toHaveJSProperty('paused', true);
+ await expect(video).toBeFocused();
+ await page.keyboard.press('Space');
+ await expect(video).toHaveJSProperty('paused', false);
+ expect(downloads).toEqual([]);
+
+ await page.keyboard.press('Escape');
+ await expect(page.getByRole('dialog')).toHaveCount(0);
+ await expect(opener).toBeFocused();
+ }
+});
+
test('recovers from a failed transfer and never opens the viewer when downloading', async ({
page,
}) => {
diff --git a/docs/agent-guide/channels.md b/docs/agent-guide/channels.md
index 2a82311d4a..3b7030d8af 100644
--- a/docs/agent-guide/channels.md
+++ b/docs/agent-guide/channels.md
@@ -1658,6 +1658,12 @@ MIME type. Linked video preview cards also offer Download, using the document's
current version, name, and file type. See [Downloading files](files.md#downloading-files)
for progress, cancellation, retries, and mobile save/share verification.
+Opening or reopening the expanded video viewer focuses the video. Press Space
+to pause or resume immediately. Tab moves through the native player controls
+and viewer actions; focusing Download explicitly still allows keyboard downloads.
+With the video focused, Escape closes the viewer and returns focus to the
+thumbnail that opened it.
+
## Pending message drafts
Sending clears the composer immediately while delivery is pending. If delivery