Skip to content

fix(doc-preview): preview SSH host files only through the host's Orca server - #47204

Merged
AmoabaKelvin merged 1 commit into
mainfrom
fix/ssh-html-preview
Nov 23, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
fix/ssh-html-preview

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

HTML previews of files on an SSH host already work, because Orca now runs its own server on every SSH host it connects to. One leftover code path still tried to read some of those files "directly over SSH", which nothing in Orca can do any more. That path could only fail, with a misleading "Remote connection dropped" message. This PR removes it, so remote previews always go through the host's Orca server. When a host has no server, Orca now says so up front instead of opening a preview that can't load.

Files Added Deleted Net
Test 0 0 0 0
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​73 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37

What Changed

  • buildDocPreviewGrantRequest used to check the file's SSH connectionId before its runtime server. If there was a connectionId, it minted an ssh grant. Main's doc-preview reader refuses every ssh grant with SSH_HOST_NOT_SERVED_MESSAGE ("Remote connection dropped. Click Reconnect…"). Grants now only go to the server that owns the workspace (runtimeEnvironmentIdOrLocalUnlessTwin). A row that names no server gets no grant.
  • getWorkspaceFilePreviewPlan now resolves the server first, the same order the file explorer, editor reads, markdown preview and chat links already use. A row that still names a bare SSH target (a legacy pre-orcad row whose host no Orca server serves) is refused with the existing sshHostWithoutServerMessage: "No Orca server is running on yet. Connect the host to set one up, then try again." Before, it opened a tab that could only fail.
  • Nothing mints an ssh grant any more, so the ssh owner kind is removed from the preload type, IPC validation, the main grant registry, both readers, artifact share and external-link confirmation.

What users see:

  • Previews on a connected SSH host: unchanged. They worked before this PR and still work (checked live, screenshot below).
  • A legacy row whose host has no Orca server: "Open in browser" is hidden or refused with the message above, instead of a tab saying "Preview unavailable", whose hidden page body said the connection dropped.
  • A paired server's row that still carries that server's legacy nested SSH id: the preview now asks that server, instead of this desktop pretending it could dial the server's SSH target.

Why

Since 1.4.225 every served SSH host runs on orcad. The SSH-to-orcad migration deletes connectionId from the rows it moves, so a served host's rows are runtime:<env> with no connectionId. This desktop's main process serves no ssh: route (requireLocalRoute throws SshHostNotServedError). The ssh grant was therefore dead weight that could only produce a false "connection dropped".

Alternatives considered:

  • Only rewording the reader's message: this would keep minting grants that can never load, and leave the wrong owner order in the grant builder.
  • Making main read SSH files for previews: this would rebuild a direct-SSH path the app removed on purpose.

Linked Issue

No GitHub issue. Remote browser parity gap M43 from the 2026-11-22 sweep. The gap's main claim (previews on SSH workspaces always fail while connected) did not reproduce on main: managed SSH previews already work. This PR fixes the leftover legacy path the gap pointed at.

Visual Proof

The preview behaviour on a connected SSH host is unchanged, so there is no before/after. These are live captures from a hidden dev build of this branch, against a real loopback SSH host running a freshly deployed orcad.

A managed SSH workspace previewing index.html from the host, through the runtime grant:

after-managed.png

A legacy bare ssh: row (injected into the renderer store, since no current flow creates one). No grant is minted and no guest page is created; the restored tab shows the existing "Preview unavailable" panel:

after-legacy.png

Testing

  • Real remote run on macOS. A hidden dev build of this branch (ORCA_BACKGROUND_LAUNCH=1, mock keychain, scratch HOME) connected to a userland sshd on 127.0.0.1 and deployed this branch's orcad template. I added a git repo on the host through repo.add on the managed server, then opened index.html as a workspace doc tab.

    • Main and the branch both rendered the page through an orca-preview:// runtime grant.
    • After "Allow folder", the sibling style.css loaded too.
  • Legacy bare ssh: row (store-injected, branch only): no grant or guest is created (CDP target count unchanged), and the panel shows "Preview unavailable". On main this row mints an ssh grant that the reader refuses with "Remote connection dropped" (read from code, doc-preview-grants.ts:35-38 and doc-preview-file-reader.ts:252-253; not run).

  • pnpm check:changed passed, as did pnpm tc:web and pnpm tc:node.

  • One review round (Codex + Claude) came back with no findings.

  • No test added: no existing tests pin these functions, and the change removes a branch rather than adding logic.

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

Performance

None, because this only reorders two checks that run when a preview opens, and deletes branches.

Risk

