Repository navigation
Fix Remote Host downloads and agent status parity - #6436
Conversation
Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThe PR adds chunked runtime file download support across the main process, preload bridge, renderer runtime client, and file explorer, with new IPC handlers, runtime chunk-read RPCs, and related tests. It also updates terminal binary streaming to carry sequence metadata through snapshot buffering and output replay. Separately, it adds Pi-compatible synthetic title parsing, detection, and e2e coverage for OMP and Pi titles. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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: 4
🧹 Nitpick comments (3)
src/shared/agent-detection.ts (1)
326-329: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short "Why" comment for the Pi-compatible ordering.
This file documents nearly every ordering decision with a
Why:comment, but the two new Pi-compatible branches (here and at Lines 428-431) don't explain why they must run beforeisPiAgentTitle/ the generic braille (isClaudeAgent) heuristic — i.e. that⠋ OMP/⠋ Piworking titles carry a braille spinner that would otherwise be claimed by Claude. A one-liner protects the ordering from future reshuffles.As per coding guidelines: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines."
Suggested comment
+ // Why: Pi/OMP synthetic titles ("⠋ Pi", "OMP ready", "Pi - action required") + // must resolve here before isPiAgentTitle and the generic braille heuristic, + // which would otherwise claim the spinner-prefixed working frames. const piCompatibleSyntheticAgentLabel = getPiCompatibleSyntheticAgentLabel(title)Source: Coding guidelines
src/main/runtime/rpc/terminal-multiplex.test.ts (1)
1108-1204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding a partial-overlap case.
These two tests cover the "no snapshot seq → keep whole" and "snapshot fully covers → drop" branches, but the partial-overlap slice path in
getOutputAfterSnapshotSeq(terminal.ts:340-344) — wherechunkStartSeq < snapshotSeq < chunk.meta.seq— is untested. That is the branch most prone to off-by-one/misalignment, especially given the byte/char concern raised on the helper. A case that buffers a chunk whose start precedes the snapshot seq and asserts only the uncovered tail is replayed would harden this.src/main/runtime/orca-runtime-files.ts (1)
481-484: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueConsider rejecting directories on the remote path for parity.
The local branch (Lines 497-499) throws
'Cannot download a directory', but the SSH branch passes a directory straight toprovider.readFile, which will surface a less actionable provider error. Aprovider.statdirectory check here would keep behavior consistent across local and remote hosts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e9caf0e9-f0b5-4fc9-9f81-e9d43424dfce
📒 Files selected for processing (25)
src/main/ipc/filesystem.test.tssrc/main/ipc/filesystem.tssrc/main/runtime/orca-runtime-files.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/files.test.tssrc/main/runtime/rpc/methods/files.tssrc/main/runtime/rpc/methods/terminal.tssrc/main/runtime/rpc/terminal-multiplex.test.tssrc/main/runtime/runtime-rpc.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/right-sidebar/FileExplorer.test.tsxsrc/renderer/src/components/right-sidebar/FileExplorer.tsxsrc/renderer/src/components/right-sidebar/FileExplorerRow.tsxsrc/renderer/src/components/right-sidebar/FileExplorerVirtualRows.tsxsrc/renderer/src/runtime/runtime-file-client.test.tssrc/renderer/src/runtime/runtime-file-client.tssrc/renderer/src/web/web-preload-api.tssrc/shared/agent-detection.test.tssrc/shared/agent-detection.tssrc/shared/pi-compatible-synthetic-title.tssrc/shared/runtime-types.tssrc/shared/synthetic-agent-title.test.tssrc/shared/synthetic-agent-title.tstests/e2e/ssh-pi-compatible-agent-title.spec.ts
| if (target.connectionId) { | ||
| if (!provider) { | ||
| throw new Error(SSH_FILESYSTEM_PROVIDER_UNAVAILABLE_MESSAGE) | ||
| } | ||
| const result = await provider.readFile(target.path) | ||
| const content = Buffer.from(result.content, result.isBinary ? 'base64' : 'utf8') | ||
| const chunk = content.subarray(offset, offset + length) | ||
| return { | ||
| contentBase64: chunk.toString('base64'), | ||
| bytesRead: chunk.byteLength, | ||
| eof: offset + chunk.byteLength >= content.byteLength | ||
| } | ||
| } |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether the SSH filesystem provider exposes a ranged/offset read API.
ast-grep --lang typescript -p 'interface IFilesystemProvider { $$$ }' $(fd -t f filesystem) 2>/dev/null
rg -nP --type=ts 'readFile(Chunk|Range|Partial)?\s*\(|readFileRange|read\s*\(.*offset' -g '* filesystem*' -g '*ssh*' -C2Repository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
# Find provider interface and SSH implementation files
fd -t f '.*filesystem.*' -t f '.*provider.*' --type f | grep -E '\.(ts|tsx)?$' | head -20
fd -t f '.*ssh.*' --type f | grep -E '\.(ts|tsx)?$' | head -20Repository: stablyai/orca
Length of output: 1071
🏁 Script executed:
#!/bin/bash
# Inspect the SSH filesystem provider interface and implementation
cat -n src/main/providers/ssh-filesystem-provider.ts | head -100
ast-grep outline src/main/providers/ssh-filesystem-provider.ts --view expandedRepository: stablyai/orca
Length of output: 6708
🏁 Script executed:
#!/bin/bash
# Examine the readFile method implementation and check for any range/offset variants
sed -n '120,141p' src/main/providers/ssh-filesystem-provider.ts
# Check for other read methods that might support ranges
rg -A 10 'async read' src/main/providers/ssh-filesystem-provider.ts | head -50Repository: stablyai/orca
Length of output: 1765
🏁 Script executed:
#!/bin/bash
# Check IFilesystemProvider interface definition to see all available methods
find . -name 'types.ts' -path '*/providers/*' | head -1 | xargs cat -n
# Also search for any existing range/offset read implementations across the codebase
rg 'readFile.*\{.*offset|readFileRange|read.*offset.*length' -t ts | head -20Repository: stablyai/orca
Length of output: 13916
Remote chunk read re-fetches the entire file on every call (O(n²) transfer)
For SSH worktrees, readFileExplorerChunk invokes provider.readFile(target.path), which fetches the full remote file, then slices the requested range in-memory. The renderer's chunked download logic calls this once per chunk (up to 512 KiB), causing the entire file to be transferred over the relay for each chunk. Total traffic and latency become quadratic in file size, defeating the purpose of chunked downloads.
The IFilesystemProvider interface does not expose a ranged-read API (no readFileRange or offset-based method). Therefore, either:
- Read the file once into a temporary local buffer or disk cache and serve subsequent chunks from that cache, or
- Extend the provider interface and SSH relay to support offset/length reads (preferred for scalability).
Additionally, the SSH branch does not explicitly reject directory paths like the local path does; add a guard to fail fast with a clear message if target.path is a directory.
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime-files.ts (1)
485-489: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why SSH chunk reads are rejected here.
This branch encodes a non-obvious constraint from the download work: falling back to
provider.readFile()per chunk is intentionally avoided. A shortWhy:comment here would make that explicit and reduce the chance of reintroducing the expensive fallback later.Suggested comment
const fileStat = await provider.stat(target.path) if (fileStat.type === 'directory') { throw new Error('Cannot download a directory') } + // Why: SSH providers do not support ranged reads here, and falling back + // to full-file reads per chunk makes large downloads pathologically slow. throw new Error('SSH runtime chunked download is unavailable; use the SSH download path')As per coding guidelines,
**/*.{ts,tsx,js,jsx}: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6a250ec8-e765-4b59-bdef-a185328cab4a
📒 Files selected for processing (6)
src/main/ipc/filesystem.test.tssrc/main/ipc/filesystem.tssrc/main/runtime/orca-runtime-files.tssrc/main/runtime/rpc/terminal-multiplex.test.tssrc/renderer/src/components/right-sidebar/FileExplorerRow.tsxsrc/shared/agent-detection.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/ipc/filesystem.test.ts
- src/main/ipc/filesystem.ts
- src/shared/agent-detection.ts
- src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
* Fix remote host downloads and agent status parity Co-authored-by: Orca <[email protected]> * Address remote download review comments Co-authored-by: Orca <[email protected]> * Avoid inefficient SSH chunk fallback Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
Summary
Items Addressed
This PR addresses these items from issue #6364, but intentionally does not close the issue because the thread now tracks additional follow-up work:
Validation
pnpm run typecheckpassed. Note: local Node 26 produced the repo Node 24 engine warning.pnpm run lintpassed. Note: local Node 26 produced the repo Node 24 engine warning.git diff --check origin/main...HEADpassed.src/renderer/src/runtime/runtime-file-client.test.ts,src/main/runtime/rpc/methods/files.test.ts,src/main/ipc/filesystem.test.ts,src/renderer/src/components/right-sidebar/FileExplorer.test.tsx,src/main/runtime/rpc/terminal-multiplex.test.ts,src/shared/agent-detection.test.ts,src/shared/synthetic-agent-title.test.ts(226 tests).pnpm build:relaypassed for linux/darwin/win x64/arm64 relay bundles.ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/ssh-pi-compatible-agent-title.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1.window.api.app.getIdentity()returnedJinwoo-H/remote-host-remaining-6364.files.statplusfiles.readChunkover runtime RPC forlarge.bin(1,048,699bytes; first chunk393,216bytes, final tail123bytes with EOF).~/Documents/large.binmatched the remote source exactly by size and SHA-256 (6eb96989e4bb95cf79889ee7e62cf3a3bf1b19152c7b9b9cf6ca9b03883459f0).Follow-up Observed During Validation
fs:readFileand shows an Access denied error; pressing Retry repeats the same failure. The Download action in this PR succeeds, but editor-open retry should be tracked separately from this download fix.Made with Orca 🐋