Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(share): plain installer log, and call a failed install a failure

review674209b07a23
diff --git a/scripts/install-server.sh b/scripts/install-server.sh
index abf65a178..f68d39c12 100755
--- a/scripts/install-server.sh
+++ b/scripts/install-server.sh
@@ -36,10 +36,18 @@ NODE_LTS_VERSION="${NODETERM_NODE_VERSION:-v22.14.0}"
NODE_DIST_BASE="${NODETERM_NODE_DIST_BASE:-https://nodejs.org/dist}"
# ---- pretty output ---------------------------------------------------------------------------
-info() { printf '\033[36m→\033[0m %s\n' "$1"; }
-ok() { printf '\033[32m✓\033[0m %s\n' "$1"; }
-warn() { printf '\033[33m⚠\033[0m %s\n' "$1" >&2; }
-fail() { printf '\033[31m✗\033[0m %s\n' "$1" >&2; exit 1; }
+# Colour only on a terminal (and not under NO_COLOR): this output is also captured — the desktop's
+# "Share with team" dialog streams it over an ssh exec channel with no pty, and the nightly update
+# writes it to the journal — where escape codes arrive as literal text.
+color_out=''; color_err=''
+if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then color_out=1; fi
+if [ -t 2 ] && [ -z "${NO_COLOR:-}" ]; then color_err=1; fi
+# mark <enabled> <colour> <glyph>
+mark() { if [ -n "$1" ]; then printf '\033[%sm%s\033[0m' "$2" "$3"; else printf '%s' "$3"; fi; }
+info() { printf '%s %s\n' "$(mark "$color_out" 36 →)" "$1"; }
+ok() { printf '%s %s\n' "$(mark "$color_out" 32 ✓)" "$1"; }
+warn() { printf '%s %s\n' "$(mark "$color_err" 33 ⚠)" "$1" >&2; }
+fail() { printf '%s %s\n' "$(mark "$color_err" 31 ✗)" "$1" >&2; exit 1; }
# ---- preflight: OS + required tools ----------------------------------------------------------
[ "$(uname -s)" = "Linux" ] || fail "The headless host targets Linux (systemd). For macOS run the desktop app; for containers use the Dockerfile (see docs/SERVER.md)."
diff --git a/scripts/install-server.test.ts b/scripts/install-server.test.ts
new file mode 100644
index 000000000..9fbfb6e4e
--- /dev/null
+++ b/scripts/install-server.test.ts
@@ -0,0 +1,48 @@
+import { describe, it, expect } from 'vitest'
+import { spawnSync } from 'node:child_process'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+
+// The installer's output is read by a person in a terminal, but also captured: the desktop's
+// "Share with team" dialog streams it over an ssh exec channel (no pty) into a log, and the
+// nightly auto-update runs it under systemd into the journal. There the colour escapes arrived
+// as literal `\033[36m` text in front of every line (device run, 2026-10-03). Only the helper
+// block is run here: the whole script needs systemd, git and a network.
+const SCRIPT = readFileSync(join(__dirname, 'install-server.sh'), 'utf8').replace(/\r\n/g, '\n')
+
+function helpers(): string {
+ const start = SCRIPT.indexOf('# ---- pretty output')
+ const end = SCRIPT.indexOf('# ---- preflight', start)
+ expect(start).toBeGreaterThan(-1)
+ expect(end).toBeGreaterThan(start)
+ return SCRIPT.slice(start, end)
+}
+
+function run(env: Record<string, string> = {}): { stdout: string; stderr: string } {
+ const r = spawnSync('bash', ['-c', `set -euo pipefail\n${helpers()}\ninfo one\nok two\nwarn three`], {
+ encoding: 'utf8',
+ env: { PATH: '/usr/bin:/bin', ...env },
+ stdio: ['ignore', 'pipe', 'pipe']
+ })
+ expect(r.status).toBe(0)
+ return { stdout: r.stdout, stderr: r.stderr }
+}
+
+describe.skipIf(process.platform === 'win32')('install-server.sh output', () => {
+ it('writes no escape codes when its output is not a terminal', () => {
+ const { stdout, stderr } = run()
+ expect(stdout).toBe('→ one\n✓ two\n')
+ expect(stderr).toBe('⚠ three\n')
+ })
+
+ it('fail() still exits 1 and names the reason, uncoloured', () => {
+ const r = spawnSync('bash', ['-c', `set -euo pipefail\n${helpers()}\nfail broken\necho unreachable`], {
+ encoding: 'utf8',
+ env: { PATH: '/usr/bin:/bin' },
+ stdio: ['ignore', 'pipe', 'pipe']
+ })
+ expect(r.status).toBe(1)
+ expect(r.stdout).toBe('')
+ expect(r.stderr).toBe('✗ broken\n')
+ })
+})
diff --git a/src/renderer/lib/shareSshTeam.test.ts b/src/renderer/lib/shareSshTeam.test.ts
index e2b69a7d0..b35d5136e 100644
--- a/src/renderer/lib/shareSshTeam.test.ts
+++ b/src/renderer/lib/shareSshTeam.test.ts
@@ -443,7 +443,14 @@ describe('runShare', () => {
const failedInstall = setup()
failedInstall.deps.api.install = async () => ({ ok: true, exitCode: 1 })
failedInstall.deps.api.probe = async () => (failedInstall.log.push('probe'), { ...READY, plan: { kind: 'install', reason: 'missing' } }) as never
- expect(await runShare(failedInstall.deps, INPUT)).toMatchObject({ kind: 'failed', step: 'checking-install' })
+ // A non-zero exit is the install FAILING; saying it "finished" read as a success followed by a
+ // readiness problem (device run, 2026-10-03).
+ expect(await runShare(failedInstall.deps, INPUT)).toEqual({
+ kind: 'failed',
+ step: 'checking-install',
+ error: 'The install failed (exit 1).',
+ reopened: false
+ })
expect(failedInstall.log.filter((l) => l === 'probe')).toHaveLength(2)
let n = 0
const refusing = setup()
diff --git a/src/renderer/lib/shareSshTeam.ts b/src/renderer/lib/shareSshTeam.ts
index 7cb418757..1e2575ea4 100644
--- a/src/renderer/lib/shareSshTeam.ts
+++ b/src/renderer/lib/shareSshTeam.ts
@@ -279,9 +279,13 @@ export async function runShare(deps: ShareDeps, input: ShareInput): Promise<Shar
again = await call(() => api.probe(projectId, ids))
}
if (!again.ok || again.plan.kind !== 'ready') {
- const base = installed.ok
- ? `The install finished (exit ${installed.exitCode}) but nodeterm-server is not ready on the host.`
- : installed.error
+ // A non-zero exit is the install failing; "finished … but not ready" read as a success with
+ // a readiness problem. The dialog shows the install's output under this line.
+ const base = !installed.ok
+ ? installed.error
+ : installed.exitCode === 0
+ ? `The install finished (exit 0) but nodeterm-server is not ready on the host.`
+ : `The install failed (exit ${installed.exitCode}).`
const why = !again.ok ? again.error : again.plan.kind === 'refuse' ? again.plan.reason : ''
// A dead connection fails the install and the re-probe with the same message: say it once.
return failed('checking-install', why && why !== base ? `${base} ${why}` : base, false)