The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): make the remote-watchdog probe test host-safe
teknium1b06071c0c9d9
diff --git a/apps/desktop/electron/remote-lifecycle.test.ts b/apps/desktop/electron/remote-lifecycle.test.tsindex 941d52282aa..b04ddf5128f 100644--- a/apps/desktop/electron/remote-lifecycle.test.ts+++ b/apps/desktop/electron/remote-lifecycle.test.ts@@ -477,7 +477,9 @@ test('connect() fails closed on lockfile schema/ownership skew: skips reap, touc`${label}: connect must refuse with remote-lockfile-skew`)assert.ok(- !ssh.calls.some(c => /(^|[^-\d])kill -9 \d+/.test(c) && !/kill -0/.test(c)),+ // Any signal, a literal pid: the probe watchdog's `kill -9 $__htp`+ // targets its own child, not a lockfile pid.+ !ssh.calls.some(c => /(^|[^-\d])kill(?: -\w+)? \d/.test(c) && !/kill -0/.test(c)),`${label}: must not kill any pid`)assert.ok(!ssh.calls.some(c => /rm -f/.test(c)), `${label}: must not remove any remote file`)diff --git a/apps/desktop/electron/ssh-connection.test.ts b/apps/desktop/electron/ssh-connection.test.tsindex 49e1fd33b88..ae0f6f25c98 100644--- a/apps/desktop/electron/ssh-connection.test.ts+++ b/apps/desktop/electron/ssh-connection.test.ts@@ -1075,6 +1075,10 @@ test('stopTunnelChild waits for process exit', async () => {})test('withRemoteTimeout kills a hung probe remotely instead of orphaning it (#110478)', async () => {+ if (process.platform === 'win32') {+ return+ }+// Shape: POSIX watchdog — macOS remotes have no GNU `timeout`.const wrapped = withRemoteTimeout('hermes --version 2>&1', 15)@@ -1098,10 +1102,13 @@ test('withRemoteTimeout kills a hung probe remotely instead of orphaning it (#11// session pipes open until the full timeout on the healthy path.assert.ok(healthyElapsed < 4000, `healthy probe returned fast (took ${healthyElapsed}ms)`)- // … a hung command is killed promptly with a non-zero exit …+ // … a hung command is killed promptly with a non-zero exit … The duration+ // is unique to this run so the orphan sweep below cannot match an unrelated+ // `sleep` on a busy host.+ const hungSecs = 30_000 + (process.pid % 10_000)const start = Date.now()- const err: any = await execFileAsync('sh', ['-c', withRemoteTimeout('sleep 30', 1)]).then(+ const err: any = await execFileAsync('sh', ['-c', withRemoteTimeout(`sleep ${hungSecs}`, 1)]).then(() => null,e => e)@@ -1109,10 +1116,10 @@ test('withRemoteTimeout kills a hung probe remotely instead of orphaning it (#11const elapsed = Date.now() - startassert.ok(err && err.code !== 0, 'hung command must exit non-zero')- assert.ok(elapsed < 15000, `watchdog fired promptly instead of waiting 30s (took ${elapsed}ms)`)+ assert.ok(elapsed < 15000, `watchdog fired promptly instead of waiting ${hungSecs}s (took ${elapsed}ms)`)// … and no orphan is left behind.- const { stdout: strays } = await execFileAsync('sh', ['-c', 'ps -eo args | grep "[s]leep 30" || true'])+ const { stdout: strays } = await execFileAsync('sh', ['-c', `ps -eo args | grep "[s]leep ${hungSecs}$" || true`])assert.equal(strays.trim(), '', 'killed probe left no orphan process')})diff --git a/apps/desktop/electron/ssh-connection.ts b/apps/desktop/electron/ssh-connection.tsindex bfbe0977530..c4d3469020e 100644--- a/apps/desktop/electron/ssh-connection.ts+++ b/apps/desktop/electron/ssh-connection.ts@@ -346,10 +346,7 @@ function buildInteractiveSshArgs(conn, remoteCwd, connectTimeoutMs?, remoteComma// session pipes would keep the ssh channel open until the full timeout even on// the healthy path. Detached, the orphan is a benign self-reaping `sleep`.function withRemoteTimeout(remoteCommand, timeoutSecs = REMOTE_PROBE_TIMEOUT_SECS) {- const secs =- Number.isFinite(timeoutSecs) && timeoutSecs > 0- ? Math.floor(timeoutSecs)- : REMOTE_PROBE_TIMEOUT_SECS+ const secs = Number.isFinite(timeoutSecs) && timeoutSecs > 0 ? Math.floor(timeoutSecs) : REMOTE_PROBE_TIMEOUT_SECSreturn (`(${remoteCommand}) </dev/null & __htp=$!; ` +