Repository navigation
Ssh watcher isolation e2e - #8494
Conversation
- 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
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds 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)
✅ Passed checks (3 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: 2
🧹 Nitpick comments (3)
.github/workflows/e2e.yml (1)
202-205: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing
if: runner.os == 'Linux'guard breaks documented cross-workflow invariant.The
buildande2ejobs in this same file gate this node-gyp override withif: runner.os == 'Linux', and thee2ejob'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 winDuplicate reconnect logic.
reconnectDockerSshRelayTargetandreconnectDisconnectedDockerSshRelayTargetshare nearly identical bodies, differing only in whetherdisconnectruns 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 winDuplicate
shellQuote— export the existing one fromdocker-ssh-relay-target.tsinstead.This is a byte-for-byte copy of the private
shellQuotealready defined indocker-ssh-relay-target.ts, which this file already importsexecDockerSshRelayTargetCommand/DockerSshRelayTargetfrom. 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
📒 Files selected for processing (8)
.github/workflows/e2e.ymlconfig/scripts/run-ssh-docker-watcher-isolation-e2e.mjspackage.jsontests/e2e/helpers/docker-ssh-relay-connection.tstests/e2e/helpers/docker-ssh-relay-processes.tstests/e2e/helpers/docker-ssh-relay-target.tstests/e2e/ssh-docker-relay-perf.spec.tstests/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
* 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
Summary
Describe the user-visible change.
Screenshots
No visual change.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAI 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.