Finding
PR #279 (fix for #276) frames the remote CLI --version output with OPENCODE_CLI_VERSION_BEGIN/END markers, but versionScript prints the END marker with no leading newline:
packages/gui-extensions/src/ssh/remote-cli.ts:44 (PR branch, commit 0b4b0af)
packages/gui-extensions/src/wsl/remote-cli.ts:23 (identical copy)
printf 'OPENCODE_CLI_VERSION_BEGIN\n'; <command> --version 2>/dev/null || true; printf 'OPENCODE_CLI_VERSION_END\n'
parseVersion (ssh remote-cli.ts:57-58, wsl remote-cli.ts:35-36) only accepts the END marker as a whole trimmed line (lines.indexOf("OPENCODE_CLI_VERSION_END", begin + 1)). If the remote CLI's --version output does not end with a newline, the END marker glues onto the version line, no line equals the marker, end === -1, and parseVersion returns null for a working CLI.
The sibling frame in the same code already guards against exactly this: the registration script in packages/gui-extensions/src/ssh/bootstrap.ts:15 prints printf '\nOPENCODE_SSH_REGISTRATION_END\n' — with a leading \n — because the cat output it frames may not end with a newline. PR #279's new tests can't see the gap: their framed() helper always places END on its own line.
Evidence (verified live against the PR branch)
Ran PR #279's own versionScript under sh with fake CLIs and fed the real output to its parseVersion:
- CLI prints
2.1.0 without trailing newline → raw output OPENCODE_CLI_VERSION_BEGIN\n2.1.0OPENCODE_CLI_VERSION_END\n → parseVersion returns null (expected 2.1.0)
- CLI prints
opencode v2.1.0 without trailing newline → null (expected 2.1.0)
- CLI prints
2.1.0\n → 2.1.0 (works)
Why it matters
Both callers treat null as "no usable CLI": the SSH staged check RemoteCli.parseVersion(existing) === input.version (packages/gui-extensions/src/ssh/bootstrap.ts:105-106) reports a staged, working CLI as not staged, and the WSL cliCheck (packages/gui-extensions/src/wsl/runtime.ts:371-373) takes its cannot-run branch. Adapters supply the command as an arbitrary quoted shell expression, so a wrapper or a CLI build whose version print lacks a trailing newline silently breaks detection — the same class of output-shape fragility #276/#279 set out to eliminate.
Acceptance criteria
-
versionScript in both remote-cli.ts copies emits the END marker on its own line regardless of whether --version output ends with a newline (e.g. leading \n, matching the registration frame), or parseVersion tolerates a glued END marker
- Regression tests in both
remote-cli.test.ts files cover a --version output with no trailing newline, produced through the real versionScript string (not only the framed() helper)
- Existing framed/banner/empty-frame behaviour from fix(gui-extensions): frame remote CLI version output so a banner cannot invent a version #279 is unchanged
Found by the pr-diff-review job reviewing PR #279 (#279).