Skip to content

feat: play video and music files in mobile previews - #26148

Merged
nwparker merged 5 commits into
mainfrom
nwparker/mobile-media-preview
Oct 7, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/mobile-media-preview

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Tap a video or music file on mobile to play and seek it inside Orca.

What Changed

The file explorer previously disabled video and music files. Explorer previews and session file tabs now download the file in 384 KB chunks with progress, then show the device's audio or video controls. Native builds cache the bytes on disk and use the existing WebView; the browser and hybrid shell play a temporary Blob. Closing or switching the preview cancels downloads and releases playback and cached bytes.

The mobile shell permits Blob media playback while keeping network media blocked. iOS keeps video inline and requires a user gesture to start playback. An older shell shows an app-update message. Mobile credentials now allow the existing file-metadata operation; older hosts show a desktop-update message. Files larger than 256 MB, interrupted transfers, files changed during download, and unsupported codecs show an error.

Why

This combines the in-app playback direction from #12570 with the bounded download approach from #21839, and shares the desktop format list from #26120. Reusing the existing WebView and authenticated files.stat / files.readChunk operations avoids a new playback dependency, whole-file base64 responses, and new host protocol methods. All four contributors to the media proposals are credited as co-authors.

Linked Issue

Fixes #24859 (mobile support; desktop support is #26120).

Visual Proof

Captured from a freshly rebuilt iOS app on the iPhone 17 Pro / iOS 26.1 Simulator, connected to a real isolated Orca host with a mobile-scoped credential. Three repeated runs asserted MP4 and MP3 play, pause, seeking, unsupported-codec errors, byte-for-byte cache contents, and deletion on close. The MP4 is 1.4 MB and requires four chunk reads.

Before After: explorer
Media unavailable on iOS Media files open on iOS
After: video After: music
Video controls after seeking Music controls after seeking

Recorded third passing simulator run:

orca-ios-media-demo.mp4

Hybrid shell after rebuilding iOS (served build 6b0d0147405b):

Video Music
Inline Blob video controls Blob music controls after seeking

Testing

  • I manually tested these changes locally

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

  • macOS headless Chromium: opened MP4 and MP3 from the explorer and verified decoding, play, and seek.

  • pnpm --dir mobile test src/files: 236 tests passed, including byte-for-byte bounded transfers, malformed and oversized responses, cancellation, changed files, native cache cleanup, and Strict Mode replay.

  • pnpm --dir mobile test src/session: 2,198 tests passed.

  • pnpm test config/scripts/mobile-web-app-render.test.mjs config/scripts/mobile-web-app-media-preview-render.test.mjs: 30 tests passed, including play/seek, stopping playback and revoking the Blob on navigation, old-shell behavior, and native policy parity.

  • Mobile source and test typechecks, changed-code quality, and pnpm run build:mobile-web passed. The verified bundle is 7.97 MB, below its 9 MB budget.

  • iOS hybrid shell: verified MP4 and MP3 decoding, play, pause, and seeking using the real downloaded mobile web bundle and the rebuilt native CSP; unsupported-media errors and navigation away also passed. Fixed the iOS WebView configuration so video stays inline and playback requires a user gesture.

  • Rebuilt the iOS native shell with expo prebuild, pod install, and xcodebuild for the simulator. Fixed an Expo native writer incompatibility with Buffer subclasses found by these emulator runs; plain Uint8Array chunks now write successfully.

  • Host file authorization, SSH chunk reads, RPC allowlist/dispatch, and path-existence tests passed; the real local rewrite regression also passed.

  • Mobile RPC allowlist tests: all five passed. Old-host metadata refusal tests cover both forbidden and method_not_found.

  • Complete mobile web checks: 486 tests in 48 files passed.

  • Android playback, physical-device playback, and a live SSH connection were not exercised locally.

Review

Adversarial review traced file authorization, workspace and SSH routing, malformed and oversized chunks, cancellation during pending reads, Strict Mode replay, cache deletion, Blob revocation, HTML escaping, native navigation limits, and older-host/shell behavior.

