Repository navigation
feat: play video and music files in mobile previews - #26148
Conversation
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]>
📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8c38de7a-dc12-4b6b-8236-91748941b12c
📒 Files selected for processing (31)
config/scripts/mobile-web-app-media-preview-render.test.mjsconfig/scripts/mobile-web-app-render.test.mjsmobile/modules/orca-mobile-web-shell/android/src/main/java/expo/modules/orcamobilewebshell/MobileWebShellCsp.ktmobile/modules/orca-mobile-web-shell/ios/MobileWebShellCsp.swiftmobile/src/files/MobileFileMediaPreview.test.tsxmobile/src/files/MobileFileMediaPreview.tsxmobile/src/files/MobileFilePreviewBody.tsxmobile/src/files/MobileFilePreviewScreen.tsxmobile/src/files/MobileMediaPlayback.tsxmobile/src/files/MobileMediaPlayback.web.tsxmobile/src/files/file-tree.tsmobile/src/files/mobile-file-explorer-row.tsxmobile/src/files/mobile-file-media-download.test.tsmobile/src/files/mobile-file-media-download.tsmobile/src/files/mobile-file-media.tsmobile/src/files/mobile-file-preview-editability.tsmobile/src/files/mobile-file-preview-navigation.test.tsmobile/src/files/mobile-file-preview-navigation.tsmobile/src/files/mobile-file-preview-request.test.tsmobile/src/files/mobile-file-preview-request.tsmobile/src/files/mobile-file-preview-response.tsmobile/src/files/mobile-file-preview-retry.test.tsxmobile/src/files/mobile-file-tab-doc.test.tsmobile/src/files/mobile-file-tab-doc.tsmobile/src/files/mobile-media-preview-cache.test.tsmobile/src/files/mobile-media-preview-cache.tsmobile/src/files/mobile-media-preview-cache.web.tsmobile/src/files/mobile-media-preview-document.tsmobile/src/session/MobileSessionActiveContent.tsxmobile/src/session/MobileSessionFileReader.tsxmobile/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.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 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 winCompare 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 andsink.finish()returns mixed bytes. Include a write-sensitive token, such as localctimeMs, 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 winUpdate the Android CSP expectation for
media-src blob:.Expo SDK 55 discovers local modules from
mobile/modulesby default. This module declares Android support inexpo-module.config.json, so its Android unit test is part of the generated project. The test rejectsblob:, but the changed CSP addsmedia-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
📒 Files selected for processing (3)
mobile/src/files/mobile-file-media-download.test.tsmobile/src/files/mobile-file-media-download.tsmobile/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.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/files/mobile-file-media-download.ts (1)
23-24: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueAdd a change timestamp check for SSH-hosted files.
statRuntimeFilereturnsctimeonly for local files. The SSH provider branch returns onlysizeandmtime. For SSH files,stat.ctimeisundefined, so the check on Line 108 is skipped. A same-size rewrite that restoresmtimebetween 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
📒 Files selected for processing (7)
mobile/modules/orca-mobile-web-shell/android/src/test/java/expo/modules/orcamobilewebshell/MobileWebShellCspTest.ktmobile/modules/orca-mobile-web-shell/ios/MobileWebShellView.swiftmobile/src/files/mobile-file-media-download.test.tsmobile/src/files/mobile-file-media-download.tsmobile/web-entry/web-overrides.jsonsrc/main/runtime/orca-runtime-files-mobile-explorer-reads.test.tssrc/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.
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.readChunkoperations 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.
Recorded third passing simulator run:
orca-ios-media-demo.mp4
Hybrid shell after rebuilding iOS (served build
6b0d0147405b):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-webpassed. 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, andxcodebuildfor 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
forbiddenandmethod_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
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)