fix(config): apply ssh.term to manual /ssh connections (#572) - #573
Merged
Conversation
`config.ssh.term` (`WEBSSH2_SSH_TERM`) was only honoured on auto-connect
routes. A plain `/ssh` page load received no `ssh.sshterm`, so the client
sent its own hard-coded `xterm-color`, and the socket path accepted it
without consulting the server default.
- connectionHandler: inject `{ ssh: { sshterm: config.ssh.term } }` on SSH
page loads (never host/port/credentials); session-supplied term still
wins; telnet routes unaffected. Session fragments without a term now
fall back to the configured default.
- ssh-config: `buildTerminalDefaults()` falls back to `config.ssh.term`
before the hard constant, so clients that omit `term` honour it too.
- docs: correct the `WEBSSH2_SSH_TERM` default (`xterm-256color`, not
`xterm-color`) and document precedence.
Behaviour change: deployments that never set `WEBSSH2_SSH_TERM` will see
manual `/ssh` sessions move from `xterm-color` to `xterm-256color`, which
aligns them with the auto-connect routes.
Fixes #572
Closed
4 tasks
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes #572 —
WEBSSH2_SSH_TERM/config.ssh.termwas only honoured on auto-connect routes (/ssh/host/…, POST, basic auth). A plain/sshload received nossh.sshterm, so the client sent its hard-codedxterm-color, and the socket path accepted it without consulting the server default.Changes
app/connectionHandler.ts— new purebuildTermConfig()injects{ ssh: { sshterm: config.ssh.term } }on SSH page loads. Only the terminal type is injected (never host/port/credentials). Composed beforebuildSshCredentials(), so a session fragment overwrites it;buildSshCredentials()now takes the default so a session with no term (e.g. invalid?sshterm=) still getsconfig.ssh.term. Telnet routes get nothing (telnet TERM isconfig.telnet.term).app/socket/adapters/ssh-config.ts—buildTerminalDefaults()falls back toconfig.ssh.termbeforeTERMINAL_DEFAULTS.DEFAULT_TERM, so clients that omittermhonour the operator default too.WEBSSH2_SSH_TERMdefault corrected toxterm-256color(was documented asxterm-color); precedence (?sshterm=>ssh.term) documented inURL-PARAMETERS.md.Precedence end-to-end: URL
?sshterm=/ session term →config.ssh.term→ client/server hard default.Deployments that never set
WEBSSH2_SSH_TERMwill see manual/sshsessions move fromxterm-color(client default) toxterm-256color(server default). Auto-connect routes already usedxterm-256color, so this aligns the two flows. Chosen over "inject only when explicitly configured" because the reporter's repro sets the value equal to the default, which that variant could not fix without provenance tracking.Testing
tests/unit/connection-handler/term-injection.vitest.ts— 7 cases: manual injection, empty term omitted, telnet omitted, session term wins, session-without-term falls back, nothing when both empty.tests/unit/socket/ssh-config-terminal-defaults.vitest.ts— 4 cases for the fallback chain.npm run lint(0 errors, warnings unchanged frommain),typecheck,test(1742 passed),buildall clean.WEBSSH2_SSH_TERM=xterm-256color,curl /ssh→"ssh":{"sshterm":"xterm-256color"};/telnet→ nosshfragment.No client change required — the client already prefers
cfg.ssh.sshtermover its default.