GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(gui-extensions): parseVersion takes the first line of login-shell output — an SSH/WSL banner is read as the CLI version (both remote-cli copies) · Issue #265 · developing-today-forks/opencode

fix(gui-extensions): parseVersion takes the first line of login-shell output — an SSH/WSL banner is read as the CLI version (both remote-cli copies) #265

New issue
Copy link
New issue
Copy link
Closed
#275
#270
Closed
fix(gui-extensions): parseVersion takes the first line of login-shell output — an SSH/WSL banner is read as the CLI version (both remote-cli copies)#265
#275
#270
Copy link

Description

@dezren39
dezren39
opened on Oct 22, 2026
Issue body actions

Problem

parseVersion reads the remote CLI's version from the first non-empty line of a login shell's output. Any banner, MOTD, or .profile echo printed before the version line is returned as the "version" — so a correctly installed remote CLI is misread on every host whose login shell prints anything.

Both copies of the parser have the identical flaw (the WSL copy's header says "keep the two copies in step"):

  • packages/gui-extensions/src/ssh/remote-cli.ts:47-60
  • packages/gui-extensions/src/wsl/remote-cli.ts:26-39
const line = output.split(/\r?\n/).find((line) => line.trim())?.trim()
const marker = line.lastIndexOf(" v")
const version = marker === -1 ? line : line.slice(marker + 2)

Both transports run login shells, so profile/banner output on stdout is expected, not exotic:

  • SSH: packages/gui-extensions/src/ssh/bootstrap.ts:86 runs scripts via sh -l -s
  • WSL: packages/gui-extensions/src/wsl/runtime.ts:224 runs scripts via sh -lc

Reproduction (parser logic run verbatim under node)

Input Returned "version"
"2.1.0\n" "2.1.0" ✅
"Welcome to Ubuntu 24.04 LTS\n2.1.0\n" "Welcome to Ubuntu 24.04 LTS" ❌
"dev tools v3 loaded\nopencode v2.1.0\n" "3 loaded" ❌
"Last login: Thu Oct 22 00:01:02 2026 from 10.0.0.2\n2.1.0\n" the whole login line ❌

Impact

  • SSH bootstrap (packages/gui-extensions/src/ssh/bootstrap.ts:106-107): parseVersion(existing) === input.version decides whether a staged CLI is reused. With any banner it is always false, so every connect re-downloads/reinstalls the CLI (or falls into the upload path), and the development-mode staged-beta choice is skewed the same way.
  • WSL (packages/gui-extensions/src/wsl/runtime.ts:347-349): readCliVersion returns the banner text as the installed version to its callers' version comparisons.
  • Same first-line pattern, same login shell: WSL resolveCli (runtime.ts:343) returns firstLine(discoverScript output) as the CLI path, so a banner line becomes the command path there too.

Contrast: the robust patterns already in this codebase

  • parseRegistration (ssh/bootstrap.ts:36-52) and the platform probe (ssh/bootstrap.ts:116-121) read marker-prefixed lines (OPENCODE_SSH_STATUS=, OPENCODE_REMOTE_TARGET=) with findLast — banner-proof.
  • The shell-side verifyScript (ssh/remote-cli.ts:121-123) extracts the version with awk '{print $NF}' from the --version line itself.
  • The openchamber repo's SSH series (fix(cli): restart-driver passes OC_PORT to the server unvalidated — NaN, fractional, out-of-range and empty values bind the wrong port #241/fix(tui): editor SSE and IDE lock-file ports parsed with bare parseInt — malformed values silently connect to the wrong port #246/docs: ROADMAP Done table omits the #244 and #250 completions (PRs #245, #251) #253/chore(deps-dev): bump storybook from 10.4.4 to 10.6.2 in /packages/storybook #255 there) fixed exactly this positional-parsing defect class in its own SSH stack; these two copies were not part of that set (checked: no equivalent parser in code/openchamber/nix — openchamber's only parseVersion is an unrelated semver comparator).

Acceptance criteria

  • Both parseVersion copies (ssh + wsl) ignore non-version lines: scan for a line whose trimmed content matches the accepted version shape already enforced by requireVersion (local or ^[0-9][a-zA-Z0-9.+-]*$, allowing the opencode v… / trailing- v… form the current lastIndexOf(" v") handles), instead of taking the first non-empty line.
  • WSL resolveCli likewise returns the discovered path line rather than the first line of login-shell output (e.g. the line that is an absolute path to an opencode binary).
  • New unit tests for both parsers covering: clean output, banner/MOTD line before the version, a banner line containing " v" (must not yield "3 loaded"), and empty output → null. No test file exists for either remote-cli.ts today, and no test references parseVersion/readCliVersion.
  • Clean-output behaviour is unchanged: "2.1.0" and "opencode v2.1.0" inputs return the same values as before.

Filed by new-issue-creator after verifying on main a7ea147ade (file:line reads, node repro of the exact parser logic, dedup searches for parseVersion / readCliVersion / remote-cli banner returned no issue).

Activity

  1. dezren39
    closed this as completedin #270on Oct 22, 2026
  2. dezren39
    added a commit that references this issue on Oct 22, 2026

    docs(roadmap): record the #265 and #269 completions in Done (#273) (#274

    6cc06c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.