Repository navigation
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⛔ Files ignored due to path filters (1)
⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughAdds mobile media handoff support for PDF, video, and audio files. The feature reads files in 512 KB RPC chunks, validates responses, enforces a 128 MB limit, caches data through Expo filesystem, and shares the cached URI with the operating system. The preview screen routes supported worktree media to the new handoff component. Tests cover download, cache, sharing, refusal, size-limit, and disconnected states. Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the user-facing change, implementation, rationale, testing, and compatibility considerations. However, the mandatory Linked Issue field is empty, the Visual Proof section marks an interaction change as N/A, and manual device testing remains pending. Resolution Add the linked issue number after “Fixes #”. Provide valid before-and-after screenshots or a video for the mobile UI interaction, or explain why the required visual proof cannot be provided. Complete and report the manual device test before merging. 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 811df770-fda5-45ac-b09d-b08236c483ab
⛔ Files ignored due to path filters (1)
mobile/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
mobile/package.jsonmobile/src/files/MobileFileMediaHandoff.test.tsxmobile/src/files/MobileFileMediaHandoff.tsxmobile/src/files/MobileFilePreviewScreen.tsxmobile/src/files/file-preview-reply-schema.tsmobile/src/files/mobile-file-media-handoff-device.tsmobile/src/files/mobile-file-media-handoff.test.tsmobile/src/files/mobile-file-media-handoff.tsmobile/src/files/mobile-file-preview-operations.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| if (chunk.bytesRead === 0) { | ||
| break |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n "files\.readChunk|FileReadChunk|bytesRead|contentBase64" mobile cloud packages . --glob '!**/node_modules/**'
sed -n '51,94p' mobile/src/files/mobile-file-media-handoff.tsRepository: stablyai/orca
Length of output: 45543
🏁 Script executed:
set -eu
printf '%s\n' '--- files RPC method ---'
cat -n src/main/runtime/rpc/methods/files.ts | sed -n '1,145p'
printf '%s\n' '--- host implementation ---'
cat -n src/main/runtime/runtime-file-commands-read-file-explorer-preview.ts | sed -n '130,195p'
printf '%s\n' '--- shared types ---'
rg -n -A12 -B8 "RuntimeFileReadChunkResult|FileReadChunk" src mobile packages shared . --glob '!**/node_modules/**' --glob '!**/*.map' | head -240
printf '%s\n' '--- provider contract and range reader ---'
cat -n src/main/providers/filesystem-provider-contract.ts | sed -n '20,65p'
cat -n src/main/runtime/ssh-file-explorer-chunk-read.ts | sed -n '1,65p'
printf '%s\n' '--- relevant tests ---'
cat -n src/main/runtime/rpc/methods/files.test.ts | sed -n '390,455p'
rg -n -A12 -B12 "downloadMobileFileMedia|bytesRead: 0|eof: false" mobile/src --glob '*test*' --glob '*.ts' --glob '*.tsx' | head -240Repository: stablyai/orca
Length of output: 45541
🏁 Script executed:
set -eu
printf '%s\n' '--- exact local host branch ---'
cat -n src/main/runtime/runtime-file-commands-read-file-explorer-preview.ts | sed -n '147,190p'
printf '%s\n' '--- exact RPC binding ---'
cat -n src/main/runtime/rpc/methods/files.ts | sed -n '100,125p'
printf '%s\n' '--- provider contract continuation ---'
cat -n src/main/providers/filesystem-provider-contract.ts | sed -n '53,82p'
printf '%s\n' '--- range reader implementations ---'
rg -n -A55 -B8 "async readFileRange|readFileRange\\s*[:=]|readFileRange\\(" src/main --glob '*.ts' --glob '!**/*.test.ts' | head -320
printf '%s\n' '--- mobile response interpretation and test helper ---'
cat -n mobile/src/files/mobile-file-media-handoff.ts | sed -n '1,95p'
rg -n -A35 -B15 "fileMediaChunkRead|interpret\\(" mobile/src/files mobile/src/transport --glob '*.ts' --glob '*.tsx' | head -260Repository: stablyai/orca
Length of output: 40109
Reject a zero-byte chunk unless eof is true.
files.readChunk can return { bytesRead: 0, eof: false } when the file shrinks after the host records its size. The current branch treats that response as successful completion, so the app can share a truncated file.
Require eof or throw an error so the catch block discards the partial file.
Proposed fix
if (chunk.bytesRead === 0) {
- break
+ if (chunk.eof) {
+ break
+ }
+ throw new Error('Host returned an incomplete file chunk')
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (chunk.bytesRead === 0) { | |
| break | |
| if (chunk.bytesRead === 0) { | |
| if (chunk.eof) { | |
| break | |
| } | |
| throw new Error('Host returned an incomplete file chunk') |
| try { | ||
| const sink = mediaHandoffSinkFor(relativePath) | ||
| await downloadMobileFileMedia(client, { worktreeId, relativePath }, sink, setProgressBytes) | ||
| await Sharing.shareAsync(sink.uri, { mimeType, dialogTitle: `Open ${title}` }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,110p' mobile/src/files/MobileFileMediaHandoff.tsx
sed -n '130,320p' mobile/src/files/MobileFilePreviewScreen.tsx
sed -n '1,80p' mobile/src/files/mobile-file-media-handoff-device.ts
rg -n "MobileFilePreviewScreen|MobileFileMediaHandoff" mobile/src --glob '!**/*.test.*'Repository: stablyai/orca
Length of output: 10770
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- media handoff definitions and callers ---'
rg -n -A80 -B20 "downloadMobileFileMedia|type MobileFileMediaSink|interface MobileFileMediaSink|mediaHandoffSinkFor" mobile/src
printf '%s\n' '--- preview screen beginning and route identity logic ---'
sed -n '1,180p' mobile/src/files/MobileFilePreviewScreen.tsx
printf '%s\n' '--- preview route registration and navigation calls ---'
rg -n -A12 -B12 "MobileFilePreviewScreen|FilePreview|preview" mobile/src --glob '!**/*.test.*' | head -n 260
printf '%s\n' '--- relevant tests ---'
rg -n -A30 -B20 "MobileFileMediaHandoff|mediaHandoff|MobileFilePreviewScreen|shareAsync" mobile --glob '*test*' --glob '*spec*' || trueRepository: stablyai/orca
Length of output: 45540
🏁 Script executed:
set -eu
printf '%s\n' '--- media handoff definitions and callers ---'
rg -n -A80 -B20 "downloadMobileFileMedia|type MobileFileMediaSink|interface MobileFileMediaSink|mediaHandoffSinkFor" mobile/src
printf '%s\n' '--- preview screen beginning and route identity logic ---'
sed -n '1,180p' mobile/src/files/MobileFilePreviewScreen.tsx
printf '%s\n' '--- preview route registration and navigation calls ---'
rg -n -A12 -B12 "MobileFilePreviewScreen|FilePreview|preview" mobile/src --glob '!**/*.test.*' | head -n 260
printf '%s\n' '--- relevant tests ---'
rg -n -A30 -B20 "MobileFileMediaHandoff|mediaHandoff|MobileFilePreviewScreen|shareAsync" mobile --glob '*test*' --glob '*spec*' || trueRepository: stablyai/orca
Length of output: 45542
🏁 Script executed:
set -eu
rg -n -A100 -B20 "downloadMobileFileMedia|MobileFileMediaSink|mediaHandoffSinkFor" mobile/src
sed -n '1,180p' mobile/src/files/MobileFilePreviewScreen.tsx
rg -n -A15 -B15 "MobileFilePreviewScreen|FilePreview" mobile --glob '!**/*.test.*' | head -n 300
rg -n -A40 -B20 "MobileFileMediaHandoff|mediaHandoff|shareAsync" mobile --glob '*test*' --glob '*spec*' || trueRepository: stablyai/orca
Length of output: 45535
🏁 Script executed:
set -eu
printf '%s\n' '--- downloader ---'
sed -n '1,180p' mobile/src/files/mobile-file-media-handoff.ts
printf '%s\n' '--- sink ---'
sed -n '1,120p' mobile/src/files/mobile-file-media-handoff-device.ts
printf '%s\n' '--- route key and shell rendering ---'
sed -n '43,95p' 'mobile/app/h/[hostId]/files/preview/[worktreeId].tsx'
rg -n -A35 -B15 "function shellScreenRouteKey|export.*shellScreenRouteKey|shellScreenRouteKey" mobile/src/mobile-web-shell
printf '%s\n' '--- handoff tests after normal flow ---'
sed -n '130,360p' mobile/src/files/MobileFileMediaHandoff.test.tsxRepository: stablyai/orca
Length of output: 15724
Invalidate stale handoff operations before sharing.
If Back unmounts the preview or the route changes while downloadMobileFileMedia awaits its RPC reads, the old open closure still reaches Sharing.shareAsync with the old sink and metadata. The route key remounts the screen, but it does not cancel the old promise.
Track an operation token, invalidate it on unmount and identity changes, and check it after the download before sharing. Do not discard a stale sink until each operation has a unique cache URI. The current sink derives its URI from only the basename, so open() and discard() can delete another concurrent operation's file.
There was a problem hiding this comment.
Important
Two things to look at before merge: the handoff is reachable on the mobile web page but cannot work there, and the download loop reads a zero-byte pre-EOF reply as a successful EOF.
Reviewed changes
- Media handoff for the mobile preview — worktree PDFs and phone-openable media skip
loadPreviewand render an Open button that downloads the file and hands the cached copy toexpo-sharing, mirroring the desktop's "open externally". - Chunked download + sink seam —
downloadMobileFileMediapages 512 KiBfiles.readChunkslices through aMobileFileMediaSink, caps at 128 MiB, and surfaces host refusals; the expo-file-system device half is split out so the loop stays testable. - New RPC op + reply schema —
fileMediaChunkRead(files.readChunk,success-result-or-skip) with a requiredcontentBase64/bytesRead/eofschema. - Tests — unit coverage of MIME mapping, chunk assembly, refusal, cap, and code fallback; component coverage of open→download→share, failed read, disconnected, and cache naming.
ℹ️ Nitpicks
mediaHandoffCacheNamekeys the cache file on the basename alone, soa/report.pdfandb/report.pdfshareorca-media-handoff-report.pdf. Sequential opens overwrite each other's bytes; a short hash of the full relative path would make the name unique per file.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| if (chunk.bytesRead === 0) { | ||
| break | ||
| } |
There was a problem hiding this comment.
The loop breaks on bytesRead === 0 before it ever consults eof, so a zero-byte reply that is not EOF is treated as a completed transfer. The host can emit { bytesRead: 0, eof: false } when a file shrinks between its stat and the read — src/main/runtime/ssh-file-explorer-chunk-read.ts:40-45 documents exactly that path — and the desktop download loop guards the same reply as a stall (src/renderer/src/runtime/runtime-file-read-client.ts:150-155). Here it silently hands a truncated prefix to the share sheet as if it were the whole file.
Technical details
# A zero-byte pre-EOF reply must not be read as EOF
## Affected sites
- `mobile/src/files/mobile-file-media-handoff.ts:75-77` — `if (chunk.bytesRead === 0) break` runs before the `eof` check at `:85`.
- `mobile/src/files/mobile-file-media-handoff.test.ts:95-104` — "keeps an empty file byte-exact" uses `{ contentBase64: '', bytesRead: 0, eof: false }`, which is the stall fixture the browser suite uses to assert a throw; the real host's empty-file reply is `{ '', 0, eof: true }` (`src/main/runtime/runtime-file-commands-read-file-explorer-preview.ts:173-177`).
## Required outcome
- Break only on `eof`; treat `bytesRead <= 0 && !eof` as a stalled download, `discard()` the partial file, and surface it as an error.
- Change the empty-file fixture to `eof: true` so the test distinguishes "empty file" from "stall".
## Suggested approach
- Append, advance `offset`, then `if (chunk.eof) break`, then throw on a zero-byte non-EOF read — the desktop loop's order.
## Open questions for the human
- A real 0-byte PDF/media still writes no cache file (the sink only creates it in `appendBase64`), so `Sharing.shareAsync` is handed a URI that does not exist. Worth an explicit branch?| try { | ||
| const sink = mediaHandoffSinkFor(relativePath) | ||
| await downloadMobileFileMedia(client, { worktreeId, relativePath }, sink, setProgressBytes) | ||
| await Sharing.shareAsync(sink.uri, { mimeType, dialogTitle: `Open ${title}` }) |
There was a problem hiding this comment.
The file-preview route is also served on the mobile web page: mobile/app/h/[hostId]/files/preview/[worktreeId].web.tsx renders this same MobileFilePreviewScreen, and mediaHandoffMimeFor is platform-independent, so a worktree PDF/media renders this Open button on the page too. On web, mediaHandoffSinkFor throws (Paths.cache on expo-file-system's web stub has no validatePath) and Sharing.shareAsync needs navigator.share, so the tap surfaces a raw internal error string. There is no .web seam for the handoff, and no existing census catches native imports in this closure.
Technical details
# The handoff has no web seam
## Affected sites
- `mobile/src/files/MobileFileMediaHandoff.tsx:4,44` — imports `expo-sharing` and calls `shareAsync`; no `.web` sibling for the component or the device sink.
- `mobile/src/files/mobile-file-media-handoff-device.ts:15` — `new File(Paths.cache, ...)`; on web `Paths.cache` evaluates `new Directory('')`, whose constructor calls the native-only `validatePath()` (`[email protected]/src/ExpoFileSystem.web.ts` is a stub class).
- `mobile/src/files/MobileFilePreviewScreen.tsx:159-160` — the media branch is chosen with no platform check.
## Required outcome
- The page must not offer a control it cannot serve, or must serve it through the shell.
## Suggested approach
- Gate the branch the way `mobile/src/files/use-mobile-file-preview-back.ts:79` gates web (`Platform.OS !== 'web'`), or add a `.web` device sink plus a web share path so the page keeps its existing host-refusal copy.There was a problem hiding this comment.
✅ No new issues found in the follow-up commit.
Reviewed changes
- Made PDF/media rows tappable in the file explorer —
canPreviewMobileFileRownow also admitsmediaHandoffMimeFor(...) !== null, so the row gate matches the preview screen's handoff branch (explorer navigation is worktree-sourced, so the tap lands on the handoff). - Decoupled the row's image icon from previewability —
isImageis nowkind === 'binary' && classifyMobileArtifact(path) === 'image', so a PDF/media row no longer shows the image icon it inherited from the oldpreviewable-based derivation. - Extended the row-predicate test — text, raster image,
.mp4,.mp3, and a non-ASCII.pdfare asserted openable;.zipstays disabled.
The two [!IMPORTANT] items from the previous review — zero-byte pre-EOF handling in the download loop and the mobile web page offering a handoff it cannot serve — are untouched by this commit and remain open.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Markdown, HTML and images preview in the app, but the phone has no PDF or video renderer and the host refuses those binaries, so tapping a .pdf or .mp4 in the file explorer showed "Binary preview unavailable". The desktop answers the same file with a choice of built-in or external viewer. This adds the mobile counterpart of "open externally": the preview screen detects the OS-openable documents and media (pdf, mp4/m4v/mov, mp3/m4a/wav), downloads the file from the paired host in host-capped 512KB files.readChunk slices into the app cache — each slice appended as base64, so SSH-hosted files work over the same path — and hands the cached file to the system share sheet with its MIME type, which offers the device's viewer. A 128MB cap keeps the handoff responsive, a failed or oversized download discards the partial file and shows the host's refusal, and terminal artifacts (absolute-path grants) keep the existing refusal. files.readChunk is already mobile-allowlisted; no host change. Co-Authored-By: Claude Code <[email protected]>
The OS handoff shipped the preview screen but the file explorer's row gate still classified PDF/media binaries as unavailable, so the rows stayed disabled and the handoff screen was unreachable. The gate now admits the handoff extensions, and the row's image-icon derivation no longer leans on previewability (a PDF row would have shown the image icon). Co-Authored-By: Claude Code <[email protected]>
0105a91 to
029e241
Compare
|
Closing this competing media proposal after merging desktop playback #26120 and mobile playback #26148. PDF opening and external-app/system-share-sheet handoff are distinct from the merged in-app player and remain tracked in #25871 with PR #25882; they are not claimed as implemented here. ChangJun Park, Lirone Levy, dupi, and John Cusack are credited with Co-authored-by trailers in both merge commits. |

ELI5
On the phone app, tapping a PDF or video in a repository's file list used to just say "Binary preview unavailable". Now a button downloads the file from the paired computer and offers it to whatever app on the phone opens that kind of file.
What Changed
Before: the mobile file preview renders text, markdown, HTML and images itself. The host deliberately refuses to send other binaries to mobile clients (
binary_file), so a.pdfor.mp4— files the phone has no in-app renderer for anyway — dead-ended in an error.After: the preview screen recognizes the documents and media Android/iOS themselves can open (pdf; mp4/m4v/mov; mp3/m4a/wav), skips the preview pipeline, and renders an Open button instead. Pressing it downloads the file from the paired host in 512KB
files.readChunkslices (the host's per-request cap; each slice is appended to the cache file as base64), shows download progress, and then hands the cached file to the system share sheet with the right MIME type — the mobile counterpart of the desktop's "open in external browser/viewer". Any app registered for that type opens it.Mechanism, all mobile-side (no host change;
files.readChunkis already mobile-allowlisted and already serves SSH-hosted worktrees):mobile-file-media-handoff.ts— MIME map, chunk loop over a sink seam, 128MB cap, refusal surfacing.mobile-file-media-handoff-device.ts— the expo-file-system sink (the only module importing it, mirroring the native-media device split).MobileFileMediaHandoff.tsx— Open button / progress / error-retry UI, reusing the preview screen's tokens.loadPreviewand renders the handoff body.Terminal artifacts (absolute-path grants) keep the existing refusal — only worktree-relative paths hand off.
Why
No PDF/video renderer is bundled in the mobile app, and adding one is a large dependency for a file-viewing side feature. Every phone already ships viewers for these types; the share-sheet handoff reaches them with a few hundred lines over an RPC the host already exposes. Chunked
files.readChunkkeeps each reply far under the mobile JSON budget and works identically over SSH hosts, where the whole file is not locally readable. The alternative — a host-side "read any binary for mobile" flag — would widen the mobile attack surface for every file type just to serve a handful.Linked Issue
Fixes #
Visual Proof
N/A — Android device UI (share sheet interaction); captured during personal-build E2E. The rendered states (Open button, progress, error+retry) are covered by component tests below.
Testing
New
mobile-file-media-handoff.test.ts: MIME mapping, multi-chunk assembly with offset/length params, empty file, refusal copy + partial-download discard, code fallback, over-cap refusal.New
MobileFileMediaHandoff.test.tsx: open→download→share with MIME and dialog title; failed read keeps the Open button and shows the host's message; disconnected waits instead of offering an Open it cannot serve; cache naming/sanitization; stale-copy overwrite and append-mode writes.Existing preview suites re-run green;
tsc, tests-typecheck ratchet, and oxlint pass on this branch.I manually tested these changes locally (device E2E pending a personal APK build; will report)
Automated tests added/updated, or explained why not below
AI Disclosure
Claude Code (Anthropic) implemented this change under the author's direction; the author reviewed and tested it.
Review
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
files.readChunkmethod and reply shape; older hosts already serving it behave identically.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code