mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 07:32:54 +00:00
a8f9fd7a56f7dd02a2a8e762267dc2dccbfbb2de
129
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
afe959835d | Add SSH debug log setting | ||
|
|
1e94fe983f | Fix terminal wheel font zoom capture | ||
|
|
63b95bb68e | [codex] add terminal font size shortcuts | ||
|
|
ea41389842 | Fix Ruijie network device detection (#1168) | ||
|
|
03cd9bc968 | feat(snippets): implement snippet variable handling and UI prompts (#1159) | ||
|
|
1fec5925eb | Refactor large modules and fix runtime errors (#1136) | ||
|
|
7272f2564d |
fix(ssh): per-host skipEcdsaHostKey toggle + advanced algorithm overrides (#1027) (#1116)
* fix(ssh): per-host skipEcdsaHostKey toggle + advanced algorithm overrides (#1027) #1027 reported an old Huawei S7706 (SSH banner `SSH-2.0--`, empty software-version field) where the legacy-algorithms toggle still couldn't get a connection through. The debug log shows the handshake makes it through every negotiation step, picks `ecdsa-sha2-nistp521` for the host key, then dies at: Handshake failed: signature verification failed i.e. ssh2's strict RFC verifier rejects the ECDSA signature the switch produces. OpenSSH on the same machine connects because its known_hosts is already pinned to an RSA fingerprint, so it never advertises ECDSA in the first place. This adds two layers of escape hatch: A. `host.skipEcdsaHostKey` (one-click) — drops every `ecdsa-sha2-*` from the offered host-key list. Forces the fallback to ssh-rsa / ssh-dss / ssh-ed25519 that those old stacks implement correctly. Wired through ssh / sftp / port-forwarding bridges, inheritable from the group default. B. `host.algorithms` (advanced) — per-category override lists (`kex`, `cipher`, `hmac`, `serverHostKey`, `compress`). When a category's array is non-empty, it fully replaces the negotiated list for that category. Exposed in a collapsible "Advanced algorithm overrides" panel on both host and group settings, inspired by Tabby's per-profile algorithm UI. Empty arrays normalize to "use default" so picking zero algorithms in a category doesn't bench the connection with "no matching algorithm". Overrides apply BEFORE `skipEcdsaHostKey` so the latter stays an unconditional kill switch even if the user explicitly puts `ecdsa-*` back into the host-key list. Behavior with default values (neither toggle set, no override list) is identical to before — zero change for hosts that aren't opted in. Tests cover the new options on both `buildAlgorithms` and `buildSftpAlgorithms`, plus group→host inheritance for both fields. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ssh): address Codex review on #1116 — proper seed + jump-host carry + missing call sites Four review findings from the Codex pass on #1116, all real: 1. AlgorithmOverridesPanel was seeding the first customization in a category from `SUPPORTED_ALGORITHMS_BY_CATEGORY`, which contains legacy algorithms (CBC, arcfour, MD5, ssh-dss, group1-sha1...). Unchecking a single modern algorithm in a host that had legacy mode *off* would silently start offering those legacy algorithms. Now seeds from `effectiveDefaultAlgorithms(legacyEnabled)`, mirroring what `buildAlgorithms` actually emits at connect time. - New `effectiveDefaultAlgorithms` pure helper in `domain/sshAlgorithmList.ts` with its own test suite (also asserts the modern subset contains no SHA-1 KEX / CBC / arcfour / MD5) - `AlgorithmOverridesPanel` takes a `legacyEnabled` prop - `isChecked` now reflects the effective-default state for an untouched category, so unchecked rows visually represent algorithms the connection wouldn't currently advertise 2. The chain-mode jump-host loop in `sshBridge.cjs` was applying the target host's `skipEcdsaHostKey` / `algorithmOverrides` to every bastion hop, which is wrong when the bastion has its own settings. This was actually a pre-existing issue with `legacyAlgorithms` too — `NetcattyJumpHost` simply didn't carry any of these fields. - `NetcattyJumpHost` gains `legacyAlgorithms`, `skipEcdsaHostKey`, `algorithmOverrides` - `createTerminalSessionStarters` populates them from each jump host's own configuration - The jump-host bridge call now reads `jump.* ?? options.*` so a hop with its own setting wins, but unset hops still fall back to the target's settings (preserves historic chain-wide behavior when nothing is overridden) 3. `infrastructure/services/portForwardingService.ts` only forwarded `legacyAlgorithms` to the port-forwarding bridge, so a host that needed the ECDSA skip or advanced overrides could connect through the terminal but its auto-start tunnels would still hit the original handshake failure. - Forward `skipEcdsaHostKey` and `algorithmOverrides` at the target call site and at the jump-host map. 4. `application/state/sftp/useSftpHostCredentials.ts` built `NetcattySSHOptions` for `openSftp` without any of the algorithm fields — and on inspection it didn't even forward `legacyAlgorithms` to begin with, so SFTP panes for legacy-mode hosts were silently negotiating with the modern default list. Same gap at the jump-host map. - Forward all three fields at both the target and the jump-host map. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * polish(hosts): make the advanced-algorithm collapsible trigger a real button The first cut used a plain underlined caption for the "Advanced algorithm overrides" collapsible trigger. That blends into the surrounding helper text and doesn't read as an interactive control — users couldn't tell that the per-category checkbox editor was reachable at all. Match the project's existing collapsible-trigger pattern (see `SerialConnectModal`): full-width ghost Button, label on the left, ChevronDown / ChevronUp on the right that flips with open state, controlled via `useState`. Applied in both `HostDetailsPanel` and `GroupDetailsPanel`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * polish(hosts): rename Legacy Algorithms card to SSH Algorithms; split Backspace into its own section The card now carries three algorithm controls (Allow Legacy / Skip ECDSA / Advanced overrides) plus a Backspace Behavior dropdown that doesn't belong with the rest. Two cleanups: 1. Rename the card from "Legacy Algorithms" to "SSH Algorithms". The original title only described the first toggle; the section now covers the whole algorithm-negotiation surface, including the ECDSA host-key skip and the per-category override editor. - i18n key renamed `hostDetails.section.legacyAlgorithms` -> `hostDetails.section.sshAlgorithms` in zh-CN / en / ru - `HostDetailsPanel` references the new key 2. Move the Backspace Behavior control out of the algorithm card. - `HostDetailsPanel`: new dedicated "Terminal Behavior" card (TerminalSquare icon) placed between SSH Algorithms and Keepalive. New i18n key `hostDetails.section.terminalBehavior`. - `GroupDetailsPanel`: no separate Card scaffolding for group defaults — moved Backspace to the bottom of the SSH section (after Mosh) so it visually separates from the algorithm block above without introducing a new card heading. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(sftp): per-hop algorithm settings in SFTP chain (Codex review on #1116) `sshBridge.cjs`'s jump loop already reads `jump.* ?? options.*` for the three algorithm fields, but `sftpBridge.cjs#connectThroughChainForSftp` was missed in that change and still applied the target host's `options.legacyAlgorithms` / `skipEcdsaHostKey` / `algorithmOverrides` to every bastion. A bastion that needed the ECDSA skip or a custom algorithm list while the target didn't would still fail the SFTP handshake before reaching the target. Mirror the sshBridge fix: read each setting from the jump host first, falling back to the target options when the hop didn't override. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ssh): keychain SSH exec + advanced editor seed honor inherited algorithm settings Two findings from a local Codex review pass on the branch: 1. The keychain "export public key to host" flow opens its own one-off SSH connection through `sshBridge#execCommand`, but the connectOpts built there didn't include any `algorithms`. ssh2 then negotiated with its built-in modern defaults regardless of what the host had set, so a host that needs the ECDSA skip (or legacy mode) would connect in the terminal but the keychain export would fail with the original signature-verification error. - `sshBridge.cjs#execCommand` now sets `algorithms` from `payload.legacyAlgorithms` / `skipEcdsaHostKey` / `algorithmOverrides`, mirroring `startSSHSession`. - `useKeychainBackend`'s `execCommand` typing gets the three new optional fields. - `KeychainManager` forwards the host's `legacyAlgorithms`, `skipEcdsaHostKey`, and `algorithms` when invoking the export. 2. The Advanced Algorithm Overrides editor seeded its first customization from `form.legacyAlgorithms`, which is the host's own field — it doesn't reflect a value the host *inherits* from its group's default. A user in a group with `legacyAlgorithms=true` editing a host that hadn't explicitly set the flag would see the editor seed in modern-only mode, and saving could silently drop the legacy algorithms the host actually needed. - `HostDetailsPanel` passes `form.legacyAlgorithms ?? groupDefaults?.legacyAlgorithms`. - `GroupDetailsPanel` adds an `inheritedLegacyAlgorithms` memo resolved from the parent group chain via `resolveGroupDefaults`, and the editor uses `form.legacyAlgorithms ?? inheritedLegacyAlgorithms`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(keychain): export-public-key honors group-inherited algorithm settings Second-pass Codex review on PR #1116 flagged that the keychain "export public key to host" flow now carries the three algorithm fields end-to-end, but only reads them from `exportHost.*` directly — which doesn't reflect values the host inherits from its group's defaults. A host that left `legacyAlgorithms` / `skipEcdsaHostKey` / `algorithms` unset but sat inside a group that turned them on would work fine in the terminal (the terminal starter applies group defaults before sending the IPC payload) but its keychain export would silently fall back to ssh2's modern defaults and hit the original signature-verification failure. Resolve the effective host with `applyGroupDefaults` + `resolveGroupDefaults` before the `execCommand` call, then read the algorithm fields off the effective host. Requires plumbing `groupConfigs` into `KeychainManager` (added as an optional prop, forwarded by `VaultView`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(host-details): algorithm-overrides editor reads currently selected group's defaults Third-pass Codex review caught that the editor seed was reading from the `groupDefaults` prop, which is whatever group the host belonged to when the panel opened. If a user switched the host into a different group inside the panel and then opened the Advanced Algorithm Overrides collapsible before saving, the editor would seed from the old group's `legacyAlgorithms` flag and could save the wrong list. The panel already memoizes `effectiveGroupDefaults` from `form.group`/`defaultGroup`/`groupConfigs` for exactly this kind of re-resolution (used by theme/font effective lookups). Read the inherited flag from there instead of the stale prop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(algorithms): trim UI cipher list to algorithms ssh2 actually supports Fourth-pass Codex review flagged that `SUPPORTED_CIPHER_ALGORITHMS` included `blowfish-cbc`, `cast128-cbc`, and the `arcfour*` family, but OpenSSL 3 disabled those primitives, so ssh2's `canUseCipher` filter drops them from `SUPPORTED_CIPHER` at startup. Selecting any of them in the Advanced Algorithm Overrides editor would make `ssh2.Client.connect()` throw `Unsupported algorithm` synchronously, turning the override into a "host now unreachable" footgun instead of a narrowing knob. Realigned each `SUPPORTED_*_ALGORITHMS` list to ssh2's actual `SUPPORTED_*` constants: - `SUPPORTED_CIPHER_ALGORITHMS`: dropped blowfish / cast128 / arcfour; added the no-suffix `aes128-gcm` / `aes256-gcm` variants ssh2 also accepts. - `SUPPORTED_KEX_ALGORITHMS`: added `diffie-hellman-group15-sha512` and `diffie-hellman-group17-sha512` (present in ssh2 but missing from the UI list); reordered to ssh2's canonical order. - `SUPPORTED_HMAC_ALGORITHMS`: reordered so the ETM/SHA-2 grouping matches ssh2's `DEFAULT_MAC` and lookups are predictable. Locked the invariant in `sshAlgorithmList.test.ts` with a new test that asserts every UI-offered algorithm is a member of ssh2's `SUPPORTED_*` for its category. A future ssh2 bump that drops an algorithm we still expose will fail this test instead of silently becoming a connect-time error for users. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(algorithms): run KEX override through the runtime fixed-DH filter Codex round-N flagged a gap in `applyAlgorithmOverrides`: when the user supplies a custom KEX list via the advanced editor, the previous implementation copied it verbatim into the negotiated `algorithms.kex` field. The default builder already passes its KEX list through `filterSupportedFixedDhKex` to drop fixed-DH groups the runtime doesn't support (notably `diffie-hellman-group1-sha1` on Electron/BoringSSL, which lacks modp2), but the override path bypassed that filter — so an Electron user enabling legacy mode and saving any KEX checkbox state would re-advertise group1-sha1 and the handshake would crash with "Unknown DH group" instead of failing fast. Apply the same `filterSupportedFixedDhKex` to the override list. New test in `sshAlgorithms.test.cjs` exercises a simulated BoringSSL runtime that lacks modp2 and asserts the override-filtered KEX no longer includes group1-sha1, while group14-sha1 / group-exchange-sha1 remain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(algorithms): run HMAC override through the FIPS MD5 filter Codex flagged the same runtime-bypass pattern Round-N-1 fixed for KEX, now in HMAC: `applyLegacyHmacAlgorithms` gates `hmac-md5` behind `md5Supported()` so FIPS Node builds don't get it, but the UI's `effectiveDefaultAlgorithms(true)` seed adds `hmac-md5` / `hmac-md5-96` unconditionally. A user with legacy mode on who saves any HMAC checkbox change would push those MD5 entries through `applyAlgorithmOverrides`, which previously copied the override verbatim — bypassing the FIPS gate and making ssh2 throw "Unsupported algorithm" before negotiation. New `filterRuntimeUnsupportedHmac` helper applies the same `md5Supported()` gate to a user override. `applyAlgorithmOverrides` routes the HMAC override through it (mirrors how the same function already routes KEX overrides through `filterSupportedFixedDhKex`). New test simulates a FIPS-disabled MD5 runtime and asserts MD5 variants drop from the final HMAC list while SHA-1 / SHA-2 entries remain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ssh): jump-host overrides no longer inherit the leaf's algorithm overrides Codex flagged that the jump-loop fallback I added for chain convenience applied the target's per-host \`algorithmOverrides\` to every bastion whose own override wasn't set, which is wrong: a target restricted to e.g. \`serverHostKey: [\"ssh-rsa\"]\` would lock the hop to ssh-rsa too and break negotiation against an Ed25519-only bastion. The fallback IS still correct for \`legacyAlgorithms\` and \`skipEcdsaHostKey\` — those are append/safety toggles that widen the offered list, so propagating them to a bastion is safe and matches the historic chain-wide behavior of \`options.legacyAlgorithms\` (single-toggle convenience for a chain with one old leaf). Treat \`algorithmOverrides\` strictly per-host instead. Same change in both \`sshBridge.cjs\` and \`sftpBridge.cjs\` jump loops, with a comment block explaining the asymmetry so a future refactor doesn't "clean up" the distinction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ui(host-details): surface inherited algorithm overrides in the advanced editor Codex flagged a real gap in the inheritance model: when a parent group has set algorithm overrides (e.g. \`algorithms.kex: [...]\`), a host or child group under it can't simply Reset a category back to NetCatty's defaults — \`applyGroupDefaults\` treats an unset host field as "inherit", so the local Reset falls back to the group's list rather than to ssh2's defaults. Cleanly distinguishing "reset to NetCatty defaults" from "inherit from group" needs a new schema field or sentinel, which is a non-trivial design change well beyond the scope of this PR. For now, surface the situation in the UI so the user understands why Reset doesn't behave the way they might expect and where to go to actually clear the restriction: - \`AlgorithmOverridesPanel\` accepts an optional \`inheritedFromGroup\` prop and, when populated, renders a blue inline notice listing the inherited categories and directing the user to the group's algorithm settings if they need to opt out. - \`HostDetailsPanel\` passes \`effectiveGroupDefaults?.algorithms\`. - \`GroupDetailsPanel\` adds a new \`inheritedAlgorithmOverrides\` memo that resolves the same way the existing \`inheritedLegacyAlgorithms\` does, and forwards it. - i18n strings added in zh-CN / en / ru. Follow-up (out of scope for this PR): if real users do hit this, introduce a \`host.algorithms = null\` (or explicit \`algorithmsOverride: boolean\`) sentinel and a Reset-to-defaults button that uses it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ssh): jump-host skipEcdsaHostKey is per-host; panel seeds from inherited overrides Three findings from the latest Codex pass: 1 & 2. `skipEcdsaHostKey` on the leaf was still falling back onto jump hosts in both `sshBridge.cjs` and `sftpBridge.cjs`. I had classified it with `legacyAlgorithms` as a "safety widening" knob, but Codex is right that it actually *narrows* the offered host-key list by dropping every `ecdsa-sha2-*`. An ECDSA-only bastion (or one where the operator pinned ECDSA via known_hosts) would still negotiate when ECDSA is offered, but fails when the leaf's skip is propagated to it. Same fix as `algorithmOverrides` last round: strictly per-host. Only `legacyAlgorithms` keeps the chain-wide fallback (append-only — it widens the offer, can never break a hop that wasn't already failing). 3. `AlgorithmOverridesPanel` was seeding the first customization of a category from the NetCatty/legacy effective default, ignoring any list the host inherits from its group for OTHER categories. Because `applyGroupDefaults` treats `host.algorithms` as an all-or-nothing inherit boundary, the moment the user saved any host-local override `{ cipher: [...] }`, the group's `{ serverHostKey: ["ssh-rsa"] }` restriction silently dropped from the effective host. Now: - `toggleAlgorithm`'s first-click seed reads `inheritedFromGroup?.[category] ?? effectiveDefault[category]`, so customizing one category preserves the group's narrowing on the others. - `updateCategory` initializes `next` from `{ ...inheritedFromGroup, ...value }` so saved overrides carry the inherited categories alongside the host's own edits. - `isChecked` reflects the inherited list when there's no local value, so the visible checkbox state matches what would actually be advertised. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(host-details): Reset preserves the inherited list instead of silently widening Codex caught a follow-on bug from the previous "carry inheritance" fix: pressing Reset on a category that's inherited from the group deleted that category from \`host.algorithms\` while other host-local or carried-inherited categories remained. Because \`applyGroupDefaults\` treats \`host.algorithms\` as all-or-nothing, the moment any host-local entry exists the group's \`algorithms\` object stops being inherited as a whole — so the freshly-deleted category fell back to NetCatty defaults rather than the group's narrower list. Effective result: Reset on an inherited category *widened* the offer instead of restoring it. Reset now persists the inherited list verbatim onto the host when the group has an override for that category, so "Reset" means "use what this host would otherwise inherit" in all cases. Also tightened \`isCustomized\` to suppress the "customized" badge (and the per-category Reset button) when the host's stored list is identical to the inherited list — those rows haven't really been customized by the user. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ui(host-details): gate the inherited-notice / checkbox baseline on no host override Codex caught the asymmetry between the read and write sides of the panel. The write side (`updateCategory`, `toggleAlgorithm`, Reset) intentionally carries `inheritedFromGroup` onto the host on the first edit so the runtime's all-or-nothing inherit boundary in `applyGroupDefaults` doesn't silently widen the offer. But the read side (the inherited-notice banner and the `isChecked` baseline for unfilled categories) was applying inherited values *unconditionally* — including when the host already had any local `algorithms` object, which makes `applyGroupDefaults` stop inheriting from the group as a whole. Net effect on a host that only locally overrode `cipher`: the UI claimed the group's `serverHostKey` restriction was still in effect, while the runtime would actually use NetCatty's modern defaults for that category. Introduce `inheritedForDisplay`, defined as `value === undefined ? inheritedFromGroup : undefined`, and route the notice + the `isChecked` baseline through it. The write side keeps consulting the unconditional `inheritedFromGroup` so the carry-over still happens on first edit — that part is what makes the runtime behavior match what the UI used to advertise. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ui(host-details): legacy/skipEcdsa toggles reflect group-inherited value Codex caught that the Skip ECDSA toggle in both the host and group panels read `form.skipEcdsaHostKey` directly, so a host whose group turned the flag on (and `applyGroupDefaults` therefore applied it to the runtime SSH negotiation) still saw the toggle rendered as off. Worse, clicking it computed `!form.skipEcdsaHostKey` — which is `!undefined` = `true` — so the first click could not actually disable the inherited setting on a per-host basis; it would just store `true` explicitly, the same effective state. The Allow Legacy Algorithms toggle had the same pre-existing issue. Fix both at once: each toggle now derives its enabled state from `form.<field> ?? <inherited>` and the onToggle handler flips that same effective value, so the toggle accurately represents what the runtime would do and a single click off correctly stores `false` (which `applyGroupDefaults` then leaves alone, breaking inheritance for this host). - `HostDetailsPanel` reads from `effectiveGroupDefaults`. - `GroupDetailsPanel` adds an `inheritedSkipEcdsaHostKey` memo alongside the existing `inheritedLegacyAlgorithms` and uses both. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
67448cea65 |
feat(terminal): configurable startup-command delay + multi-line sequencing (#1096)
* feat(terminal): add global startupCommandDelayMs setting Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(terminal): add startup-command line-split and delay-clamp helpers Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(terminal): run multi-line startup commands in sequence with configurable delay Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(terminal): expose startup command delay in Terminal settings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(terminal): keep startup-command line content verbatim splitStartupCommandLines now only drops blank/whitespace-only lines and normalizes CRLF, but no longer trims each line's content. This keeps a single-line startup command byte-identical to what the user typed (e.g. a leading space for HISTCONTROL=ignorespace is preserved), while still supporting multi-line sequencing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(sync): include startupCommandDelayMs in synced terminal settings Terminal settings sync via the SYNCABLE_TERMINAL_KEYS allowlist; the new startupCommandDelayMs preference was missing, so it wouldn't propagate across devices. Add it (it's a user preference like keepaliveInterval, not device-specific). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|
|
453202df8f | perf(terminal): add output flow control / back-pressure for heavy streams (#1090) | ||
|
|
bf1c95500a |
feat #826: optional Option+←/→ word jump on macOS (#1082)
* feat #826: optional Option+←/→ word jump on macOS Adds a Terminal → Keyboard toggle "Option+←/→ jumps by word" (off by default, synced). When on, a bare Option+Left/Right sends Meta-b / Meta-f instead of xterm's default ^[[1;3D / ^[[1;3C, so readline/zle moves by word without per-host bindkey setup (Termius-style). The key→sequence mapping is a tested pure function; the handler reads the setting live (no reconnect) and runs after kitty mode + autocomplete so it doesn't override them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix #826: gate Option+←/→ word jump to macOS The setting is syncable, so without a platform gate, enabling it on a Mac would also rewrite Alt+←/→ to Meta-b/f on synced Linux/Windows devices, breaking apps/shells that expect the default ^[[1;3D / ^[[1;3C. Pass isMacPlatform() into the mapping so it only applies on macOS; add a test for the non-macOS case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
8fd7ff6475 |
fix #1078: send macOS Option as Meta (wire altAsMeta to xterm macOptionIsMeta) (#1080)
"Use Option as Meta key" was read into `altIsMeta` but only applied to the mouse alt-click options (`altClickMovesCursor`). xterm.js's `macOptionIsMeta` — the option that actually makes Option emit ESC-prefixed (Meta) sequences — was never set, so on macOS Option kept producing layout characters (ƒ, ∫, …) and readline/zle word shortcuts (Alt+f, Alt+b, Alt+Backspace) were dead. Extract the altAsMeta→xterm mapping into one tested helper used by both the terminal init path (createXTermRuntime) and the live settings sync (Terminal.tsx) so the two can't drift again. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
bf0bd193eb |
fix #1049: clear WebGL texture atlas to recover from garbled terminal (#1050)
Heavy full-screen TUIs (claude code / gemini cli / opencode), font changes, and device pixel ratio changes can leave xterm.js's WebGL glyph texture atlas in a corrupted state that persists for the life of the terminal — users see persistent "garbled / 花屏" output that only clears when a brand-new terminal is opened (most often on Windows with display scaling / multi-monitor setups). Clear the texture atlas so glyphs re-rasterize at the correct scale instead of forcing users to reopen the terminal: - Add watchDevicePixelRatio() helper (TDD, unit-tested) that re-registers a matchMedia listener across DPI changes and fires a repair callback. - Wire it into createXTermRuntime: on devicePixelRatio change, clear the atlas and refit; also clear the atlas on reflow (term.onResize). Watcher is torn down on dispose. - Expose clearTextureAtlas() on XTermRuntime and call it after font changes in Terminal.tsx (xterm.js #3280). All calls are no-ops under the DOM renderer. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
6084e8e94f |
fix(terminal): handle forced prompt newline (#1025)
* fix(terminal): handle forced prompt newline * fix review issue * fix(terminal): harden prompt newline handling --------- Co-authored-by: yuzifu <yuzifu@TB16PGen5.Info> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> |
||
|
|
88a322a03b |
[codex] Filter terminal cursor replies from broadcast input (#1022)
* Filter terminal CPR from broadcast input * Handle split cursor reports in broadcast |
||
|
|
3e8965f9a9 | Fix pr987 (#1010) | ||
|
|
88732040aa |
fix(terminal): separate prompt after unterminated command output (#987)
* fix(terminal): separate prompt after unterminated command output Add a display-layer prompt line break handler so recognized shell prompts move to the next visual line when the final command output line is not newline terminated. Also add a terminal setting to toggle the behavior, sync support, i18n copy, and focused tests for prompt insertion. * fix review issue * Fix prompt cache initialization * Serialize terminal output writes for prompt breaks * Keep terminal status lines ordered with output * Fix prompt arming without command callback * Keep prompt display breaks out of session logs * Avoid prompt breaks for output suffix matches --------- Co-authored-by: yuzifu <yuzifu@TB16PGen5.Info> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> |
||
|
|
ff6b4a4625 |
Broadcast pasted terminal input (#927) (#996)
* Broadcast user paste to terminals * Use workspace session id for context paste broadcast * Consume paste broadcast suppression before toggle check |
||
|
|
fb9400a5fb |
fix #984: After running the clear command, the inline session log will be cleared (#990)
Co-authored-by: yuzifu <yuzifu@TB16PGen5.Info> |
||
|
|
84416d04bf |
[codex] Fix issue 957 long paste display (#959)
* Fix long paste display artifacts * Fix serial line mode pasted chunks * Narrow long paste display cleanup scope * Strip only matched paste echo highlights * Honor paste scroll setting through xterm paste |
||
|
|
92ecd84edf |
Fix #939: per-host SSH keepalive override + cloud-friendly defaults (#947)
* fix(ssh): per-host keepalive override + cloud-friendly defaults (#939, #581)
Issues #939 (cloud / Aliyun sessions silently freezing after 15-20 min idle
because no SSH keepalive packets are sent) and #581 (older routers like
NOKIA / ALCATEL being killed by ssh2 after a few unanswered keepalives) are
in direct tension at the global-setting level: cloud users want keepalive
ON, embedded-device users want it OFF, and any single global default hurts
the other group.
Resolves the conflict by moving keepalive to a per-host setting (mirroring
the existing `legacyAlgorithms` per-host pattern), with cloud-friendly
global defaults:
Domain:
- Host gains `keepaliveOverride?: boolean` + `keepaliveInterval?: number`
+ `keepaliveCountMax?: number`. When override is true, the host's
values are used; otherwise the global TerminalSettings values apply.
Per-field fallback so a host can override interval only or countMax only.
- TerminalSettings gains `keepaliveCountMax: number` so the second knob
(number of unanswered keepalives before declaring dead) is no longer
hardcoded at 3 in the bridge.
- DEFAULT_TERMINAL_SETTINGS: keepaliveInterval bumped from 0 to 30, and
keepaliveCountMax = 10. Cloud LBs / NAT tables stay populated; brief
network glitches don't trip the dead-connection check; an actually
dead session is detected within ~5 minutes. Existing users with 0
saved keep their value (no migration) — they were the #581 router
cohort and their setup still works untouched.
Plumbing:
- domain/host.ts adds resolveHostKeepalive(host, globalSettings) with
five unit tests covering both directions of the override flag and
per-field fallback.
- components/terminal/runtime/createTerminalSessionStarters.ts uses the
resolver when building startSSHSession options.
- electron/bridges/sshBridge.cjs reads keepaliveCountMax from options
(defaulting to 10) at both connection sites (direct + jump host) and
still routes interval=0 through to a fully disabled keepalive
(preserving #581's escape hatch).
UI:
- Settings → Terminal → Connection grows a second input next to the
existing interval: "Max unanswered keepalives".
- Host details panel gains a Keepalive section with a "Override global
keepalive" toggle that, when on, exposes per-host interval +
countMax inputs and an inline hint when interval = 0 (explaining
the implications). Same visual pattern as the existing Legacy
Algorithms section.
Sync:
- keepaliveCountMax added to SYNCABLE_TERMINAL_KEYS so the new global
field rides existing sync infrastructure. Per-host fields ride the
hosts array passthrough automatically (older clients receiving them
ignore unknown fields, per the existing lenient sync contract).
i18n: en + zh-CN strings for the new settings row, the host section
header, and the override toggle / inputs / disabled hint.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(ssh): resolve keepalive per jump host, not just the final target
Addresses codex review on PR #947:
https://github.com/binaricat/Netcatty/pull/947#discussion_r3217027xxx
The first cut only resolved keepalive for the final target host and
forwarded a single interval/countMax pair across the whole start-SSH
call. connectThroughChain in sshBridge.cjs then applied that one pair
to every hop, so a chain like:
router (bastion, needs keepalive=0) → cloud target (needs 30s)
would either kill the router (with cloud-friendly defaults) or fail
to keep the target alive (with router-friendly 0). The per-host
override was effectively useless for bastion hosts.
Fix:
- NetcattyJumpHost gains optional keepaliveInterval / keepaliveCountMax.
- createTerminalSessionStarters runs resolveHostKeepalive() per
jumpHost when building the chain, so each hop carries its own
resolved pair.
- sshBridge.cjs's chain connector reads jump.keepaliveInterval /
jump.keepaliveCountMax for each hop, falling back to the call's
target-level options for backward compatibility with older
serializers that don't yet populate the per-hop fields.
The final target's keepalive path is unchanged — it still reads
options.keepaliveInterval / options.keepaliveCountMax that the
session starter resolves from the target host.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(ssh): per-host keepalive for SFTP + port forwarding too
Follow-up to the maintainer review on PR #947 — terminal SSH was the
only path that honored per-host keepalive overrides. SFTP and port
forwarding share the same NetcattyJumpHost type but their builders
weren't resolving keepalive per-hop, and their bridges hardcoded the
old 10s/3 defaults. Net result: a router-as-bastion in a chain still
got killed when reached via the SFTP file panel or a port-forwarding
tunnel, even though the user had toggled per-host override.
Plumbing:
- useSftpHostCredentials / buildSftpHostCredentials: accept optional
terminalSettings; call resolveHostKeepalive() for the target and
each jump entry; emit keepaliveInterval / keepaliveCountMax in the
returned NetcattySSHOptions.
- useSftpConnections + useSftpState + SftpStateOptions thread the
setting down. SftpSidePanel passes the global terminalSettings prop
it already has from TerminalLayer.
- portForwardingService.startPortForward: accepts terminalSettings
as an 8th argument, resolves per-host (target + each jump), and
populates the bridge payload.
- usePortForwardingState.startTunnel and usePortForwardingAutoStart
forward the new parameter; App.tsx supplies terminalSettings (via
a ref in the once-on-launch auto-start effect so changing global
keepalive later doesn't re-fire it).
Bridges:
- sftpBridge.cjs target connect: now also reads keepaliveCountMax
from options (was hardcoded 3). 10s/3 stays as the bridge-level
fallback to preserve the #669 protection when the renderer hasn't
supplied a value.
- sftpBridge.cjs jump hop: reads jump.keepaliveInterval /
jump.keepaliveCountMax, then falls back to the target-call options
(matches the symmetric SSH bridge change).
- portForwardingBridge.cjs: reads keepaliveInterval /
keepaliveCountMax from the IPC payload; same 10s/3 fallback.
Types:
- NetcattyJumpHost already grew keepalive fields earlier; this
commit also adds them to PortForwardOptions so the IPC contract
is explicit.
End-to-end: a chain `[router-as-bastion, cloud-host]` with the
router host's keepaliveOverride=true / interval=0 now correctly
disables keepalive on the router hop for terminal SSH AND SFTP AND
port forwarding, while the cloud target still gets the resolved
30s/10 default for each path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(ssh): honor explicit keepalive=0 in SFTP + port forwarding bridges
Addresses codex review on PR #947:
- https://github.com/binaricat/Netcatty/pull/947#discussion_r3217448xxx
- https://github.com/binaricat/Netcatty/pull/947#discussion_r3217449xxx
The previous follow-up commit (
|
||
|
|
478e148b40 |
Drop noisy [XTerm] renderer=... boot log
The line printed once per terminal session and offered no diagnostic value beyond what window.__xtermRenderer already exposes for ad-hoc introspection. Keep the detection + retry + window publish; just stop polluting the console. Rename logRenderer → trackRenderer to match the now-narrowed responsibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
bce33f34ee | Fix SSH known host verification | ||
|
|
b6c59b9683 |
Merge pull request #924 from bet4it/shift-enter-support
Support Shift+Enter |
||
|
|
ff6b75aba7 | Harden Shift+Enter keyboard support | ||
|
|
2329014e22 | fix: harden SSH key passphrase flows | ||
|
|
5c5ab21b10 | support Shift+Enter | ||
|
|
f1cfce45cf | feat: Enhance SSH key management with reference key support and UI updates | ||
|
|
eb1fd9c127 | Harden Telnet auto-login | ||
|
|
b9ac14f497 | Improve Telnet credential login | ||
|
|
3efc9ada8e |
Fix Windows mosh startup
Fix Windows mosh startup |
||
|
|
72e305fb7a | Add reusable proxy profiles | ||
|
|
8ccefc821c |
[codex] Use dedicated mosh binary repository (#881)
* Use dedicated mosh binary repository * Require bundled mosh client * Auto-fill saved password for mosh SSH handshake * Harden bundled mosh binary flow |
||
|
|
d86c5ed05a |
[codex] Remove mosh client path setting (#878)
* fix(terminal): remove mosh client path setting * fix(terminal): remove stale mosh detection bridge |
||
|
|
a4a5c703b1 | Fix terminal cursor preference handling | ||
|
|
74d56cdcb8 |
[codex] Settings: detect & override mosh client path (#849)
* Add Mosh client detection and override in Settings → Terminal Builds on PR #847 (auto-detection across PATH gaps). Power users with non-standard install locations (containers, custom builds, multiple mosh versions) can now point the app at a specific mosh binary; less technical users get a one-click "Detect" button to confirm where mosh was found, with a Browse fallback for clicker-only flows. Backend (electron/bridges/terminalBridge.cjs): - detectMoshClient() returns { platform, found, path, searchedPaths }. Reuses resolvePosixExecutable; surfaces the searched dirs so the UI can tell users where to look when nothing was found. - pickMoshClient() opens a native file picker via dialog.showOpenDialog. - startMoshSession honors options.moshClientPath when provided. Strict failure: a missing/non-executable explicit path produces a clear error instead of falling back to auto-detect, so users notice typos and stale paths instead of getting silent recovery. UI (components/settings/tabs/SettingsTerminalTab.tsx): - New SettingRow under "Connection" with text input + Detect + Browse buttons, mirroring the localShell validation pattern. Shows inline validation (notFound/isDirectory) and the last detect result with searched directories on miss. Plumbing: - TerminalSettings.moshClientPath: string field with default "" so empty == auto-detect (matches existing PR #847 semantics). - preload exposes detectMoshClient + pickMoshClient. - createTerminalSessionStarters passes terminalSettings.moshClientPath into the IPC call, undefined when blank. - en.ts / zh-CN.ts get the 9 new strings. Verified locally: - vite build succeeds; settings tab renders. - detectMoshClient() against the live machine returns /opt/homebrew/bin/mosh with the expected searchedPaths list. - Existing PR #847 auto-detection path is unchanged when the field is empty. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Skip POSIX execute-bit check for explicit Windows mosh path Address Codex P2 on PR #849 commit |
||
|
|
08e566adb0 |
[codex] Add X11 forwarding support (#835)
* Add X11 forwarding support * Address X11 forwarding review feedback * Handle X11 auth for unix socket display paths * Tighten X11 forwarding compatibility handling |
||
|
|
c58f018d24 |
fix(terminal): preserve selection when typing Space or uppercase letters (closes #819) (#820)
PR #763 captured and restored the mouse selection in a keydown-only microtask. That covers lowercase letters — xterm's _keyDown calls triggerDataEvent synchronously, so the selection is cleared before the microtask drains and the restore runs. Space (keyCode 32) and A–Z (the _keyDown macOS-IME HACK) are instead routed through the keypress event, which fires in a *later* macrotask. The keydown microtask drains first, sees the selection still intact, and no-ops. Then keypress clears it without any restore. Fix: hook both keydown and keypress in attachCustomKeyEventHandler. The keypress path gives us a second microtask that drains after _keyPress has cleared the selection, so the restore actually runs for those keys. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
9bf4aed44f |
fix(autocomplete): stop prepending theme cwd ("~ ") to completed commands (closes #806) (#814)
* fix(autocomplete): honor typed keystrokes when the prompt parser over-captures Closes #806. ## Root cause findPromptBoundary stops at the first "PROMPT_CHAR + space" it sees on the current line. Themes that render additional content after the prompt char — most notably oh-my-zsh robbyrussell's "➜ ~ " where "~" is the cwd — trip it: promptText becomes "➜ ", userInput becomes "~ sudo id". Every consumer downstream treats the theme's cwd marker as part of the user's command, so: 1. recordCommand logs entries like "~ sudo id" into history. 2. fuzzyQueryHistory later returns those polluted entries as suggestions. 3. When the user hits Tab, insertSuggestion compares suggestion.text ("~ ls") against userInput ("~ lo"), falls into the Ctrl-U-plus-rewrite path, and the phantom "~ " ends up on the real command line. The reporter hit this right after `sudo` because sudo's password interaction gave history enough polluted entries to start winning fuzzy matches; without sudo the popup stays empty so the Ctrl-U rewrite path never fires and the bug is invisible. ## Fix Track what the user actually typed in an independent keystroke buffer (typedInputBufferRef) inside the autocomplete hook: - Append every printable char / paste chunk. - Pop on backspace, word-kill on Ctrl+W. - Clear on Enter, Ctrl+C, Ctrl+U, and any escape sequence / unhandled control char (cursor moves we can't follow invalidate the buffer). Introduce reconcilePromptWithTypedInput: if detectPrompt's userInput ends with the typed buffer and is longer, the parser over-captured — move the excess back to promptText so userInput matches what was actually typed. Apply at every detectPrompt call site (fetchSuggestions, the stale-result recheck, insertSuggestion). For Enter-record the typed buffer wins outright when present, but only after a live detectPrompt confirms we're at a shell prompt — otherwise a password-entry Enter would log the password as a command. insertSuggestion / ghost-text accept update the typed buffer to the accepted text so a subsequent Enter records the right command. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): track keystroke-buffer reliability, skip it after cursor moves Codex flagged (#814 P1) that clearing typedInputBufferRef on escape / control sequences and then re-appending printable keys leaves the buffer holding only the post-navigation suffix of the real line. A classic Up-arrow-recall workflow — ↑ to pull "git commit -m fix" out of history, append one char, Enter — would record just that one char as the command, polluting history and skewing future fuzzy matches. Add typedBufferReliableRef as a companion flag: - Reset (reliable=true) on Enter / Ctrl-C / Ctrl-U (zle wipes the line, our buffer is a true view of the empty line again). - Also reset by insertSuggestion and ghost-text right-arrow accept once they write the full accepted text and we re-align the buffer to it. - Cleared (reliable=false) when any escape sequence, unhandled control char (Ctrl-P / Ctrl-N / Ctrl-R / Ctrl-A / Ctrl-E / ...) arrives — those can move the cursor or swap the zle line in ways an append-only buffer can't follow. All four call sites now gate on the flag: - reconcilePromptWithTypedInput receives the buffer only when reliable, so an unreliable buffer never trims the detector's userInput (avoids a symmetric flavor of the original bug where the detector is right and the buffer is wrong). - Enter-record prefers the buffer only when reliable; otherwise it falls straight through to detectPrompt. - The Ctrl+Right (next-word ghost accept) append is skipped when unreliable so we don't seed the buffer with just that word. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): resync typed buffer when sub-dir select rewrites the line Codex flagged (#814 P2) that handleSubDirSelect rewrites the command line via writeToTerminal(Ctrl-U + cmdPrefix + fullPath) but never touches typedInputBufferRef. After the rewrite the buffer still holds whatever was typed before, so pressing Enter records that stale partial input as the executed command — polluting history and steering later suggestions off course. Same commit also routes handleSubDirSelect through reconcilePromptWithTypedInput. The raw detectPrompt would include the robbyrussell "~ " cwd marker in the command prefix it reconstructs, which is the original symmetric #806 bug leaking into this path too. After the rewrite, set the buffer to the newly written command string and flip reliability back on — the terminal line content now matches it exactly, so the next Enter-record does the right thing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): reset typed buffer when a paste chunk carries a newline Codex flagged (#814 P2) that multi-character paste payloads skip the top-of-handleInput Enter guard (which compares data === "\r" exactly), so a paste like "cmd\r" goes through the paste branch and the "\r" gets appended to typedInputBufferRef verbatim. The shell executes "cmd", but our buffer is left holding "cmd\r...", still marked reliable. The next Enter then records whatever combined stale string lives there. Detect line terminators inside multi-char paste chunks: slice from the last \r or \n onward and keep only that tail as the new buffer content (and flip reliability back on, since the tail now matches the shell's zle line). Skip synthesizing recordCommand entries for the flushed intermediate lines — onCommandExecuted in createXTermRuntime already tracks pasted multi-line input independently, so duplicating the logic here would risk double-counting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): clear lastAcceptedCommandRef on paste-with-newline early return Codex flagged (#814 P2) that the multi-line-paste branch clears the keystroke buffer and bails out before the rest of handleInput runs — including the line that resets lastAcceptedCommandRef. If the user had just accepted a suggestion (Tab / → / popup click), the embedded newline still flushes it in the shell, but our fast-path cache keeps holding it. The next Enter then takes the lastAcceptedCommandRef shortcut and logs that old suggestion as the executed command, polluting history with something the user didn't actually run. Null lastAcceptedCommandRef.current at the same point we reset the typed buffer so the fast path stays aligned with the shell. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): require typed buffer to align with live line before recording Codex flagged (#814 P1) that paste paths which bypass handleInput — the createXTermRuntime hotkey / context-menu / middle-click handlers all call writeToSession(...) directly — leave typedInputBufferRef stale while still marked reliable. A "type prefix → paste remainder → Enter" flow would then record just the keyboard-typed prefix, feeding garbage back into autocomplete ranking. Require alignment: livePrompt.userInput must end with the typed buffer before we trust it. reconcilePromptWithTypedInput already snaps the two together when they *are* aligned — if its endsWith check fails, the buffer is stale (or mid-navigation) and we fall back to livePrompt.userInput instead. That drops the #806 fix for this one paste-bypass case, but the same flow would have hit the same pollution before this PR, so it's a no-regression fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): route out-of-band paste writes through handleInput Codex flagged (#814 P1) that the reconcile path in fetchSuggestions has the same stale-buffer failure mode the Enter-record path now guards against: snippet / keyboard-paste / selection-paste / middle-click-paste handlers in createXTermRuntime call writeToSession directly, so typedInputBufferRef only holds whatever was typed *after* the paste. reconcilePromptWithTypedInput then treats the pasted prefix as prompt text and trims it, completions fetch on the truncated input, and accepting a suggestion rewrites the command incorrectly. Fix at the source: notify the autocomplete hook with the raw (pre-bracket-wrap) bytes at every paste site so its keystroke buffer absorbs them through the same handleInput path keyboard input uses. handleInput's multi-char paste branch already resets / aligns the buffer (and invalidates on embedded escape sequences), so this single extra call per paste site is enough — no new hook API needed. The existing onData-driven notification at line 684 already covers the non-paste keyboard path, and the snippet / paste / pasteSelection / middle-click handlers are the only remaining paths that bypass it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): preserve inner newlines of bracketed-paste input Codex flagged (#814 P2) that the multi-char-paste branch in handleInput drops everything before the last newline, but when bracketed paste is active those newlines are literal input staying on the zle line — not command terminators. A multi-line paste like "cmd1\ncmd2" then left only "cmd2" in typedInputBufferRef and the next Enter recorded / trusted just the tail. Teach handleInput to recognize the bracketed-paste wrapper "\x1b[200~...\x1b[201~" and append the enclosed content verbatim (reliability flag stays on — we know exactly what was added). Matching change in createXTermRuntime: pass the final (possibly bracket-wrapped) bytes to ctx.onAutocompleteInput instead of the raw pre-wrap text so the handle sees the markers when applicable. Non-bracketed pastes still hit the existing newline-split branch so each "\n" resets the buffer to the post-terminator tail. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(autocomplete): route every prompt consumer through getAlignedPrompt Each Codex round on #814 surfaced one more code path that needed the "consume the keystroke buffer only when it's aligned with the live line" gate: Enter-record, fetchSuggestions (×2), insertSuggestion, handleSubDirSelect, fetchSubDirForIndex. The fixes were correct but the guard ended up spelled three different ways across the file: reconcilePromptWithTypedInput(detectPrompt(term), reliable ? buf : "") plus a separate `userInput.endsWith(buf)` check in the Enter branch. That scatter is exactly how the next out-of-band writer gets missed and regresses #806. Collapse all six sites onto one helper: getAlignedPrompt(term, buffer, reliable) → { prompt, alignedTyped } The helper owns the policy — reliability + endsWith alignment — in one place. Non-aligned buffers fall through as raw detector output (same pre-PR behavior, so the worst case for any future forgotten path is a degrade, not a pollution). Enter-record additionally consumes alignedTyped, which is only non-null when the buffer truly matches the tail, so it can record the clean typed command directly without redoing the endsWith check. No behavior change from the previous commit; this is purely deduplication of the alignment guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): inherit reliability on bracketed paste instead of resetting Codex flagged (#814 P1 follow-up) that the bracketed-paste branch unconditionally flipped typedBufferReliableRef back to true. A history-recall-then-paste flow (↑ marks the buffer unreliable, then bracketed paste arrives) would then set reliable=true even though the buffer only contains the pasted tail, not the recalled head. getAlignedPrompt's endsWith check can pass trivially for a short paste tail that happens to equal the last N chars of the recalled line, and Enter would record just the pasted fragment. Reliability is now inherited across a bracketed paste rather than reset: if the buffer was already aligned, appending the paste keeps it aligned; if the buffer was unreliable (post-recall / post-cursor- move), it stays unreliable and the alignment guard in getAlignedPrompt falls through to the raw detector result the way it should. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
a1648adf12 |
Add opt-in setting to preserve mouse selection across keystrokes (#755) (#763)
* Add opt-in setting to preserve mouse selection across keystrokes Closes #755. xterm.js hardcodes a "clear selection on user input" listener (SelectionService.ts: coreService.onUserInput → clearSelection) with no public option to disable. The user-reported workflow this breaks: select a path with the mouse, type a command prefix like `sz `, then middle-click-paste the still-live selection — but the very first keystroke wipes the selection, so there's nothing left to paste. Modern terminals (iTerm2, GNOME Terminal, Windows Terminal) preserve the selection across input by default. We expose this as an opt-in toggle for now since the visual semantics are a behavior change. Implementation is capture-and-restore via xterm.js public APIs (getSelectionPosition / select); xterm clears the selection synchronously, then a queueMicrotask reapplies it on the next tick. A ref (isRestoringSelectionRef) gates copy-on-select so the restore doesn't redundantly rewrite the clipboard and clobber whatever the user copied elsewhere in between. Defaults to false (opt-in); can flip to default-on later if reception is positive. Selection still clears on: - Mouse click in empty space (xterm's mouse-driven path is untouched) - Terminal scroll past the selected rows (existing buffer-trim logic) - Programmatic clearSelection() callers Files: - domain/models.ts — new field, default false - application/syncPayload.ts — added to SYNCABLE_TERMINAL_KEYS - components/terminal/runtime/createXTermRuntime.ts — capture in attachCustomKeyEventHandler, restore via queueMicrotask - components/Terminal.tsx — owns isRestoringSelectionRef, passes it through context, checks in copy-on-select listener - components/settings/tabs/SettingsTerminalTab.tsx — UI toggle - application/i18n/locales/{en,zh-CN}.ts — labels Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Trim verbose i18n descriptions to match neighboring rows Both clearWipesScrollback and preserveSelectionOnInput descriptions were too long. Cut to one sentence each, matching the brevity of adjacent rows like Bracketed paste and OSC-52. Historical context and edge-case caveats belong in the changelog/PR, not the settings UI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
484ac5f463 |
Honor CSI 3 J by default; add toggle to preserve scrollback on clear (#761)
* Honor CSI 3 J by default; add toggle to preserve scrollback on `clear` Default `clear` (ncurses ≥ 2013) emits CSI 2 J + CSI 3 J to wipe both visible screen and scrollback. PR #633 unconditionally intercepted CSI 3 J to keep history across `clear`, which broke POSIX semantics — users running standard `clear` could not wipe scrollback at all (#757). Restore the standard behavior as the default and expose a toggle for the iTerm2-style "preserve history" preference (matches what #622 asked for): - domain/models.ts: add `clearWipesScrollback: boolean` (default true) - createXTermRuntime.ts: CSI 3 J handler now reads the setting and only intercepts when the user opts out - SettingsTerminalTab.tsx + i18n: expose the toggle with a description explaining the tradeoff - The right-click "Clear Buffer" menu action keeps its independent semantics (always preserves scrollback) regardless of this setting, since it goes through `clearTerminalViewport`, not the CSI path Closes #757 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: include clearWipesScrollback in cloud-sync terminal keys Codex review on PR #761 caught that the new toggle was added to TerminalSettings but not to SYNCABLE_TERMINAL_KEYS, so it would never travel across devices via cloud sync — users disabling it on one device would silently get the default back on another after sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
1ca2cd8ec2 |
feat: add "paste selection" terminal command with bindable shortcut
Adds a new terminal action that pastes the terminal's current selection at the cursor without going through the system clipboard — the equivalent of X11 PRIMARY-selection paste. Default shortcut: ⌘ + Shift + X / Ctrl + Shift + X. Also surfaces the action in the terminal right-click menu, disabled when there is no selection. Does not change middle-click paste behavior. Closes #637 |
||
|
|
02967d9258 |
fix: do not clear terminal buffer at the top of session starters
Each session starter (startSSH / startTelnet / startMosh / startLocal) called term.clear() as its first step. In xterm.js, clear() wipes the entire buffer including scrollback. On initial connect this is harmless (the buffer is already empty), but on retry it undoes the viewport preservation that handleRetry just performed — so #695 remained broken for any protocol that went through these starters (i.e. all of them). The clear call served no purpose: xterm mounts with an empty buffer and nothing writes to it before the starter runs. Remove the four try/catch(term.clear()) blocks so handleRetry's preserveTerminalViewportInScrollback actually sticks across reconnect on SSH reboots, telnet drops, mosh/local respawns, etc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
97e78624bb |
fix: remove hardcoded Ctrl+F handler that bypassed configurable shortcuts
The xterm custom key event handler intercepted plain Ctrl+F / Cmd+F to open terminal search, ignoring the user's configured keybinding scheme. This conflicted with zsh's forward-char (Ctrl+F) and gave users no way to disable it via the Shortcuts settings tab. The configurable keybinding system below already routes the searchTerminal action via checkAppShortcut, with defaults of Ctrl+Shift+F (PC) and Cmd+F (Mac). Dropping the hardcoded branch lets the user's settings take effect. Also remove the stale "(Ctrl+F)" label from the toolbar tooltip since the shortcut is configurable and the default on PC is Ctrl+Shift+F. Fixes #694 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
1368709f4e |
fix: map scrollback=0 to large value so mouse wheel scrolling works
xterm.js treats scrollback=0 as "no scrollback buffer", which makes hasScrollback return false and converts wheel events into arrow-key sequences. The UI uses 0 to mean "no limit", so map it to 999999 before passing to xterm.js. Closes #689 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
76cd1f2883 |
fix: remove unused variables flagged by eslint
- App.tsx: remove unused followAppTerminalTheme/setFollowAppTerminalTheme from destructuring (they flow through settings object, not App props) - createTerminalSessionStarters.ts: remove dead usedKey/usedPassword assignments left over from PR #680 which changed runDistroDetection to use the existing session's connection instead of auth credentials Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
e8b9122270 |
feat: auto-detect network devices from SSH banner and skip stats polling (#680)
* feat: auto-detect network devices from SSH banner and skip stats polling (#674) Fixes rapid AAA session churn reported on Cisco/HPE/similar network devices running Netcatty. The root cause was two separate polls that both open fresh exec channels (each counted as its own AAA session on many network devices): - runDistroDetection() opens a brand new SSH connection every time a host connects to run `cat /etc/os-release || uname -a` - useServerStats polls `conn.exec(statsCommand)` every 5 seconds Both commands fail on non-POSIX CLIs, but the channels still hit AAA. This change avoids both by reading the SSH server identification string that ssh2 already captures during the handshake (`conn._remoteVer`). No extra network round-trips, zero additional AAA entries. ## Changes **sshBridge.cjs** - Store `conn._remoteVer` on the session object at connect time as `session.remoteSshVersion` - New IPC handler `netcatty:ssh:remoteInfo` (`getSessionRemoteInfo`) returning the captured SSH server software string **preload.cjs / global.d.ts / useTerminalBackend.ts** - Thread `getSessionRemoteInfo(sessionId)` through to the renderer **domain/host.ts** - `NETWORK_DEVICE_OPTIONS` constant listing the vendor IDs we can recognize (cisco, juniper, huawei, hpe, mikrotik, fortinet, paloalto, zyxel) - `detectVendorFromSshVersion()` — pure function that parses an SSH server software string and returns a vendor ID or ''. Pattern set is sourced from Nmap nmap-service-probes (authoritative), the ssh-audit software.py reference, and vendor docs; see code comments for the exact matches used. - `classifyDistroId()` returns `linux-like | network-device | other` so features that require a POSIX shell can gate on the result. **createTerminalSessionStarters.ts (runDistroDetection)** - Before running the /etc/os-release probe, call `getSessionRemoteInfo` on the already-connected session and feed the banner into `detectVendorFromSshVersion`. If the vendor maps to a known network device, emit the vendor ID via the existing `onOsDetected` callback and skip the shell probe entirely. For unknown or generic OpenSSH/Dropbear banners the existing behavior is preserved. **Terminal.tsx** - `isSupportedOs` now derives from `classifyDistroId(effectiveDistro)` combined with `host.deviceType !== 'network'`, so neither explicit network-device hosts nor banner-detected ones trigger the stats polling loop. **useServerStats.ts** - Add a consecutive-failure counter. After 3 consecutive failed polls, stop the interval for this session (reset on disconnect / sessionId change / settings toggle). This is the fallback for hosts the banner classifier cannot identify (Juniper JUNOS, Cisco NX-OS, Arista EOS — all present as plain `OpenSSH_*` but do not support the POSIX stats pipeline). **DistroAvatar.tsx / HostDetailsPanel.tsx** - Add 8 network-device vendor icons (Cisco, Juniper, Huawei, HPE, MikroTik, Fortinet, Palo Alto, ZyXEL) alongside the existing Linux distro icons, with brand colors. Icons sourced from Simple Icons (CC0) where available; HPE and ZyXEL use simple abbreviation placeholders. - Network device vendors are added to the manual distro override dropdown so users can pin an icon even if their device has an exotic banner we don't auto-detect. **i18n** - English + Chinese labels for the new vendor options in the Host Details distro selector. Closes #674 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: gate network-device detection on raw host.distro, not manual icon override Per Codex review on PR #680: the stats-polling gate was passing `host` through getEffectiveHostDistro() before classifying, which honors the manual distro override (`distroMode: 'manual'` + `manualDistro`). That meant a user who previously pinned an "ubuntu" icon on a host that later gets banner-detected as Cisco would still be classified as linux-like and keep generating the AAA session flood #674 is meant to eliminate. Separate display from gating: - Display (DistroAvatar, host cards): keeps using getEffectiveHostDistro so users can cosmetically override the icon. - Gating (useServerStats via Terminal.tsx isSupportedOs): reads host.distro directly — the value populated by banner detection — alongside the explicit host.deviceType flag. Manual icon choice can no longer re-enable polling on a detected network device. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: guard distro detection against stale session timers Per Codex review on PR #680: runDistroDetection is scheduled on a 600ms setTimeout after connection and also makes async calls of its own. A quick disconnect + reconnect on the same session slot could fire the old timer against the new session, reading host B's SSH banner via getSessionRemoteInfo and writing host B's vendor onto host A's distro field — wrong icon and wrong stats-polling state. Follow the same pattern already used for the startup-command timer in this file (scheduledSessionId captured at schedule time, checked inside the timer). Capture `id` at schedule time, bail out if ctx.sessionRef.current no longer matches, and re-check after every async await inside runDistroDetection so that a reconnect during the banner fetch or the os-release probe also bails cleanly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address local codex review on PR #680 Addresses three issues found in a local Codex review pass after the remote reviewer gate was flaky: ## P0 — session tokens instead of sessionId for stale-timer guard The previous guard captured `id` returned from startSSHSession and compared against `ctx.sessionRef.current` inside the setTimeout and the async runDistroDetection. But the renderer passes `sessionId: ctx.sessionId` into startSSHSession (see createTerminalSessionStarters.ts:543), meaning a tab reuses the SAME sessionId across disconnect+reconnect. The comparison `T1 === T1` always passed, so the guard was a no-op. Replaced with a module-level Map<sessionId, object> that stores the live "connection token" for each sessionId slot. Each call to startSSH mints a fresh `{}` token and overwrites the entry. Timers and async continuations compare their captured token against the current map value by reference — a reconnect replaces the map entry with a new token, so stale callbacks bail cleanly. ## P1 — run os-release probe on the existing SSH connection The fallback /etc/os-release probe used `execCommand` which creates a brand-new SSHClient() on every call. On network devices that present as plain `OpenSSH_*` and fall through to this step (JUNOS, NX-OS, EOS) it added one extra full-auth AAA session log entry per connect, in addition to the failing stats polls. Added `getSessionDistroInfo(sessionId)` as a new IPC handler that runs the same probe via `session.conn.exec()` — an exec channel on the already-open connection, no new handshake. Plumbed through preload.cjs, global.d.ts, and useTerminalBackend.ts. runDistroDetection uses this instead of execCommand in the fallback path, also removing the unused auth-credentials argument (we are no longer opening a new connection, so no credentials are needed). ## P2.1 — don't re-arm timers after giving up After the consecutive-failure counter trips, useServerStats cleared the interval but a subsequent effect rerun (visibility change, settings tweak, etc.) would schedule a fresh `setTimeout` and `setInterval` that would just call the early-return path forever. The scheduling block now checks `givenUpRef.current` before arming either timer. The flag is still cleared on the normal disconnect / sessionId-change reset path so a reconnect gets a fresh attempt. ## P2.2 — drop the ambiguous IPSSH-* → cisco mapping Nmap's `match ssh m|^SSH-([\d.]+)-IPSSH-` line is labelled as `Cisco/3com IPSSHd` — it cannot identify a specific vendor from the banner alone. Mapping it to `cisco` would risk showing the wrong vendor icon on a 3Com device. Removed the rule entirely and documented why with a code comment; users with such devices can still use the Host Details manual distro override. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address remaining gaps from local codex follow-up review P0 gap — delete connection token on session exit. Previously the map entry lingered after disconnect, so a very late-firing timer could still pass the isConnectionTokenCurrent check even though the session no longer existed. Functionally harmless (the IPC calls would fail) but semantically wrong. Now connectionTokensBySessionId.delete() is called in the onSessionExit handler. P1 new — exec channel leak on timeout in getSessionDistroInfo. The timeout branch resolved the promise but didn't close the stream, so a hanging remote command would leave the exec channel open until the SSH connection itself dropped. Added a settled guard (resolve-once) and stream.close() on timeout. P2.1 gap — givenUpRef not reset on sessionId change. The failure counter reset only happened in the !isConnected branch of the main effect, so a sessionId swap while still connected (rare, but possible if the tab reconnects without toggling connected state) would permanently suppress polling. Added a small dedicated effect that resets both counters when sessionId changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
890abd1c4c |
Fix/terminal clear preserve scrollback (#633)
* fixd:issure #622 * fix: use baseY instead of viewportY for active screen row count When the user scrolls up to browse history, viewportY differs from baseY (the active screen origin). _core.scroll always operates on the active screen, so counting rows from viewportY preserves the wrong number of lines and may evict older scrollback unexpectedly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use term.clear() for local clear to preserve prompt line The escape sequence \x1b[H\x1b[2J erases the entire display including the current prompt/input line, which is a regression from term.clear() that keeps the prompt as the first visible line. Remote CSI 2 J is already handled separately by the CSI parser handler. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: preserve both scrollback and prompt in local clear term.clear() destroys scrollback (truncates buffer lines). The escape sequence approach erases the prompt. This commit uses _core.scroll to push lines above cursor into scrollback, then clears below the prompt with CSI 0 J and repositions the cursor — preserving both history and the current prompt line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: panwk <panwk@88.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
32b74f4fea |
fix: persist sidebar appearance overrides for quick-connect hosts (#611)
* fix: persist sidebar appearance overrides for quick-connect hosts Quick-connect hosts (id starting with `quick-`) are not in the saved hosts array, so per-host overrides set via the sidebar (fontWeight, theme, fontFamily, fontSize) were silently lost: 1. onUpdateHost only updated existing entries (map), never inserted — change to upsert so quick-connect hosts are added on first override. 2. fontWeight handlers guarded on rawHost from hostMap, which is undefined for quick-connect hosts — fall back to focusedHost. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: only auto-add quick-connect hosts, never re-add deleted saved hosts Restrict the onUpdateHost upsert to quick-connect hosts (id starts with `quick-`). This prevents sidebar appearance changes from silently re-adding a host that was intentionally deleted while its session was still running. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use primary font only in document.fonts.check to fix bold weight fallback document.fonts.check returns false when ANY listed font in the family string is still loading. Our font family strings include a long CJK fallback chain (Sarasa Mono SC, Noto Sans Mono CJK, PingFang SC, etc.) that may not be loaded during early terminal creation. This caused fontWeightBold to incorrectly fall back to the normal fontWeight, making bold text (including shell prompts) render too thin in freshly created terminals while live-updated terminals looked correct. Fix: extract only the primary font family for the check, ignoring the fallback chain that is irrelevant for bold weight availability. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: normalize WebGL fontWeight rendering after terminal connection Work around xterm.js WebGL renderer bug where glyphs rendered via the constructor look visually different from those set dynamically. After the terminal connects and text is on screen, force a fontWeight round-trip (original → normal → original) so the WebGL texture atlas rebuilds through the dynamic path, producing consistent rendering that matches sidebar font weight changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use global settings for quick-connect host appearance changes Quick-connect hosts have ephemeral IDs (quick-${Date.now()}-...) that are never reused across connections. Auto-adding them to the hosts array would accumulate orphaned entries over time. Instead, treat quick-connect hosts like local terminals: sidebar appearance changes (fontWeight, etc.) update the global terminal settings rather than creating per-host overrides. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address code review findings - Apply isFocusedHostEphemeral to theme, fontFamily, fontSize handlers (not just fontWeight) so all appearance changes on ephemeral hosts update global settings - Use hostMap.has() instead of id.startsWith('quick-') to detect ephemeral hosts — saved hosts with quick- prefix are handled correctly - Re-read fontWeight at timer fire time to avoid stale closure - Handle quoted font names with commas in primaryFontFamily parser Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
0413e02bf0 |
feat: make font weight a per-host setting with override support
- Add fontWeight/fontWeightOverride to Host and GroupConfig interfaces - Add resolve/has/clear helpers in terminalAppearance.ts - Wire per-host font weight through TerminalLayer → ThemeSidePanel - ThemeSidePanel shows "Use Global" button when host overrides weight - createXTermRuntime resolves per-host font weight - Add to INHERITABLE_KEYS for group config inheritance Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
e26f1350f5 |
feat(xterm-6): add scrollbar theming and cleanup log messages
- Add scrollbar slider theme colors derived from foreground color (scrollbarSliderBackground/Hover/Active — new in xterm 6.0) - Update log messages to say 'DOM' instead of 'canvas' Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |