Skip to content

Ssh watcher isolation e2e - #8494

Merged
AmethystLiang merged 2 commits into
mainfrom
ssh-watcher-isolation-e2e
Jul 13, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
ssh-watcher-isolation-e2e

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Describe the user-visible change.

Screenshots

  • Add screenshots or a screen recording for any new or changed UI behavior.
  • If there is no visual change, say No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

Summarize the code review you ran with your AI coding agent. Include the main risks it checked, what it flagged, and what you changed or verified as a result.
Confirm that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR.

Security Audit

Provide a basic security audit summary from your AI coding agent. Call out any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks that were reviewed, plus any follow-up needed.

Notes

Call out any platform-specific behavior, risks, or follow-up work.

- Covers two scenarios: crashed watcher children are respawned under the
  same relay without dropping the terminal PTY or file-explorer view, and
  a missing deployed relay-watcher.js artifact is repaired on reconnect
- Extracts shared connect/disconnect/reconnect logic out of the perf spec
  into docker-ssh-relay-connection.ts, and adds docker-ssh-relay-processes.ts
  for inspecting/signaling remote relay and watcher PIDs
- Wires the new spec into a dedicated CI job and pnpm script
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 651880bd-9adf-4943-819d-9b535741252b

📥 Commits

Reviewing files that changed from the base of the PR and between ca901e0 and b1b426f.

📒 Files selected for processing (5)
  • .github/workflows/e2e.yml
  • config/scripts/run-ssh-docker-watcher-isolation-e2e.mjs
  • tests/e2e/helpers/docker-ssh-relay-connection.ts
  • tests/e2e/helpers/docker-ssh-relay-processes.ts
  • tests/e2e/helpers/docker-ssh-relay-target.ts

📝 Walkthrough

Walkthrough

Adds a dedicated Docker SSH watcher isolation E2E workflow, runner script, and package command. Introduces reusable helpers for connecting to relay targets, controlling relay processes, inspecting artifacts, executing Docker commands, and writing remote files. Migrates relay setup in performance tests to shared helpers. Adds Playwright scenarios covering watcher replacement after crashes and watcher artifact restoration after reconnect.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is still the template placeholder text and lacks actual summaries, screenshots, testing, review, security, and notes. Fill in each section with concrete PR details, especially the summary, testing results, AI review, security audit, and any platform-specific notes.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: a new SSH watcher isolation E2E test.
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.
✨ 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: 2

🧹 Nitpick comments (3)
.github/workflows/e2e.yml (1)

202-205: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing if: runner.os == 'Linux' guard breaks documented cross-workflow invariant.

The build and e2e jobs in this same file gate this node-gyp override with if: runner.os == 'Linux', and the e2e job's comment explicitly states the guard exists to keep the workaround "consistent across all three workflows, even though this job currently pins runs-on: ubuntu-latest." This new job skips both the guard and the "(Linux only)" step naming, silently breaking that stated invariant.

♻️ Proposed fix
-      - name: Use external node-gyp to avoid pnpm's bundled copy
+      - name: Use external node-gyp to avoid pnpm's bundled copy (Linux only)
+        if: runner.os == 'Linux'
         run: |
           npm install -g node-gyp@11.5.0
           echo "npm_config_node_gyp=$(npm root -g)/node-gyp/bin/node-gyp.js" >> "$GITHUB_ENV"

Source: Linters/SAST tools

tests/e2e/helpers/docker-ssh-relay-connection.ts (1)

96-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate reconnect logic.

reconnectDockerSshRelayTarget and reconnectDisconnectedDockerSshRelayTarget share nearly identical bodies, differing only in whether disconnect runs first. Worth consolidating into a single parameterized helper to avoid drift between the two error-message/state-sync paths.

