Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(cli): bash's no-terminal noise out of DSH output; green CI on Linux (#376)

Dee02cf409ae26b
diff --git a/cli/src/dsh/materialize.spec.ts b/cli/src/dsh/materialize.spec.ts
index 5616c0517..d23f3ec2a 100644
--- a/cli/src/dsh/materialize.spec.ts
+++ b/cli/src/dsh/materialize.spec.ts
@@ -173,7 +173,8 @@ describe('materializeWorkspace, on harnesses other than the starter', () => {
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })
const slow = install({ engine: 'codex', workspace: { marker: 'done', init: 'sleep 30' } })
const pending = materializeWorkspace(slow, workspace)
- vi.advanceTimersByTime(5 * 60_000)
+ // And the SIGKILL grace after it: an interactive bash, the usual shell on Linux, ignores SIGTERM.
+ vi.advanceTimersByTime(5 * 60_000 + 3_000)
const result = await pending
expect(result.warnings).toEqual(['init exited by timeout'])
})
diff --git a/cli/src/dsh/shell.spec.ts b/cli/src/dsh/shell.spec.ts
index fe45adc5e..eaecb67d2 100644
--- a/cli/src/dsh/shell.spec.ts
+++ b/cli/src/dsh/shell.spec.ts
@@ -77,6 +77,15 @@ describe('isShellNoise', () => {
expect(isShellNoise("(eval):3: can't change option: zle")).toBe(true)
expect(isShellNoise('ok zle is a word a doctor might print')).toBe(false)
})
+
+ it('drops what bash says without a terminal, as Linux CI saw it', () => {
+ expect(isShellNoise('bash: cannot set terminal process group (-1): Inappropriate ioctl for device')).toBe(true)
+ expect(isShellNoise('bash: no job control in this shell')).toBe(true)
+ expect(isShellNoise('/usr/bin/bash: no job control in this shell')).toBe(true)
+ expect(isShellNoise('logout')).toBe(true)
+ expect(isShellNoise(' ok bash: no job control in this shell')).toBe(false)
+ expect(isShellNoise('logout failed')).toBe(false)
+ })
})
describe('runDshCommand', () => {
diff --git a/cli/src/dsh/shell.ts b/cli/src/dsh/shell.ts
index 949044fb2..917101084 100644
--- a/cli/src/dsh/shell.ts
+++ b/cli/src/dsh/shell.ts
@@ -26,13 +26,17 @@ export interface DshCommandResult {
/**
* What the shell itself says about being interactive without a terminal — not the DSH's output.
* `zsh -lic` with no tty cannot enable the line editor, and an rc file that sets `zle` makes zsh
- * complain once per option; the engine never sees this because its pane HAS a tty. Dropped so a
- * doctor's lines, which the desktop shows verbatim, are the doctor's.
+ * complain once per option. `bash -lic`, the usual shell on Linux, says it has no job control, and a
+ * login bash says `logout` when a script exits. The engine never sees any of this because its pane
+ * HAS a tty. Dropped so a doctor's lines, which the desktop shows verbatim, are the doctor's.
*/
export function isShellNoise(line: string): boolean {
return /can't change option: zle$/.test(line) || /^\(eval\):\d+: can't change option: zle$/.test(line)
+ || BASH_NO_TTY.test(line) || line === 'logout'
}
+const BASH_NO_TTY = /^(?:\S*\/)?bash: (?:cannot set terminal process group \(-?\d+\): Inappropriate ioctl for device|no job control in this shell)$/
+
/**
* `[path, ...args]` that runs `script` through the user's shell, or `/bin/sh -c` when none is known.
*
diff --git a/cli/src/dsh/verdict.spec.ts b/cli/src/dsh/verdict.spec.ts
index 9dd9436d0..677ba3c71 100644
--- a/cli/src/dsh/verdict.spec.ts
+++ b/cli/src/dsh/verdict.spec.ts
@@ -174,8 +174,9 @@ describe('DshVerdictWatcher, event by event', () => {
listener = (name, at) => { if (name === event && at === path) resolve(true) }
inner.on('all', listener)
})
- // a change within the same millisecond as the last one can read as no change at all
- await settle(20)
+ // a change within the same millisecond as the last one can read as no change at all, and chokidar
+ // drops a second `change` to one file within 50 ms of the first (Linux delivers them that fast)
+ await settle(80)
act()
const seenIt = await Promise.race([landed, settle(3_000).then(() => false)])
inner.off('all', listener)
diff --git a/cli/src/lib/gridHandoff.spec.ts b/cli/src/lib/gridHandoff.spec.ts
index c865ea384..5ccd2ca53 100644
--- a/cli/src/lib/gridHandoff.spec.ts
+++ b/cli/src/lib/gridHandoff.spec.ts
@@ -121,7 +121,8 @@ describe('handOffToGrid — a child that never answers', () => {
function hangingGrid(dir: string): string {
mkdirSync(dir, { recursive: true })
const bin = join(dir, 'grid')
- writeFileSync(bin, ['#!/bin/sh', "trap '' TERM", '/bin/cat > /dev/null', 'sleep 60', ''].join('\n'), { mode: 0o755 })
+ // Absolute paths, since PATH is empty here: Linux's sh exits 127 on a bare `sleep` before the watchdog fires.
+ writeFileSync(bin, ['#!/bin/sh', "trap '' TERM", '/bin/cat > /dev/null', '/bin/sleep 60', ''].join('\n'), { mode: 0o755 })
return bin
}