Skip to content

feat: in-app audio/video preview from the file explorer - #15733

Closed
ckdwns9121 wants to merge 2 commits into
stablyai:mainfrom
ckdwns9121:feat/media-file-preview
Closed

ckdwns9121 wants to merge 2 commits into
stablyai:mainfrom
ckdwns9121:feat/media-file-preview

Conversation

@ckdwns9121

@ckdwns9121 ckdwns9121 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Clicking an audio or video file (mp3, wav, m4a, mp4, mov, webm) in the file explorer used to show "Binary file — cannot display". Now it opens a real in-app player — the same native controls you get in a browser — so you can watch a screen recording or listen to a clip without leaving Orca.

What Changed

  • New MediaViewer editor component (src/renderer/src/components/editor/MediaViewer.tsx): renders a native <video controls> / <audio controls> element from the file's base64 payload via Blob + URL.createObjectURL (object URLs support seeking and avoid holding a second string copy of the file). The object URL is revoked on unmount/tab close, which also unloads playback. Failure to decode shows the same error UX as ImageViewer.
  • New shared mime map (src/shared/media-file-extensions.ts): .mp3, .wav, .m4a, .ogg, .mp4, .mov, .webm — all natively decodable by Electron's Chromium.
  • Local read path (src/main/ipc/filesystem.ts): media extensions join PREVIEWABLE_BINARY_MIME_TYPES. Media gets its own 100MB cap (MAX_PREVIEWABLE_MEDIA_SIZE) since recordings routinely exceed the 50MB image cap; images/PDFs keep 50MB, text keeps its existing limit.
  • SSH/remote read path (src/relay/fs-handler-utils.ts, fs-handler-file-read.ts): media types are advertised only on the chunked fs.readFileStream path (new STREAM_PREVIEWABLE_MIME_TYPES). The legacy single-frame fs.readFile intentionally keeps media as plain binary markers — old clients read over that path in one JSON frame, and multi-MB base64 media could blow their frame budget. Relay media keeps the existing 50MB relay cap.
  • Routing (EditorEditFileSurface.tsx, EditorConflictReviewSurface.tsx, editor-lazy-views.ts): binary previews with an audio/*/video/* mime route to the lazy-loaded MediaViewer; everything else keeps going to ImageViewer.
  • i18n: the two MediaViewer strings are in all five locale catalogs.

Explicitly not in scope (matching the issue): diff-mode media preview (git diff allowlist untouched, so a changed .mp4 still shows "Binary file changed"), waveforms/thumbnails, custom transport controls, and the mobile/OMP runtime read path (orca-runtime-files.ts) — happy to follow up on that one.

Why

Fixes the gap described in #8344: images and PDFs already preview in-app via the binary-preview pipeline, but audio/video fell through to "Binary file — cannot display", forcing a context switch to an external app. This reuses the exact same pipeline (isImage + mimeType contract) end to end, so the change is additive and small.

Linked Issue

Fixes #6751

Supersedes duplicate #8344

Visual Proof

Before After
before — "Binary file — cannot display" (Korean UI: "바이너리 파일 – 표시할 수 없음") after — in-app video player with native controls

Both captured from the E2E harness (headless Electron, seeded repo) opening the same media-preview-clip.webm from the file explorer — before on main, after on this branch. The UI language is Korean in the screenshots; the before-state text is the localized "Binary file — cannot display".

Related: #12570 adds video preview to the mobile file viewer; this PR covers the desktop editor surface. The mobile/OMP runtime read path is untouched here.

Testing

  • pnpm lint ✅ (includes localization catalog/extraction/coverage checks)

  • pnpm typecheck ✅

  • Unit tests ✅ — new/updated suites:

    • src/shared/media-file-extensions.test.ts (mime map, webm/ogg coverage, non-media rejection)
    • src/renderer/src/components/editor/MediaViewer.test.tsx (video vs audio routing, decode-failure error state, object-URL revocation on cleanup)
    • src/main/ipc/filesystem.test.ts (webm/mp4/mp3 base64 previews; 100MB media cap allows 80MB media, rejects 101MB; images still capped at 50MB)
    • src/relay/fs-handler-stream.test.ts (stream path advertises video/webm metadata and streams chunks intact)
    • src/relay/fs-handler-file-read-media.test.ts (legacy single-frame path keeps media as plain binary markers; images unchanged)
  • E2E ✅ — new tests/e2e/media-file-preview.spec.ts: writes a real 1s VP8+Opus webm into the seeded repo, opens it from the explorer, asserts the player mounts and Chromium reaches readyState >= HAVE_METADATA (proves the base64 → Blob → objectURL chain decodes end to end).

  • Manually tested on macOS (headless Electron E2E run). Windows/Linux not manually tested — the change has no platform-specific code paths (mime lookup + DOM media elements).

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Implemented with Claude (Fable 5) via Claude Code, driven and reviewed by @ckdwns9121.

Review

Self-review notes, per the contribution checklist:

  • Cross-platform: no platform branches; file paths go through extname/path.join; <video>/<audio> are Chromium-native on all three OSes. .mov decodability depends on the codec inside the container — undecodable files land in the same error state as broken images.
  • SSH/remote: media previews work over the chunked stream path. Wire compatibility considered both ways: old client + new host → legacy path unchanged, still shows the binary marker; new client + old host → no media mime advertised, graceful fallback to the binary message. No new wire fields or opcodes.
  • Performance: media never enters the git diff/status allowlists, so no diff path buffers video. The base64 → Uint8Array decode is one pass on open (~100–300ms for very large files) and freed on tab close via revokeObjectURL. Lazy MediaViewer chunk keeps it out of the startup bundle.
  • Security: extensions map to a fixed mime allowlist; content is rendered only through Blob object URLs into media elements (no HTML injection surface); size caps bound memory.
  • Backwards compatibility: isImage: true contract kept for media (same as the existing PDF precedent), so no renderer/main version skew issues.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The 100MB media cap applies locally only; the relay path keeps its existing 50MB previewable-binary cap. Files over the cap show the existing "File too large" error. Streaming/seeking beyond the cap would need a custom protocol handler, called out as a follow-up in the issue.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Contributor

X handle: @SDD125232

@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0fcc374c-7e0e-4835-8279-10d2e7329908

📥 Commits

Reviewing files that changed from the base of the PR and between 728cf6b286b9f42abfc28e70838a30bbdda3bed4 and 3ca88ec.

📒 Files selected for processing (10)
  • src/main/ipc/filesystem/filesystem-file-content-inspection.ts
  • src/main/ipc/filesystem/filesystem-read-handlers.ts
  • src/relay/fs-handler-utils.ts
  • src/renderer/src/components/editor/EditorEditFileSurface.tsx
  • src/renderer/src/components/editor/editor-lazy-views.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/ja.json

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds shared audio and video MIME mappings, separate 100 MB media preview limits, and relay classification for media streams. The editor now renders supported media through MediaViewer, which decodes base64 content, displays audio or video controls, handles errors, and revokes object URLs. Tests cover local reads, streaming, component behavior, localization, and end-to-end WebM playback.

Priority: ➖ Normal

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 3ca88

Supported media previews work through local and streaming remote paths, with no established current-head risk requiring changes before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Issue #6751 requests audio previews. The PR also adds video preview behavior for .mp4, .mov, and .webm, including video MIME routing, <video> rendering, video-specific tests, and a WebM E2E te… Move video support to a separately scoped issue, or remove the video-specific MIME entries, rendering path, and tests from this pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 17 files. (5 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding in-app audio and video previews from the file explorer.
Description check ✅ Passed The description follows the repository template and covers the user impact, implementation, rationale, linked issue, visual proof, testing, AI disclosure, review considerations, scope boundaries, and …
Linked Issues check ✅ Passed Issue #6751 requires audio previews in the file explorer for local, SSH, and remote hosts. The PR adds a shared map for .mp3, .wav, .m4a, and .ogg, routes previewable binary media to `MediaVie…
Full details: Out of Scope Changes check

Explanation

Issue #6751 requests audio previews. The PR also adds video preview behavior for .mp4, .mov, and .webm, including video MIME routing, &lt;video&gt; rendering, video-specific tests, and a WebM E2E test. The linked issue does not define video support. These changes are not required to implement audio playback.

Full details: Docstring Coverage

Explanation

Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 17 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/ipc/filesystem.ts (1)

157-158: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Raising the local media preview cap to 100 MB reuses the existing full-buffer base64 IPC transport and a synchronous renderer-side decode. Both sites amplify the same underlying design choice: neither the transport nor the decode path was adapted when the ceiling doubled from the 50 MB image cap.

  • src/main/ipc/filesystem.ts#L157-L158: confirm the base64 IPC message for a 100 MB file (roughly 133 MB as a string) does not cause noticeable delays or memory spikes when it crosses the IPC boundary, or consider streaming large media instead of buffering and base64-encoding the whole file.
  • src/renderer/src/components/editor/MediaViewer.tsx#L14-L28: replace the manual atob() plus per-byte Uint8Array loop with a native decode path, for example fetch(\data:${mimeType};base64,${base64}`).then((response) => response.blob())`, so a 100 MB file does not block the renderer main thread during decode.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eaacb0cb-40bd-4353-98f4-f31e508c3151

📥 Commits

Reviewing files that changed from the base of the PR and between 59892a2 and 47eac3cf0b0d7fbe776600ba674a044ecb5b8f3c.

📒 Files selected for processing (17)
  • src/main/ipc/filesystem.test.ts
  • src/main/ipc/filesystem.ts
  • src/relay/fs-handler-file-read-media.test.ts
  • src/relay/fs-handler-file-read.ts
  • src/relay/fs-handler-stream.test.ts
  • src/relay/fs-handler-utils.ts
  • src/renderer/src/components/editor/EditorContent.tsx
  • src/renderer/src/components/editor/MediaViewer.test.tsx
  • src/renderer/src/components/editor/MediaViewer.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/media-file-extensions.test.ts
  • src/shared/media-file-extensions.ts
  • tests/e2e/media-file-preview.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@ckdwns9121

Copy link
Copy Markdown
Contributor Author

Hi @brennanb2025 — gentle ping when you have a chance!

It looks like the PR Checks and PR test LoC workflows are currently waiting for maintainer approval because this is my first contribution.

Would you mind approving the workflow runs and taking a look at the PR when convenient? All local checks pass, and I’m happy to address any feedback or make follow-up changes.

Thanks!

@kgbvsfbi

Copy link
Copy Markdown

Any chance .ogg could be included in the format list? Ogg Vorbis/Opus is natively decodable by Electron's Chromium, so it should fit the same criterion as the current set — seemingly just one more entry in src/shared/media-file-extensions.ts (.ogg → audio/ogg). It's a common format for sound assets (e.g. game/app sound effects), so it would be great to have it covered by this PR. Happy to open a follow-up instead if you'd rather keep the scope as is.

@ckdwns9121

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion, @kgbvsfbi — this fits the PR's existing native-decoding criterion, so I included it here rather than deferring it.

AS-IS:

  • .ogg files fell through to the binary-file fallback because the shared media MIME map did not advertise them.

TO-BE:

  • Added .ogg → audio/ogg and an explicit Ogg container regression test in commit 7a2e1098f5.
  • Updated the PR description's supported-format and test coverage lists.

Verification:

  • pnpm exec vitest run --config config/vitest.config.ts src/shared/media-file-extensions.test.ts — 4 tests passed
  • pnpm exec oxlint src/shared/media-file-extensions.ts src/shared/media-file-extensions.test.ts — passed
  • pnpm typecheck — passed

@ckdwns9121
ckdwns9121 force-pushed the feat/media-file-preview branch from 7a2e109 to 728cf6b Compare August 26, 2026 08:24
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@ckdwns9121

Copy link
Copy Markdown
Contributor Author

Rebased this PR onto the latest upstream main and resolved the editor conflict without restoring the legacy monolithic EditorContent implementation. Media routing now follows the current editor ownership boundaries in EditorEditFileSurface, EditorConflictReviewSurface, and editor-lazy-views.

I also rewrote the Ogg follow-up commit so both PR commits are attributed to my personal ckdwns9121 noreply identity.

Verification after the rebase:

  • Targeted Vitest suites: 62 passed, 1 skipped
  • Changed-file oxlint: passed
  • pnpm typecheck: passed
  • Electron headless media preview E2E: 1 passed

The PR description has been updated to reference the new routing files.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f04e8d7d-1a38-4051-8e8b-da2867db4a53

📥 Commits

Reviewing files that changed from the base of the PR and between 5e900b1 and 728cf6b286b9f42abfc28e70838a30bbdda3bed4.

📒 Files selected for processing (19)
  • src/main/ipc/filesystem.test.ts
  • src/main/ipc/filesystem.ts
  • src/relay/fs-handler-file-read-media.test.ts
  • src/relay/fs-handler-file-read.ts
  • src/relay/fs-handler-stream.test.ts
  • src/relay/fs-handler-utils.ts
  • src/renderer/src/components/editor/EditorConflictReviewSurface.tsx
  • src/renderer/src/components/editor/EditorEditFileSurface.tsx
  • src/renderer/src/components/editor/MediaViewer.test.tsx
  • src/renderer/src/components/editor/MediaViewer.tsx
  • src/renderer/src/components/editor/editor-lazy-views.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/media-file-extensions.test.ts
  • src/shared/media-file-extensions.ts
  • tests/e2e/media-file-preview.spec.ts
🚧 Files skipped from review as they are similar to previous changes (14)
  • src/relay/fs-handler-file-read.ts
  • src/renderer/src/i18n/locales/zh.json
  • src/relay/fs-handler-utils.ts
  • src/main/ipc/filesystem.test.ts
  • src/shared/media-file-extensions.ts
  • src/renderer/src/i18n/locales/ja.json
  • src/relay/fs-handler-stream.test.ts
  • tests/e2e/media-file-preview.spec.ts
  • src/main/ipc/filesystem.ts
  • src/renderer/src/i18n/locales/es.json
  • src/shared/media-file-extensions.test.ts
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/en.json
  • src/relay/fs-handler-file-read-media.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

ckdwns9121 and others added 2 commits September 18, 2026 13:30
Media files (.mp3/.wav/.m4a/.mp4/.mov/.webm) opened from the file explorer
now render a native in-app player instead of 'Binary file — cannot display',
reusing the existing previewable-binary pipeline images and PDFs already use.

- local IPC advertises media mime types with a dedicated 100MB cap
- SSH relay advertises media only on the chunked stream path so legacy
  single-frame clients keep their small binary markers
- new lazy MediaViewer component with object-URL lifecycle management

Fixes #8344

Co-Authored-By: Claude Fable 5 <[email protected]>
@nwparker

nwparker commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by merged desktop playback #26120 and mobile playback #26148. The desktop implementation uses bounded range streaming rather than transferring the whole file through base64. ChangJun Park, Lirone Levy, dupi, and John Cusack are credited with Co-authored-by trailers in both merge commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Allow previewing audio files (mp3, wav, etc) in the orca file explorer

3 participants