The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): preserve a sentinel already captured when force-settling
chelsealong4b16a99f71d3
diff --git a/apps/desktop/electron/shell-path.test.ts b/apps/desktop/electron/shell-path.test.tsindex bbca038e165..4792af947c0 100644--- a/apps/desktop/electron/shell-path.test.ts+++ b/apps/desktop/electron/shell-path.test.ts@@ -1,4 +1,5 @@import assert from 'node:assert/strict'+import { EventEmitter } from 'node:events'import { beforeEach, test } from 'vitest'@@ -152,6 +153,23 @@ test('applyLoginShellPath force-settles when a hung grandchild keeps the execFilassert.ok(elapsed < 4000, `expected the probe to force-settle well under the test timeout, took ${elapsed}ms`)})+test('applyLoginShellPath keeps a sentinel already printed when the hard timer force-settles', async () => {+ const env: any = { SHELL: '/bin/zsh', PATH: '/usr/bin' }+ // Simulates a probe whose shell already wrote the sentinel before a+ // daemon-holding descendant wedges the pipe: execFile's callback never+ // fires, but the stdout stream itself did emit the data.+ const stdout = new EventEmitter()+ const execFileFn = () => ({ pid: 424243, stdin: { end() {} }, stdout })++ const resultPromise = applyLoginShellPath({ env, platform: 'linux', execFileFn, timeoutMs: 20 })+ stdout.emit('data', `${START}/opt/homebrew/bin:/usr/bin${END}`)++ const result = await resultPromise++ assert.equal(result.applied, true)+ assert.equal(env.PATH, '/opt/homebrew/bin:/usr/bin')+})+test('ensureLoginShellPath never rejects', async () => {const execFileFn = () => {throw new Error('spawn EACCES')diff --git a/apps/desktop/electron/shell-path.ts b/apps/desktop/electron/shell-path.tsindex 6760af4037c..426c2747daf 100644--- a/apps/desktop/electron/shell-path.ts+++ b/apps/desktop/electron/shell-path.ts@@ -71,6 +71,7 @@ function runProbe(shell, flags, execFileFn, timeoutMs): Promise<string | null> {return new Promise(resolve => {let settled = falselet hardTimer: ReturnType<typeof setTimeout> | null = null+ let capturedStdout = ''const finish = value => {if (!settled) {@@ -99,6 +100,12 @@ function runProbe(shell, flags, execFileFn, timeoutMs): Promise<string | null> {// Interactive shells with a broken rc can block reading stdin.child?.stdin?.end?.()+ // Mirror what the callback would have seen, so a sentinel that already+ // printed before a descendant wedged the pipe isn't thrown away below.+ child?.stdout?.on?.('data', chunk => {+ capturedStdout += chunk+ })+// execFile's own `timeout` only SIGTERMs the direct child; a profile// that spawns a daemon (e.g. Powerlevel10k's gitstatusd) can leave a// grandchild holding the stdout pipe open, so the callback above never@@ -120,7 +127,7 @@ function runProbe(shell, flags, execFileFn, timeoutMs): Promise<string | null> {}}- finish(null)+ finish(extractSentinelPath(capturedStdout))}, timeoutMs + 1000)} catch {finish(null)