Two findings were fixed before merge: the Android CSP test still rejected the newly permitted media-only Blob source, and a same-size rewrite could restore modification time during a multi-chunk transfer. Local file metadata now includes an optional change timestamp, which the downloader compares when supplied. A real filesystem test rewrites a file and restores its modification time; transfer tests reject the changed revision and accept hosts that omit it. Four Android policy JUnit tests passed when compiled with the production CSP and network-blocker constants. No blocking findings remain.

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

  • Rebuilt and verified the iOS shell in the simulator. The hybrid policy and iOS inline-playback change require a new native app build; an older shell reports that an update is required. No new native dependency is introduced.
  • Playback starts after the file finishes downloading. Codecs depend on the device; the format list covers MP4/MOV/M4V/WebM and MP3/WAV/M4A/AAC/Ogg/OGA/FLAC/Opus.
  • Existing host operations retain authorization and SSH/folder-workspace routing. The existing file-stat reply gains an optional local change timestamp; older replies and SSH providers without it retain size/modification-time checks. On older hosts and SSH providers without a change timestamp, a same-size rewrite that restores modification time can still evade detection. No new methods or stream opcodes are added.
  • This covers files opened from worktree/folder explorers and session file tabs. Grant-only terminal artifacts outside the workspace retain their current behavior because the existing protocol does not provide chunk reads for those grants.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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)

Reuse existing chunked file reads, native cache storage, and WebView media controls.

Co-authored-by: ChangJun Park <[email protected]>
Co-authored-by: Lirone Levy <[email protected]>
Co-authored-by: dupi <[email protected]>
Co-authored-by: John Cusack <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The change adds mobile audio and video previews for supported worktree files. It identifies media by file extension and adds media preview states. It downloads file bytes through RPC in validated chunks and stages them in native cache files or web Blob URLs. The preview UI reports download progress and renders platform-specific playback. The shell CSP permits media from Blob URLs. Tests cover file recognition, downloads, preview lifecycle, playback, and CSP behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 3b688

Media previews of SSH-hosted files may rarely play mixed content if the file is rewritten in place during download. This is a bounded gap and should be documented, but it does not block merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 36 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #24859 is closed and completed, so it supplies historical context only. No active directly linked issue remains. No linked-issue coding requirements apply.
Out of Scope Changes check ✅ Passed The changes support mobile media previews, including chunked downloads, playback, cache cleanup, RPC metadata access, security policy, and tests. The whole-PR summary ties the optional local change ti…
Title check ✅ Passed The title clearly and concisely describes the main change: playing video and music files in mobile previews.
Description check ✅ Passed The description covers the required sections, including the user-facing change, rationale, linked issue, visual proof, testing, review, and checklist. It also documents platform limitations and compat…
Full details: Docstring Coverage

Explanation

Docstring coverage is 3.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 36 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c38de7a-dc12-4b6b-8236-91748941b12c
📥 Commits

Reviewing files that changed from the base of the PR and between 25e0a29 and 47783e5.

📒 Files selected for processing (31)
  • config/scripts/mobile-web-app-media-preview-render.test.mjs
  • config/scripts/mobile-web-app-render.test.mjs
  • mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellCsp.kt
  • mobile/modules/orca-mobile-web-shell/ios/MobileWebShellCsp.swift
  • mobile/src/files/MobileFileMediaPreview.test.tsx
  • mobile/src/files/MobileFileMediaPreview.tsx
  • mobile/src/files/MobileFilePreviewBody.tsx
  • mobile/src/files/MobileFilePreviewScreen.tsx
  • mobile/src/files/MobileMediaPlayback.tsx
  • mobile/src/files/MobileMediaPlayback.web.tsx
  • mobile/src/files/file-tree.ts
  • mobile/src/files/mobile-file-explorer-row.tsx
  • mobile/src/files/mobile-file-media-download.test.ts
  • mobile/src/files/mobile-file-media-download.ts
  • mobile/src/files/mobile-file-media.ts
  • mobile/src/files/mobile-file-preview-editability.ts
  • mobile/src/files/mobile-file-preview-navigation.test.ts
  • mobile/src/files/mobile-file-preview-navigation.ts
  • mobile/src/files/mobile-file-preview-request.test.ts
  • mobile/src/files/mobile-file-preview-request.ts
  • mobile/src/files/mobile-file-preview-response.ts
  • mobile/src/files/mobile-file-preview-retry.test.tsx
  • mobile/src/files/mobile-file-tab-doc.test.ts
  • mobile/src/files/mobile-file-tab-doc.ts
  • mobile/src/files/mobile-media-preview-cache.test.ts
  • mobile/src/files/mobile-media-preview-cache.ts
  • mobile/src/files/mobile-media-preview-cache.web.ts
  • mobile/src/files/mobile-media-preview-document.ts
  • mobile/src/session/MobileSessionActiveContent.tsx
  • mobile/src/session/MobileSessionFileReader.tsx
  • mobile/src/session/mobile-session-route-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