The riskiest part is the plan order. The runtime server is now checked before the per-file SSH id. A runtime row with a legacy nested SSH id now asks its server instead of failing on this desktop. Ambiguous ownership (undefined) is still refused before either check, and twins are still refused first. Local workspaces still open file:// tabs. The grant IPC runs entirely inside one app, so there is no mixed-version wire impact. Older desktops, servers and phones see no change. Back out with a plain revert.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: grants still only read through a server's worktree-scoped files.read or file grants. No new read path.
  • Cross-platform: no path or platform code changed.
  • Mobile: phones don't mint desktop doc-preview 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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

Preview grants checked the file's SSH connection id before its server, so a
row that still named an SSH target got an ssh grant that main refuses with
"Remote connection dropped". Every served SSH host is a managed server now,
so grants are runtime-only; a host with no server says so instead of opening
a preview that can't load.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Document preview grants now accept runtime owners only. Grant requests require a runtime environment and file directory. Grant reads and external-link confirmations use the runtime environment. Preview planning marks SSH hosts without a runtime environment as unsupported.

Merge Risk: Minimal · up to 626e6

SSH host document previews now go only through the host's Orca server. Hosts without a server get an explanatory refusal instead of a preview that cannot load. No concrete defect remains in the reviewed change, so the merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the doc-preview fix that serves SSH host files only through the host's Orca server. It matches the changeset, which removes the SSH grant path and routes previews thro…
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 follows the template well. It has an ELI5, What Changed, Why, a linked-issue note, Visual Proof with before/after captures, Testing with steps and platform (macOS), Performance, Risk w…
Full details: Title check

Explanation

The title names the main change: the doc-preview fix that serves SSH host files only through the host's Orca server. It matches the changeset, which removes the SSH grant path and routes previews through the runtime server. The title follows the conventional commit style and stays under the length guidance.

Full details: Description check

Explanation

The description follows the template well. It has an ELI5, What Changed, Why, a linked-issue note, Visual Proof with before/after captures, Testing with steps and platform (macOS), Performance, Risk with level and backout, and a checked Checklist. It has no explicit issue link, but the author explains there is no GitHub issue and cites a sweep gap instead. The AI Disclosure and Review sections are empty. Those are minor gaps and do not make the description largely incomplete.

  • Autofix · 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cf737a1a-00cf-436a-b0a0-800e5446b410
Commits

Reviewing files that changed from the base of the PR and between 61476bf and 626e639.

Files selected for processing: 9

  • src/main/browser/document-preview/doc-preview-file-reader.ts
  • src/main/browser/document-preview/doc-preview-grant-registry.ts
  • src/main/browser/document-preview/doc-preview-terminal-file-reader.ts
  • src/main/ipc/doc-preview-grant-ipc.ts
  • src/preload/api/document-preview/doc-preview-api.ts
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-artifact-share.tsx
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-external-link-confirmation.tsx
  • src/renderer/src/lib/browser/documents/doc-preview-grants.ts
  • src/renderer/src/lib/browser/documents/file-preview.ts
Files with no reviewable changes: 2

  • src/main/browser/document-preview/doc-preview-file-reader.ts
  • src/main/browser/document-preview/doc-preview-terminal-file-reader.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit a9e7199 into main Nov 23, 2026
33 of 34 checks passed
Fartown pushed a commit to Fartown/orca that referenced this pull request Nov 27, 2026
合入上游 fa60d0a..33dfd04(1988 个提交),110 个冲突文件全部按「以上游为底、重放 fork 改动」解决。

上游这一段的主要变化与 fork 侧的应对:
- stablyai#46786 删除约 93% 的测试与配套夹具:登记表摘掉已不存在的上游测试;fork 测试仍需要的 38 个夹具搬进 src/fork-test-support、tests/e2e/fork-fixtures;守护 fork 行为的用例移植到各功能自有测试。
- 主进程状态重构为 DesktopCore:fork 启动代码改读 state.core.runtime;Goal 与本地任务的启动调用从行数已满的启动流程文件迁到 chat-journal-startup(时序不变,serve 仍在绑定 RPC 前等待 Goal 注册)。
- stablyai#46479 配对端智能体列表改为非 React 增量发布:公共会话名改成覆盖层接入,并修复发布器就绪前解析出的名字不随首发发出的问题。
- stablyai#47204 文档预览只经主机上的 Orca 服务端:局域网分享目标与 HTML 窗格内预览随之只认 runtime 授权。
- stablyai#48447 移除 Gemini CLI、测试专用导出被删:相应 fork 用例调整。
- 新棘轮(zod-prefer-lazy 等)命中的 fork 既有代码登记进基线;手机网页包脚本数量表按实测更新。

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GvYgJSDZu9H4rmSuyr1FeT
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