Repository navigation
fix(ssh): open external host images from terminal links - #10323
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds 🚥 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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 78a26df8-1ec7-4725-b665-7b143f0aefbb
📒 Files selected for processing (14)
src/renderer/src/components/editor/editor-restored-tab-conflict-scan.test.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.tssrc/renderer/src/components/editor/useEditorPanelContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/components/terminal-pane/terminal-file-open-routing.tssrc/renderer/src/components/terminal-pane/terminal-link-handlers.test.tssrc/renderer/src/lib/editor-file-operation-owner.test.tssrc/renderer/src/lib/editor-file-operation-owner.tssrc/renderer/src/lib/workspace-session-editor-drafts.test.tssrc/renderer/src/lib/workspace-session.tssrc/renderer/src/store/slices/editor.test.tssrc/renderer/src/store/slices/editor.tssrc/shared/types.tstests/e2e/ssh-external-image-preview.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 086617f2-3381-422b-bf59-f9a38c98b070
📒 Files selected for processing (24)
src/renderer/src/components/editor/EditorContent.tsxsrc/renderer/src/components/editor/ExternalFileChangeBanner.tsxsrc/renderer/src/components/editor/ExternalFileChangeCompareDialog.tsxsrc/renderer/src/components/editor/MarkdownPreview.tsxsrc/renderer/src/components/editor/RichMarkdownEditor.tsxsrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.tssrc/renderer/src/components/editor/rich-markdown-editor-config.tssrc/renderer/src/components/editor/rich-markdown-image-context.tssrc/renderer/src/components/editor/useEditorPanelContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/components/editor/useLocalImageSrc.test.tssrc/renderer/src/components/editor/useLocalImageSrc.tssrc/renderer/src/components/editor/useRichMarkdownProgrammaticSync.tssrc/renderer/src/components/editor/useRichMarkdownReconcileRoundTrip.tssrc/renderer/src/components/terminal-pane/terminal-file-open-routing.tssrc/renderer/src/components/terminal-pane/terminal-link-handlers.test.tssrc/renderer/src/hooks/useEditorExternalWatch.tssrc/renderer/src/runtime/mobile-markdown-bridge.tssrc/renderer/src/runtime/runtime-file-client.test.tssrc/renderer/src/runtime/runtime-file-client.tssrc/renderer/src/store/slices/editor.test.tssrc/renderer/src/store/slices/editor.tssrc/shared/workspace-session-schema.test.tssrc/shared/workspace-session-schema.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts
- src/renderer/src/components/editor/useEditorPanelContentState.ts
- src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts
- src/renderer/src/store/slices/editor.ts
Main's SSH external-image wiring (#10323) pushed RichMarkdownEditor.tsx over the 400-line tsx budget, failing PR Checks lint on every merge into main. Move the props type into a sibling module so the component stays under the limit without disabling max-lines.
…10429) * Fix fork PR/MR worktree creation race via durable review-head refs When creating a fork PR/MR worktree, concurrent `git fetch origin` operations clobber the shared FETCH_HEAD, causing the wrong commit to be checked out. Fetch PR/MR heads into dedicated per-review refs (`refs/orca/pull/<N>`, `refs/orca/merge-requests/<N>`) that persist and isolate each head from other fetches. Gracefully keep the compare-base when the fetch fails but the local ref already exists, avoiding silent fallback to the wrong branch on transient network errors. * Bound PR/MR head fetches with 60s timeout Prevent PR/MR creation from hanging when a remote is stalled or unreachable. Both GitHub and GitLab head fetches now enforce a 60-second timeout, matching the bound used in the create-path fetch. Durable refs (refs/orca/pull/*, refs/orca/merge-requests/*) decouple the ref from FETCH_HEAD, preserving legacy client semantics. * test: align CI expectations with main PowerShell/sparse regressions PR checks merge into main, which recently changed PowerShell launch args (cwd restore after profiles) and sparse-checkout detection (require core.sparseCheckout). Derive PowerShell spawn args from the production resolver, mock the sparse config flag, reset shared worktree list scan cache between tests, and stop requiring floating polls to avoid getRepos hydration. * Address review follow-ups on durable review-head refs - Unify PR review-head remote selection: local and SSH GitHub paths share resolveGitHubReviewHeadRemote, which prefers the remote mapping to the hosting GitHub project (upstream before origin, matching work-item/API candidate order) so contributor clones fetch refs/pull from the repo that actually hosts the PR. - Soft-keep durable review heads: when the PR/MR head fetch fails but refs/orca/pull/<N> / refs/orca/merge-requests/<iid> still resolves, keep the pinned SHA (warn) instead of failing resolve, mirroring the compare-base fallback. Extracted shared compare-base soft-keep into compare-base-ref-fetch.ts. - Extract fetchGitLabMergeRequestHeadRef (local + SSH) parallel to the GitHub helper; bound its local fetch with the shared 60s timeout. - Share relay-style fetch validation (positive safe-integer id, remote not starting with "-") between relay and local helpers via review-head-tracking-ref.ts; move REVIEW_HEAD_FETCH_TIMEOUT_MS there. - Drop the githubPullRequestHeadLocalRef re-export; resolve head SHAs via rev-parse --verify <ref>^{commit}. - Add GitLab anti-FETCH_HEAD regression test plus durable-head soft-keep and remote-selection unit tests. Co-authored-by: Orca <[email protected]> * test: supply live getRepos for terminal-retirement hydrates Main's headless tab hydrate (#9343) skips worktree keys whose repo is not in getRepos. Retirement tests that rebuild mobile tabs from a persisted session now advertise the fixture repo as live so PR Checks merge stays green. * fix(editor): extract RichMarkdownEditor props to stay under max-lines Main's SSH external-image wiring (#10323) pushed RichMarkdownEditor.tsx over the 400-line tsx budget, failing PR Checks lint on every merge into main. Move the props type into a sibling module so the component stays under the limit without disabling max-lines. * Make durable review-head refs remote-identity scoped Embed remote name + URL hash into refs/orca/pull|merge-requests refs to prevent soft-keep from serving wrong project's PR/MR when FETCH_HEAD is clobbered by concurrent fetch. Fetch functions now return the written ref path (writer-authoritative) so callers rev-parse exactly what was fetched, not re-derive identity. Soft-keep only applies to transient errors (timeout, network); fails hard on missing refs, auth failures, and stale relay. Relay returns localRef so client avoids re-hashing (URL normalization can disagree). --------- Co-authored-by: Orca <[email protected]>
* fix(ssh): open external host images from terminal links * fix(ssh): keep external file ownership host-scoped * fix(ssh): reject blank external file owners --------- Co-authored-by: OrcaWin <[email protected]>
…tablyai#10429) * Fix fork PR/MR worktree creation race via durable review-head refs When creating a fork PR/MR worktree, concurrent `git fetch origin` operations clobber the shared FETCH_HEAD, causing the wrong commit to be checked out. Fetch PR/MR heads into dedicated per-review refs (`refs/orca/pull/<N>`, `refs/orca/merge-requests/<N>`) that persist and isolate each head from other fetches. Gracefully keep the compare-base when the fetch fails but the local ref already exists, avoiding silent fallback to the wrong branch on transient network errors. * Bound PR/MR head fetches with 60s timeout Prevent PR/MR creation from hanging when a remote is stalled or unreachable. Both GitHub and GitLab head fetches now enforce a 60-second timeout, matching the bound used in the create-path fetch. Durable refs (refs/orca/pull/*, refs/orca/merge-requests/*) decouple the ref from FETCH_HEAD, preserving legacy client semantics. * test: align CI expectations with main PowerShell/sparse regressions PR checks merge into main, which recently changed PowerShell launch args (cwd restore after profiles) and sparse-checkout detection (require core.sparseCheckout). Derive PowerShell spawn args from the production resolver, mock the sparse config flag, reset shared worktree list scan cache between tests, and stop requiring floating polls to avoid getRepos hydration. * Address review follow-ups on durable review-head refs - Unify PR review-head remote selection: local and SSH GitHub paths share resolveGitHubReviewHeadRemote, which prefers the remote mapping to the hosting GitHub project (upstream before origin, matching work-item/API candidate order) so contributor clones fetch refs/pull from the repo that actually hosts the PR. - Soft-keep durable review heads: when the PR/MR head fetch fails but refs/orca/pull/<N> / refs/orca/merge-requests/<iid> still resolves, keep the pinned SHA (warn) instead of failing resolve, mirroring the compare-base fallback. Extracted shared compare-base soft-keep into compare-base-ref-fetch.ts. - Extract fetchGitLabMergeRequestHeadRef (local + SSH) parallel to the GitHub helper; bound its local fetch with the shared 60s timeout. - Share relay-style fetch validation (positive safe-integer id, remote not starting with "-") between relay and local helpers via review-head-tracking-ref.ts; move REVIEW_HEAD_FETCH_TIMEOUT_MS there. - Drop the githubPullRequestHeadLocalRef re-export; resolve head SHAs via rev-parse --verify <ref>^{commit}. - Add GitLab anti-FETCH_HEAD regression test plus durable-head soft-keep and remote-selection unit tests. Co-authored-by: Orca <[email protected]> * test: supply live getRepos for terminal-retirement hydrates Main's headless tab hydrate (stablyai#9343) skips worktree keys whose repo is not in getRepos. Retirement tests that rebuild mobile tabs from a persisted session now advertise the fixture repo as live so PR Checks merge stays green. * fix(editor): extract RichMarkdownEditor props to stay under max-lines Main's SSH external-image wiring (stablyai#10323) pushed RichMarkdownEditor.tsx over the 400-line tsx budget, failing PR Checks lint on every merge into main. Move the props type into a sibling module so the component stays under the limit without disabling max-lines. * Make durable review-head refs remote-identity scoped Embed remote name + URL hash into refs/orca/pull|merge-requests refs to prevent soft-keep from serving wrong project's PR/MR when FETCH_HEAD is clobbered by concurrent fetch. Fetch functions now return the written ref path (writer-authoritative) so callers rev-parse exactly what was fetched, not re-derive identity. Soft-keep only applies to transient errors (timeout, network); fails hard on missing refs, auth failures, and stale relay. Relay returns localRef so client avoids re-hashing (URL normalization can disagree). --------- Co-authored-by: Orca <[email protected]>
Summary
Root Cause
PR #1878 changed external SSH reads from
readFile({ connectionId })to unconditional rejection whenever a connection existed. PR #1924 later moved that logic without introducing the regression. External SSH paths use the absolute path as bothfilePathandrelativePath, so the editor misclassified them as restored client-local files before the healthy SSH read/image path could run.Screenshots
No visual design change. The Docker-backed Electron E2E captures the rendered remote image as test evidence.
Testing
pnpm lint— touched-file oxlint and React Doctor pre-commit lint passed; full repository lint was not run.pnpm typecheckpnpm test— 531 focused Vitest tests passed across terminal routing, editor ownership/loading/restore, markdown image loaders, session persistence, runtime file routing, and relay filesystem handling.pnpm build— Electron E2E build and all-platform relay build passed.Additional gates:
pnpm run typecheck:nodepnpm run build:relaypnpm run check:max-lines-ratchetpnpm run check:reliability-gatesgit diff --checkORCA_E2E_SSH_DOCKER=1 ... ssh-external-image-preview.spec.ts(1 passed)AI Review Report
Completed four internal review/fix rounds, including repeated elegance and performance audits. The review covered macOS/Linux/Windows path forms (including WSL UNC aliases), direct SSH vs remote-runtime routing, host replacement/reconnect behavior, restart persistence, secondary reads, detached markdown previews, mutation provenance, mobile reads, and relay behavior.
Issues found and fixed during review:
externalSshTargetIdon restart.The final round found no remaining in-scope issues. The docstring warning is not actionable under this repository's policy favoring concise, non-obvious comments.
Security Audit
Reviewed path authorization, IPC boundaries, SSH provider selection, remote-runtime separation, persistence, and mutation ownership. Remote absolute paths remain behind the SSH/runtime filesystem providers; client-local authorization is not granted for SSH paths. Reads and writes reject when the persisted external owner no longer matches the current target, and runtime-owned paths cannot inherit direct-SSH ownership. No secrets, auth changes, new dependencies, or new command construction were introduced.
Notes