🟡 Minor · Compare a write-sensitive revision after the chunk reads. · mobile-file-media-download.ts:89-100

mobile/src/files/mobile-file-media-download.ts:89-100
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Compare a write-sensitive revision after the chunk reads.

For a multi-chunk local file, an in-place rewrite between reads can keep the size unchanged and restore the original mtime. The next chunk can then contain new bytes, while the final check passes and sink.finish() returns mixed bytes. Include a write-sensitive token, such as local ctimeMs, in the stat replies and reject a changed token.

🟡 Minor · Update the Android CSP expectation for media-src blob:. · MobileWebShellCsp.kt:47

mobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellCsp.kt:47
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Update the Android CSP expectation for media-src blob:.

Expo SDK 55 discovers local modules from mobile/modules by default. This module declares Android support in expo-module.config.json, so its Android unit test is part of the generated project. The test rejects blob:, but the changed CSP adds media-src blob:. A generated Android module unit-test invocation can therefore fail.

Suggested fix
-    assertFalse(MOBILE_WEB_SHELL_CSP.contains("blob:"))
+    assertEquals(
+      listOf("media-src blob:"),
+      directives.filter { it.contains("blob:") }
+    )

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7538f449-c605-4e2f-9fda-71194d7dfc5a
📥 Commits

Reviewing files that changed from the base of the PR and between 47783e5 and c85f951.

📒 Files selected for processing (3)
  • mobile/src/files/mobile-file-media-download.test.ts
  • mobile/src/files/mobile-file-media-download.ts
  • mobile/web-entry/web-overrides.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • mobile/src/files/mobile-file-media-download.test.ts
  • mobile/src/files/mobile-file-media-download.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@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)
mobile/src/files/mobile-file-media-download.ts (1)

23-24: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Add a change timestamp check for SSH-hosted files.

statRuntimeFile returns ctime only for local files. The SSH provider branch returns only size and mtime. For SSH files, stat.ctime is undefined, so the check on Line 108 is skipped. A same-size rewrite that restores mtime between chunks is then not detected. The cached media can contain mixed content from two file versions.

This is a limit of the SSH path, not a regression. Document it in the code. Alternatively, surface it in the PR notes as a known gap.

Also applies to: 104-109


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a7ba79e3-b0b7-4688-b393-7f7ba80a9b69
📥 Commits

Reviewing files that changed from the base of the PR and between 19aca2f and 3b688bb.

📒 Files selected for processing (7)
  • mobile/modules/orca-mobile-web-shell/android/src/test/java/expo/modules/orcamobilewebshell/MobileWebShellCspTest.kt
  • mobile/modules/orca-mobile-web-shell/ios/MobileWebShellView.swift
  • mobile/src/files/mobile-file-media-download.test.ts
  • mobile/src/files/mobile-file-media-download.ts
  • mobile/web-entry/web-overrides.json
  • src/main/runtime/orca-runtime-files-mobile-explorer-reads.test.ts
  • src/main/runtime/runtime-file-commands-search-runtime-files.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/web-entry/web-overrides.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

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] video file preview (watching .mp4/.mov files inside Orca).

1 participant