Skip to content

Fix Remote Host downloads and agent status parity - #6436

Merged
Jinwoo-H merged 3 commits into
mainfrom
Jinwoo-H/remote-host-remaining-6364
Jun 26, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
Jinwoo-H/remote-host-remaining-6364

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds Remote Host File Explorer downloads for runtime-owned worktrees, using full-file chunked transfer instead of preview-sized reads.
  • Saves downloaded files through Electron native save sessions with temp-file promotion and cleanup on failure/cancel.
  • Drops terminal output already covered by the initial multiplex snapshot so buffered startup output is not duplicated.
  • Adds Pi/OMP-compatible synthetic title detection and hook-driven status titles, plus SSH Docker E2E coverage for those title shapes.

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:

  • Remote Host file rows could not be downloaded because the UI only had the SSH download path.
  • Remote Host downloads must behave like a real file transfer, not a preview save, so large files and binaries are transferred in chunks.
  • Pi/OMP-compatible agent status titles were not recognized consistently across remote/SSH terminal status paths.
  • Initial terminal subscription could replay output already included in the snapshot.

Validation

  • pnpm run typecheck passed. Note: local Node 26 produced the repo Node 24 engine warning.
  • pnpm run lint passed. Note: local Node 26 produced the repo Node 24 engine warning.
  • git diff --check origin/main...HEAD passed.
  • Focused Vitest suite passed: 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:relay passed for linux/darwin/win x64/arm64 relay bundles.
  • Live Docker SSH E2E passed: 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.
  • Launched this PR worktree in Electron with isolated user data and verified window.api.app.getIdentity() returned Jinwoo-H/remote-host-remaining-6364.
  • Paired a local headless Orca runtime server, registered a disposable git repo, exposed its runtime worktree, and verified files.stat plus files.readChunk over runtime RPC for large.bin (1,048,699 bytes; first chunk 393,216 bytes, final tail 123 bytes with EOF).
  • Exercised the user-facing File Explorer Download action on the remote runtime file. macOS native Save dialog appeared, Save completed, and ~/Documents/large.bin matched the remote source exactly by size and SHA-256 (6eb96989e4bb95cf79889ee7e62cf3a3bf1b19152c7b9b9cf6ca9b03883459f0).
  • Inspected renderer console/app logs for relevant errors during the download path; no console errors were reported.
  • Cleaned up the live SSH container, remote runtime server, dev Electron process, temp repos/user-data, and downloaded test artifact.

Follow-up Observed During Validation

  • Clicking a remote runtime file row to open it in the editor still routes through local fs:readFile and 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 🐋

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main changes to remote downloads and agent status parity.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description is detailed and covers summary, validation, and follow-up, but it misses the template’s Screenshots, AI Review Report, Security Audit, and Notes sections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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: 4

🧹 Nitpick comments (3)
src/shared/agent-detection.ts (1)

326-329: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add 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 before isPiAgentTitle / the generic braille (isClaudeAgent) heuristic — i.e. that ⠋ OMP / ⠋ Pi working 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 win

Consider 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) — where chunkStartSeq < 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 value

Consider 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 to provider.readFile, which will surface a less actionable provider error. A provider.stat directory 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1293ed0 and 341a57d.

📒 Files selected for processing (25)
  • src/main/ipc/filesystem.test.ts
  • src/main/ipc/filesystem.ts
  • src/main/runtime/orca-runtime-files.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/files.test.ts
  • src/main/runtime/rpc/methods/files.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/main/runtime/runtime-rpc.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/FileExplorer.test.tsx
  • src/renderer/src/components/right-sidebar/FileExplorer.tsx
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/renderer/src/components/right-sidebar/FileExplorerVirtualRows.tsx
  • src/renderer/src/runtime/runtime-file-client.test.ts
  • src/renderer/src/runtime/runtime-file-client.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/agent-detection.test.ts
  • src/shared/agent-detection.ts
  • src/shared/pi-compatible-synthetic-title.ts
  • src/shared/runtime-types.ts
  • src/shared/synthetic-agent-title.test.ts
  • src/shared/synthetic-agent-title.ts
  • tests/e2e/ssh-pi-compatible-agent-title.spec.ts

Comment thread src/main/ipc/filesystem.ts Resolved
Comment thread src/main/ipc/filesystem.ts Resolved
Comment on lines +481 to +493
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
}
}

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.

🚀 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*' -C2

Repository: 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 -20

Repository: 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 expanded

Repository: 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 -50

Repository: 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 -20

Repository: 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.

@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/runtime/orca-runtime-files.ts (1)

485-489: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document 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 short Why: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 341a57d and 024db6f.

📒 Files selected for processing (6)
  • src/main/ipc/filesystem.test.ts
  • src/main/ipc/filesystem.ts
  • src/main/runtime/orca-runtime-files.ts
  • src/main/runtime/rpc/terminal-multiplex.test.ts
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/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

@Jinwoo-H
Jinwoo-H merged commit 4904ffd into main Jun 26, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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]>
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.

1 participant