♻️ Proposed refactor
-export async function reconnectDockerSshRelayTarget(page: Page, targetId: string): Promise<void> {
-  await page.evaluate(async (targetId) => {
-    const store = window.__store
-    if (!store) {
-      throw new Error('Store unavailable')
-    }
-    await window.api.ssh.disconnect({ targetId })
-    const state = await window.api.ssh.connect({ targetId })
-    if (!state || state.status !== 'connected') {
-      throw new Error(`SSH target did not reconnect: ${JSON.stringify(state)}`)
-    }
-    store.getState().setSshConnectionState(targetId, state)
-  }, targetId)
-}
-
-export async function reconnectDisconnectedDockerSshRelayTarget(
-  page: Page,
-  targetId: string
-): Promise<void> {
-  await page.evaluate(async (targetId) => {
-    const store = window.__store
-    if (!store) {
-      throw new Error('Store unavailable')
-    }
-    const state = await window.api.ssh.connect({ targetId })
-    if (!state || state.status !== 'connected') {
-      throw new Error(`SSH target did not reconnect: ${JSON.stringify(state)}`)
-    }
-    store.getState().setSshConnectionState(targetId, state)
-  }, targetId)
-}
+async function performDockerSshRelayReconnect(
+  page: Page,
+  targetId: string,
+  disconnectFirst: boolean
+): Promise<void> {
+  await page.evaluate(async ({ targetId, disconnectFirst }) => {
+    const store = window.__store
+    if (!store) {
+      throw new Error('Store unavailable')
+    }
+    if (disconnectFirst) {
+      await window.api.ssh.disconnect({ targetId })
+    }
+    const state = await window.api.ssh.connect({ targetId })
+    if (!state || state.status !== 'connected') {
+      throw new Error(`SSH target did not reconnect: ${JSON.stringify(state)}`)
+    }
+    store.getState().setSshConnectionState(targetId, state)
+  }, { targetId, disconnectFirst })
+}
+
+export async function reconnectDockerSshRelayTarget(page: Page, targetId: string): Promise<void> {
+  return performDockerSshRelayReconnect(page, targetId, true)
+}
+
+export async function reconnectDisconnectedDockerSshRelayTarget(
+  page: Page,
+  targetId: string
+): Promise<void> {
+  return performDockerSshRelayReconnect(page, targetId, false)
+}
tests/e2e/helpers/docker-ssh-relay-processes.ts (1)

67-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate shellQuote — export the existing one from docker-ssh-relay-target.ts instead.

This is a byte-for-byte copy of the private shellQuote already defined in docker-ssh-relay-target.ts, which this file already imports execDockerSshRelayTargetCommand/DockerSshRelayTarget from. Since this is a shell-escaping utility (security-relevant), keeping two independent copies risks one being patched and the other silently left behind.

♻️ Proposed refactor
--- a/tests/e2e/helpers/docker-ssh-relay-target.ts
+++ b/tests/e2e/helpers/docker-ssh-relay-target.ts
-function shellQuote(value: string): string {
+export function shellQuote(value: string): string {
   return `'${value.replaceAll("'", "'\\''")}'`
 }
--- a/tests/e2e/helpers/docker-ssh-relay-processes.ts
+++ b/tests/e2e/helpers/docker-ssh-relay-processes.ts
 import {
   execDockerSshRelayTargetCommand,
+  shellQuote,
   type DockerSshRelayTarget
 } from './docker-ssh-relay-target'
...
-function shellQuote(value: string): string {
-  return `'${value.replaceAll("'", "'\\''")}'`
-}
-

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f45e4920-37ea-4d3e-b98d-10810c74bd39

📥 Commits

Reviewing files that changed from the base of the PR and between ec7cc2d and ca901e0.

📒 Files selected for processing (8)
  • .github/workflows/e2e.yml
  • config/scripts/run-ssh-docker-watcher-isolation-e2e.mjs
  • package.json
  • tests/e2e/helpers/docker-ssh-relay-connection.ts
  • tests/e2e/helpers/docker-ssh-relay-processes.ts
  • tests/e2e/helpers/docker-ssh-relay-target.ts
  • tests/e2e/ssh-docker-relay-perf.spec.ts
  • tests/e2e/ssh-docker-watcher-isolation.spec.ts

- node-gyp override only applies on Linux runners now, since the CI job
  moved to ubuntu-latest but shares the workflow with non-Linux jobs
- spawn the e2e runner scripts through a shell on win32 to satisfy
  Node's CVE-2024-27980 restriction on unshelled .cmd spawns
- harden relay process row parsing against empty pid/ppid fields so a
  vanished /proc entry fails loudly instead of coercing to pid 0
- dedupe the reconnect helpers and export shellQuote for reuse across
  the docker-ssh-relay test helpers
@AmethystLiang
AmethystLiang merged commit b69c604 into main Jul 13, 2026
3 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Add a Docker SSH watcher-isolation E2E test to verify remote relay-watch

- Covers two scenarios: crashed watcher children are respawned under the
  same relay without dropping the terminal PTY or file-explorer view, and
  a missing deployed relay-watcher.js artifact is repaired on reconnect
- Extracts shared connect/disconnect/reconnect logic out of the perf spec
  into docker-ssh-relay-connection.ts, and adds docker-ssh-relay-processes.ts
  for inspecting/signaling remote relay and watcher PIDs
- Wires the new spec into a dedicated CI job and pnpm script

* Fix Windows and Linux-only issues in Docker SSH watcher-isolation E2E ha

- node-gyp override only applies on Linux runners now, since the CI job
  moved to ubuntu-latest but shares the workflow with non-Linux jobs
- spawn the e2e runner scripts through a shell on win32 to satisfy
  Node's CVE-2024-27980 restriction on unshelled .cmd spawns
- harden relay process row parsing against empty pid/ppid fields so a
  vanished /proc entry fails loudly instead of coercing to pid 0
- dedupe the reconnect helpers and export shellQuote for reuse across
  the docker-ssh-relay test helpers
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