mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 04:50:52 +00:00
fb9400a5fbe4f3579dbb3cfd65d3de8a147dd987
232
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fb9400a5fb |
fix #984: After running the clear command, the inline session log will be cleared (#990)
Co-authored-by: yuzifu <yuzifu@TB16PGen5.Info> |
||
|
|
ea5320d94a |
Fix #954: unify Tooltip styling + replace native selects (#961)
* Fix #954: unify Tooltip styling + replace native selects Replace native HTML title= tooltips and native <select> dropdowns with the existing Radix-based Tooltip / Select components so they share the app's rounded styling, theme tokens and i18n pipeline. Adds a global TooltipProvider in AppWithProviders so every descendant Tooltip works without a per-file Provider wrapper. Scope (driven by the issue #954 examples and "全部都处理" follow-up): - TerminalLayer toolbar: Add Terminal / Split View / SFTP / Scripts / Theme / AI Chat / Move panel / Close panel. - TopTabs middle bar: quick switcher, more tabs, AI assistant, theme toggle, settings; window-control buttons (min/max/close), tray close and hotkey reset/disable have their native title dropped per the user's explicit opt-out ("可以不用Tooltip,直接全局禁用 原生title 属性"). - AI panels: AIChatSidePanel session history / new chat / delete, ConversationExport, AgentSelector, ChatInput attach / expand / permission, ModelSelector, ProviderCard, ai-elements/tool-call. - SFTP: SftpSidePanel header, SftpBreadcrumb, SftpFileRow, SftpPaneToolbar, SftpTabBar, SftpTransferQueue. - Settings: SettingsPage close, SettingsAppearanceTab theme/accent swatches, SettingsFileAssociationsTab edit/remove, SettingsSystemTab crash-log paths and global hotkey reset. - Host vault: HostDetailsPanel (clear / suggestions / show-password / key path / browse key), GroupDetailsPanel, KnownHostsManager, ConnectionLogsManager, KeychainManager, SyncStatusButton, CloudSyncSettings, LogView, QuickSwitcher, ScriptsSidePanel, Terminal status bar copy-host + broadcast/focus, ZmodemProgressIndicator. - Terminal subcomponents: HostKeywordHighlightPopover, TerminalComposeBar, TerminalConnectionDialog, TerminalSearchBar. - Editor: TextEditorPane (subtitle, search, wrap, promote-to-tab). - TrayPanel session rows and port-forwarding rows. Native <select> migrated to custom Select component: - SerialConnectModal (data bits, stop bits, parity, flow control) - SerialHostDetailsPanel (same four fields) - HostDetailsPanel backspace behavior - GroupDetailsPanel backspace behavior - SettingsTerminalTab local shell picker - terminal/ThemeSidePanel font weight Hardcoded English strings extracted to i18n. New keys for both en and zh-CN: terminal.layer.*, topTabs.*, ai.chat.* (sessionHistory, attach, collapse, expand, enableAgent), zmodem.*, settings.shortcuts. resetToDefault. Inline help text on SnippetsManager package-name input removed because the same hint is already shown in a visible <p> below the input. Existing per-file <TooltipProvider> wrappers (SnippetsManager, ScriptsSidePanel, SelectHostPanel, RuleCard, HostDetailsPanel proxy section) are left in place — they nest harmlessly under the global provider and stay self-sufficient for component tests. Tests: - tsc clean for changed files (pre-existing repo-wide errors unrelated to this PR). - All 802 tests pass (3 skipped pre-existing). - HostDetailsPanel.proxyProfile.test and TextEditorPane.test updated to wrap with TooltipProvider, matching the runtime context now needed by the migrated components. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix #954: wrap Settings + Tray windows with TooltipProvider Settings and the tray panel mount as separate Electron windows with their own React root in index.tsx, so they do not inherit the global TooltipProvider added under AppWithProviders. After the unified Tooltip migration, any settings tab that used a Tooltip (Appearance, Application, FileAssociations, System, Shortcuts, Terminal, AI ProviderCard, AI ModelSelector) — and TrayPanel — threw "Tooltip must be used within TooltipProvider" and rendered nothing. Wrap both branches with TooltipProvider at the same level as ToastProvider in index.tsx. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
938d1ef48b |
Fix ghost text duplicating glyphs after Tab completion (#906)
The reliability gate at handleInput's adjustToInput call froze the ghost at its last show()-time tail in any path where the typed buffer becomes unreliable (Tab pass-through to shell, history recall, cursor moves). When the user kept typing into that gap, the next render advanced the cursor past the ghost's anchor while the ghost text stayed put — a → -accept then pasted the stale tail on top of the just-typed glyphs (e.g. "systemctl s" + typing "t" → screen showed "systemctl sttop firewalld"). Add GhostTextAddon.applyKeystroke so the ghost can evolve its own currentInput off raw keystrokes (printable / Backspace / Ctrl-W), seeded by whatever the last show() captured from the live xterm reading. handleInput now uses the existing adjustToInput on the reliable path (preserves multi-char paste re-alignment) and routes single-keystroke events through applyKeystroke on the unreliable path, fixing the visual misalignment and the duplication-on-accept in one shot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
4b7249997f | Update changed known hosts in place | ||
|
|
eb3f55b477 | Integrate host key confirmation into connection dialog | ||
|
|
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 |
||
|
|
5a1d6931a5 |
Fix Tab completion preferring history over local files (#867)
* Fix spec-aware path completion priority Use resolved Fig spec args when deciding when filesystem suggestions should outrank command history. Add a regression test covering a spec-driven file argument command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix generator-only spec path completion --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> |
||
|
|
68040ebdd7 |
fix(autocomplete): recognize Nerd Font / Powerline glyphs as prompt terminators (#871)
* fix(autocomplete): recognize Nerd Font / Powerline glyphs as prompt terminators oh-my-posh and similar themed prompts end with PUA codepoints (e.g. U+F105 chevron, U+E0B0 powerline arrow) that aren't in the hardcoded PROMPT_CHARS set, so findPromptBoundary returned -1 and both ghost-text and popup autocomplete went silent. Treat any Private Use Area char (U+E000-U+F8FF) followed by a space as a candidate prompt terminator — real shell commands essentially never contain PUA codepoints, so this is high-confidence. * Fix Powerline glyph prompt splitting --------- Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> |
||
|
|
e4e1b54374 | Fix terminal custom accent color (#864) | ||
|
|
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 |
||
|
|
df25d6c4b0 | fix: resolve WebGL blank frame on resize and keep split pane bright on context menu (#837) | ||
|
|
324301e61a | Show SFTP toolbar button (#834) | ||
|
|
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> |
||
|
|
dd1d97ffff |
Fix Midnight brightness, optimize backdrop-blur, and remove unused radials. (#817)
- Fixed 8% brightness causes compositers to have severe rendering issues. (Only effected on the Midnight color scheme) 10% seems to be okay. - Reduced backdrop-blur as it's expensive CSS. - Removed radial-gradient backgrounds (they don't show up) |
||
|
|
73b27ad7c4 |
fix(autocomplete): sync ghost text to live input on every keystroke (#815)
* fix(autocomplete): sync ghost text to live input on every keystroke Ghost text was displayed based on whatever input was passed to GhostTextAddon.show() at fetch time. Between a user's keystroke and the next debounced fetchSuggestions firing (~100ms), the on-screen line had already advanced one character but ghost.getGhostText() still returned the pre-update tail. Pressing → during that window pasted the stale tail on top of the new char — e.g. type "do", suggestion shows "cker ls"; type "c", accept immediately → "doc" + "cker ls" lands as "doccker ls" instead of the expected "docker ls". Two-layer fix: 1. New GhostTextAddon.adjustToInput(newInput) that re-renders the ghost against a fresh input without waiting for a new fetch: shrinks / grows the tail if the suggestion still prefix-matches, hides otherwise. Called from handleInput after every buffer mutation (printable, backspace, Ctrl-W, paste tail) when the buffer is reliable. Unreliable-buffer paths skip the call to avoid making the ghost lie. 2. Defense-in-depth at both ghost-accept sites (→ and Ctrl-→): recompute the tail against the live typed buffer instead of trusting getGhostText's show()-time state. If the suggestion no longer prefixes the live buffer, hide without writing. Ctrl-→ additionally resyncs ghost.show() to the live buffer before picking the next word so getNextWord operates on an up-to-date tail. * fix(autocomplete): defer ghost text updates to the next xterm render The previous pass made adjustToInput re-show the ghost synchronously on every keystroke, but xterm hasn't echoed the triggering char yet at that moment — cursorX is still the pre-keystroke position. Painting the shrunken tail there left it visibly overlapping with the char xterm was about to draw, and the ghost only snapped to the right column on the next onRender tick. That one-frame overlap is the "jitter" the reporter still saw. Switch adjustToInput to a defer-and-reapply pattern: - On every keystroke that should re-align the ghost, stash the desired input in pendingInput and hide the element immediately. The transient blank frame is preferable to an overlap glyph. - The existing term.onRender listener now checks for a pending update first: by that tick xterm has processed the echo, cursorX has advanced, and we can paint the new tail at the correct column via applyInputUpdate. - New isActive() exposes "has a live suggestion even if hidden waiting for render" so a fast "type + →" / "type + Ctrl-→" sequence in the hide-until-render gap still hits the accept branch and grabs the recomputed tail from the live buffer. show() and hide() clear pendingInput so an explicit state change supersedes any queued adjust. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): restore ghost text, predict-anchor-shift on each keystroke The previous refactor broke inline completion entirely: 1. useTerminalAutocomplete force-disabled showGhostText whenever showPopupMenu was on — and both are true by default, so ghost never rendered. 2. GhostTextAddon put its overlay container *under* xterm's screen via insertBefore + no z-index. xterm's default renderer paints theme.background across every cell including empty ones, so the ghost was fully occluded by the canvas even when the hook *did* call show(). Fixes both issues and lands the correct per-keystroke strategy the jitter report was asking for: - Drop the showGhostText-vs-showPopupMenu gate; respect user settings. - Put the ghost container back on top of the screen (appendChild + z-index 1). - Track anchorInputLength at show() time. adjustToInput now advances the ghost's left by (newInput.length - anchorInputLength) cells *synchronously* — i.e. it predicts where xterm's cursor will land once the echo arrives, instead of re-reading the live cursorX that hasn't advanced yet. textContent is trimmed in the same call, so ghost + real-input stay aligned across SSH echo latency with no one-frame overlap or blank gap. - Updated GhostTextAddon.test.ts expectations for the new behavior (and cast the fake-document through unknown to fix the pre-existing TS error). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): address ghost text review feedback Follow-ups on the predict-anchor-shift from the previous commit, based on a code-reviewer pass: - Backspace / Ctrl-W de-sync: updatePosition's Math.max(0, ...) was clamping the delta to zero when newInput shrank below the show-time input length. The ghost then stayed pinned at the original anchor column while the real cursor walked back left, leaving a gap between the cursor and the ghost. Let the delta go negative so the ghost tracks the cursor backwards; clamp the resulting left at 0 instead of clamping the delta. - Resize staleness: onResize now also resets lastLeft/lastTop and re-renders, so the dedup cache in updatePosition doesn't hide a now-stale pixel coordinate after xterm recomputes cell dims. - Added a regression test for the backspace path covering both the step-back-below-anchor case and the clamp-at-0-on-overshoot case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): don't accept whole suggestion when buffer is unreliable Codex flagged (#815 P1 ×2) that the live-buffer recompute on → and Ctrl-→ falls into a degenerate path when typedBufferReliableRef is false. My previous cut used live = "" as the fallback, but fullSuggestion.startsWith("") is always true — so: - → would write the entire suggestion over whatever is on the line (post history-recall ↑, Ctrl-R reverse search, etc.). - Ctrl-→ would reanchor the ghost at the start and getNextWord would hand back the first token, duplicating leading content on top of the recalled command. When the buffer is unreliable, empty buffer ≠ empty line — the line has content we're not tracking. Fall back to the ghost's own cached state instead of recomputing: - → reliable: recompute tail vs live buffer, flip buffer to the accepted suggestion, reliability back on. - → unreliable: use ghost.getGhostText() (shown-at-show-time tail) and don't touch the buffer/reliability flag. - Ctrl-→ reliable: resync ghost to live, then proceed as before. - Ctrl-→ unreliable: skip the resync, derive the shrink baseline from fullSuggestion - current-ghost-tail so the next-word logic still works off whatever the ghost was actually showing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): hide ghost on single-byte cursor/recall control chars Reviewer caught that Ctrl-P / Ctrl-N / Ctrl-R / Ctrl-A / Ctrl-E and friends flip typedBufferReliableRef to false but don't hide the ghost — leaving it rendering a tail tied to the pre-recall line. The previous commit's unreliable-→ fallback then reads that stale tail via ghost.getGhostText() and writes it onto the recalled line, reproducing the very duplication class the fallback was meant to prevent (just triggered by Ctrl-P instead of ↑). Mirror what the escape-sequence branch already does: clearState() + return. Once the ghost is hidden, ghost.isActive() is false at the → and Ctrl-→ gates, so the accept-path doesn't fire at all until a fresh fetchSuggestions re-anchors it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): drop accepted-command cache on cursor/recall keys Reviewer pointed out that the early returns in the single-byte ctrl-char and escape-sequence branches leave lastAcceptedCommandRef untouched. If the user accepts a suggestion via → and then immediately hits Ctrl-R or ↑ to pick a different command, the fast Enter path (lines ~611-612) still reads the cached accepted command and records it — logging the old suggestion instead of whichever command the reverse-search or history-recall actually ran. Null lastAcceptedCommandRef at the top of both branches (same place we hide the ghost and flip reliability off) so accept + recall + Enter records the recalled command, not the stale accept. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): also null accepted-command cache on Ctrl-C / Ctrl-U Reviewer flagged this class of bug is still reachable via Ctrl-C / Ctrl-U. The branch handling those kills the zle line, but the early return leaves lastAcceptedCommandRef pointing at a command that is no longer on the line: accept "git status" via → → Ctrl-C to abandon → type "ls" → Enter logs "git status" via the fast path instead of "ls". Same one-liner as the other early-return branches: null the cache alongside clearState(). Now the cache's lifetime truly ends at any event that invalidates the accept. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): null accepted-command cache on bracketed paste too Fifth-pass reviewer caught the last symmetric gap: the bracketed-paste branch appends pasted bytes to the buffer but leaves lastAcceptedCommandRef set. Accept "git status" via → then bracketed-paste " --short" (no embedded newline), press Enter — the fast path at line 611 still reads "git status" and logs that instead of "git status --short". Mirror the non-bracketed paste branch: null the cache before clearState() returns. All handleInput paths that extend or invalidate the line now consistently end the cache's lifetime. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): predict ghost column by cell width + wrap at EOL Review caught two geometry bugs in GhostTextAddon.updatePosition that only surfaced outside the ASCII happy path: - CJK / fullwidth / emoji glyphs occupy two xterm cells but the predictor advanced by one char-length per code unit, so ghost drifted one cell left for every wide char typed and visibly overlapped the user's glyph. - When the predicted column crossed term.cols the real cursor wrapped to the next row, but the predictor just piled more pixels onto `left` — ghost walked off the right edge instead of following onto the next line. Fix both by switching from code-unit count to a small EAW-style width classifier, then applying row wrapping via col = (anchorX + cellDelta) % cols rowOffset = Math.floor((anchorX + cellDelta) / cols) against the current term.cols. Fake terminal in the test suite now exposes cols/rows so the unit tests can exercise both invariants: - "advances the anchor by two cells when a CJK glyph is typed" - "wraps the ghost to the next row when the predicted column crosses cols" Known limitation the review already flagged: on backspace-after-wide we don't have per-grapheme widths to reverse exactly, so the negative delta falls back to code-unit width on the deleted slice. The slice is `currentSuggestion[currentInput.length..anchorInputLength]` which is the same text the user would have typed, so it's correct when only ASCII edits; wide-char backspace can still drift by one cell. Fixing this cleanly needs a per-grapheme buffer and is out of scope. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(autocomplete): honor showGhostText toggle while a ghost is on screen Codex flagged (#815 P2) that fetchSuggestions gates new ghost shows on settingsRef.current.showGhostText, but handleInput's adjustToInput call had no such guard. A ghost that was already active at the moment the user turned showGhostText off would keep tracking the typed buffer via adjustToInput on every keystroke, so the "disabled" setting only took hold after some unrelated path called clearState(). Two-part fix: - Add a useEffect watching settings.showGhostText. When it flips false, hide the active ghost immediately so the disabled setting applies to whatever was already on screen. - Gate the adjustToInput call in handleInput behind settingsRef.current.showGhostText too, so subsequent keystrokes under the disabled setting don't try to move or re-show a ghost. Codex's earlier P2 about wrap-at-EOL on line 236 is already resolved by |
||
|
|
4090483738 |
Fix Security Issues (#799)
* chore(deps): bump fast-xml-parser and @aws-sdk/xml-builder Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and [@aws-sdk/xml-builder](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages-internal/xml-builder). These dependencies needed to be updated together. Updates `fast-xml-parser` from 5.3.4 to 5.5.8 - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.3.4...v5.5.8) Updates `@aws-sdk/xml-builder` from 3.972.4 to 3.972.18 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages-internal/xml-builder/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/HEAD/packages-internal/xml-builder) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.8 dependency-type: indirect - dependency-name: "@aws-sdk/xml-builder" dependency-version: 3.972.18 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump follow-redirects from 1.15.11 to 1.16.0 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.11 to 1.16.0. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.11...v1.16.0) --- updated-dependencies: - dependency-name: follow-redirects dependency-version: 1.16.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump hono from 4.12.7 to 4.12.14 Bumps [hono](https://github.com/honojs/hono) from 4.12.7 to 4.12.14. - [Release notes](https://github.com/honojs/hono/releases) - [Commits](https://github.com/honojs/hono/compare/v4.12.7...v4.12.14) --- updated-dependencies: - dependency-name: hono dependency-version: 4.12.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump vite from 7.3.1 to 7.3.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 7.3.1 to 7.3.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v7.3.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v7.3.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 7.3.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump flatted from 3.3.3 to 3.4.2 Bumps [flatted](https://github.com/WebReflection/flatted) from 3.3.3 to 3.4.2. - [Commits](https://github.com/WebReflection/flatted/compare/v3.3.3...v3.4.2) --- updated-dependencies: - dependency-name: flatted dependency-version: 3.4.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump @hono/node-server from 1.19.11 to 1.19.14 Bumps [@hono/node-server](https://github.com/honojs/node-server) from 1.19.11 to 1.19.14. - [Release notes](https://github.com/honojs/node-server/releases) - [Commits](https://github.com/honojs/node-server/compare/v1.19.11...v1.19.14) --- updated-dependencies: - dependency-name: "@hono/node-server" dependency-version: 1.19.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump rollup from 4.57.1 to 4.60.2 Bumps [rollup](https://github.com/rollup/rollup) from 4.57.1 to 4.60.2. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.57.1...v4.60.2) --- updated-dependencies: - dependency-name: rollup dependency-version: 4.60.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump electron from 40.1.0 to 40.8.5 Bumps [electron](https://github.com/electron/electron) from 40.1.0 to 40.8.5. - [Release notes](https://github.com/electron/electron/releases) - [Commits](https://github.com/electron/electron/compare/v40.1.0...v40.8.5) --- updated-dependencies: - dependency-name: electron dependency-version: 40.8.5 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump path-to-regexp from 8.3.0 to 8.4.2 Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) from 8.3.0 to 8.4.2. - [Release notes](https://github.com/pillarjs/path-to-regexp/releases) - [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md) - [Commits](https://github.com/pillarjs/path-to-regexp/compare/v8.3.0...v8.4.2) --- updated-dependencies: - dependency-name: path-to-regexp dependency-version: 8.4.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump picomatch from 2.3.1 to 2.3.2 Bumps [picomatch](https://github.com/micromatch/picomatch) from 2.3.1 to 2.3.2. - [Release notes](https://github.com/micromatch/picomatch/releases) - [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/picomatch/compare/2.3.1...2.3.2) --- updated-dependencies: - dependency-name: picomatch dependency-version: 2.3.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump yaml from 2.8.2 to 2.8.3 Bumps [yaml](https://github.com/eemeli/yaml) from 2.8.2 to 2.8.3. - [Release notes](https://github.com/eemeli/yaml/releases) - [Commits](https://github.com/eemeli/yaml/compare/v2.8.2...v2.8.3) --- updated-dependencies: - dependency-name: yaml dependency-version: 2.8.3 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump @xmldom/xmldom from 0.8.11 to 0.8.13 Bumps [@xmldom/xmldom](https://github.com/xmldom/xmldom) from 0.8.11 to 0.8.13. - [Release notes](https://github.com/xmldom/xmldom/releases) - [Changelog](https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md) - [Commits](https://github.com/xmldom/xmldom/compare/0.8.11...0.8.13) --- updated-dependencies: - dependency-name: "@xmldom/xmldom" dependency-version: 0.8.13 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump brace-expansion from 1.1.12 to 1.1.14 Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.12 to 1.1.14. - [Release notes](https://github.com/juliangruber/brace-expansion/releases) - [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.12...v1.1.14) --- updated-dependencies: - dependency-name: brace-expansion dependency-version: 1.1.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump tar from 7.5.7 to 7.5.13 Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.7 to 7.5.13. - [Release notes](https://github.com/isaacs/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/node-tar/compare/v7.5.7...v7.5.13) --- updated-dependencies: - dependency-name: tar dependency-version: 7.5.13 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Security Fixes Security fixes: Added input validation for uncontrolled command lines. Added Proper Shell Escaping for useTerminalAutocomplete Fixed 4 race condition alerts by atomic stat+read(s) without following symlinks. Misc: Use Crypto randomness instead of Math.random() (Not a security issue but convenient) * Fix OS quirk fallbacks * Review fix - use lstat before open to skip FIFO/devices early to prevent blocks - SFTP skip UUID tag could be dubiously long * allow symlinks alongside regular files. * Use acutal target size for reading * Fix Destructed import / fix to use full shellEscape charset - Destructed import - Guard now matches full shellEscape charset * Supress Codex complaints Replaced manual fd.read with fs.promises.readFile(fd) to ensure complete file reads to EOF. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.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> |
||
|
|
a5b5f15343 |
feat(terminal): quick encoding switch for telnet & serial (closes #804) (#812)
* feat(terminal): extend quick encoding switcher to telnet and serial sessions Closes #804. TerminalToolbar only showed the UTF-8 / GB18030 encoding menu for SSH sessions. Telnet and serial sessions had no runtime control — their decoder was fixed at session start via charsetToNodeEncoding + Node's StringDecoder, which only knows utf8/latin1/ascii/utf16le. Users connecting to legacy telnet daemons or MCU consoles emitting GBK were stuck with the encoding chosen at connect time and could not switch to read non-latin text correctly. Main side (terminalBridge.cjs): - Swap StringDecoder for iconv-lite on the telnet + serial paths so GB18030 actually decodes. Local PTY and mosh keep StringDecoder — local follows the OS locale and mosh frames its own UTF-8, neither needs a runtime swap. - Store the decoder through a mutable decoderRef on the session object so the onData closures stay untouched while a new IPC handler can swap in a fresh decoder mid-session. - Add normalizeTerminalEncoding that resolves user-facing charset names (utf-8/gbk/gb2312/gb18030) into iconv identifiers. - Register netcatty:terminal:setEncoding, which updates the session's encoding + decoderRef (and mirrors to serialEncoding for aiBridge / mcpServerBridge exec calls that still read the legacy field). Renderer + preload: - preload.setSessionEncoding now tries the SSH handler first and falls through to the new terminal handler when the SSH side reports ok: false (non-SSH sessions don't have session.stream). Single preload method, one extra IPC round-trip only for telnet/serial, which only happens on explicit user click. - Drop the isSSHSession gate in TerminalToolbar; replace with encodingSwitchSupported = not local, not mosh, not localhost-PTY. - Terminal.tsx onSessionAttached now syncs the initial encoding for every protocol that supports it (same gate as the toolbar), not only SSH. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ai): decode serial exec output with iconv for non-Buffer encodings Codex flagged (#812 P1) that session.serialEncoding can now be an iconv-only label like gb18030 after a user switches encoding via the new terminal toolbar menu. execViaRawPty then called data.toString(encoding) on the raw Buffer, which throws "TypeError: Unknown encoding" for anything outside Node's utf8/latin1/ascii/utf16le set. The throw landed inside the data listener so Catty Agent / MCP serial exec calls failed and, worse, the uncaught path could destabilize the process. Route the decode through a small decodeBufferAs helper: Node encoding labels still use Buffer.toString for speed; anything else falls back to iconv-lite (which already handles the toolbar's GB18030). A last- resort utf8 fallback keeps the listener from throwing even if iconv itself rejects an unrecognized label. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(terminal): don't overwrite telnet/serial charset on session attach Codex flagged (#812 P1) that extending onSessionAttached to sync the UI encoding for telnet and serial sessions corrupts any host charset outside the toolbar's two values. terminalEncodingRef is derived from a useState that only ever resolves to 'utf-8' or 'gb18030', so a host configured with latin1 / shift_jis had its correct decoder immediately clobbered with one of those two as soon as the session attached. SSH is the only protocol that actually needs this sync: its backend starts in utf-8 regardless of host.charset. startTelnetSession and startSerialSession already apply options.charset through normalizeTerminalEncoding, so leaving them alone keeps arbitrary iconv labels intact; the toolbar's runtime switch remains the path for users who do want to flip to UTF-8 / GB18030 mid-session. Restore the SSH-only gate on the sync and document why the new protocols are intentionally excluded. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * style(terminal): align encoding menu rows with the rest of the popover The encoding section used a different template from every other row in the overflow menu: an uppercase "TERMINAL ENCODING" section header, then two indented rows with a leading check mark instead of a leading icon. Next to Open SFTP / Scripts / Terminal settings it read as a different component and made the popover feel disjointed. Drop the section header and render both encoding options as plain menuItemClass rows — Languages icon on the left to match the Zap / Palette leading-icon pattern, label in the flex-1 slot, and the active row gets a trailing Check in place of a right-side accessory. A single divider above them still groups the choice visually without the uppercase label. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * style(terminal): collapse encoding picker into a proper submenu The previous pass put UTF-8 and GB18030 as flat rows under a separator inside the main overflow popover. It matched the top rows better but still looked like a disjoint block of two choices stuck at the bottom. Turn the encoding picker into a nested submenu so the parent popover stays a flat list of actions and the choice lives behind a single row that mirrors the other menu items exactly: Languages icon on the left, t("terminal.toolbar.encoding") label in the flex slot, the current value as a muted caption, and a ChevronRight to signal the submenu. The submenu itself is a second Popover anchored to the right of the parent. Both popovers are now controlled so picking a value closes the whole chain in one click, and the parent's onInteractOutside ignores clicks that land in the submenu portal — otherwise Radix would treat the submenu click as "outside" the parent and dismiss it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(terminal): drop hostname gate, simplify encoding row label Two issues in one pass: 1. Codex P2 (#812): encodingSwitchSupported still hard-disabled the menu when host.hostname === 'localhost'. That was a leftover from when the only "local" escape hatch was hostname-based, but it incorrectly blocks telnet / SSH sessions aimed at localhost (test daemons, forwarded endpoints) which do have a real backend decoder we can drive. The isLocalTerminal / isMoshSession gates already cover the true local PTY and mosh cases — drop the hostname check. 2. UI: the submenu trigger carried the current value as a muted caption next to the label. At w-48 the row ran out of room and truncated "Terminal Encoding" to "Terminal Enc...". Since the submenu already marks the active choice with a check, the caption is redundant. Remove it so the full label fits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ai): stream-decode serial output with a stateful per-command decoder Codex flagged (#812 P2) that decoding each serial data event with a stateless decodeBufferAs call corrupts multi-byte characters on GBK/GB18030 consoles: serial ports deliver chunks at arbitrary byte boundaries, so the leading half of a 2-byte char in one event gets emitted as replacement bytes before the trailing half ever arrives. Build a stateful decoder once per execViaRawPty call (StringDecoder for Node-native encodings, iconv.getDecoder for iconv-only labels like gb18030) and feed every chunk through decoder.write(). On finish, decoder.end() flushes any partial bytes the decoder is still holding into the final output before it's handed back to the caller. Strings pass through untouched, same as before. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(terminal): sync SSH encoding on localhost sessions too Codex flagged (#812 P2) that dropping the 'localhost' check from the toolbar's encodingSwitchSupported gate left an inconsistency: Terminal.tsx onSessionAttached still skipped setSessionEncoding when host.hostname === 'localhost', so a user could pick GB18030, reconnect a localhost SSH tab, and the backend would restart in utf-8 while the UI still showed GB18030 — mojibake until manually toggled again. Drop the hostname clause from the isSSH check here as well. SSH to localhost is still a real SSH session whose backend starts in utf-8; the sync is what keeps the UI's picked encoding aligned across reconnects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(terminal): re-sync telnet/serial encoding after user opt-in Codex flagged (#812 P2) that the SSH-only sync left telnet/serial with a silent UI/backend mismatch across reconnects: a user picks GB18030, the tab disconnects and retries, startTelnetSession/startSerialSession re-apply host.charset, and the UI still shows GB18030 — garbled output until the user toggles again. An unconditional sync isn't right either (earlier review: it would clobber arbitrary host.charset values like latin1 / shift_jis that the UI's two-value state can't represent). Track whether the user has actually clicked the toolbar menu this session via userPickedEncodingRef — once set, any subsequent onSessionAttached for telnet/serial re-applies the picked value; on first attach with no user action the backend's configured charset stays intact. SSH keeps the unconditional sync (its backend always starts in utf-8, so there's no configured charset to preserve). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
e992d51fa6 |
Collapse four terminal toolbar actions behind a More popover (#792)
* Collapse four terminal toolbar actions behind a "More" popover
The terminal status-bar toolbar had seven visible icon buttons
(SFTP, Encoding, Scripts, Theme, Highlight, Compose, Search) plus
the close button. That's a lot of icons for a toolbar that sits
right above the terminal output — it reads as cluttered and pushes
the connection info / host name around on narrow tabs.
Fold the four "opener" actions — SFTP, Encoding, Scripts, Terminal
Settings — behind a single `MoreHorizontal` (⋮) popover. The three
mid-session toggles (Highlight, Compose, Search) stay in the bar
because they're used repeatedly during a session.
- components/terminal/TerminalToolbar.tsx:
* Add MoreHorizontal import, a shared `menuItemClass` style for
popover rows.
* Replace the four inline Buttons with a single Popover whose
content lists each action as an icon + label row.
* Inline the Encoding sub-popover into the same menu: a
Languages-icon section header followed by two `Check`-marked
radio-like rows for UTF-8 / GB18030 — still only rendered when
`isSSHSession && onSetTerminalEncoding`.
* SFTP row respects the existing connected-state: disabled +
50% opacity until the session is connected, and label falls back
to "availableAfterConnect".
- application/i18n/locales/en.ts, zh-CN.ts:
* New `terminal.toolbar.more` key — "More actions" / "更多操作"
— used as the ⋮ button's aria-label and tooltip.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Move terminal overflow menu to end and use vertical dots
The ⋮ overflow trigger was the first icon in the toolbar with a
horizontal-dots glyph. Visually it read as the primary action and
competed with the mid-session toggles next to it.
Move the Popover to the end of the toolbar (just before the close
X when shown), switch the icon to MoreVertical, and flip the
popover alignment to `end` so it opens leftward from the right
edge.
Toolbar order is now: Highlight → Compose → Search → ⋮ → (X).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
999ad916e3 |
Make terminal compose bar borderless and immersive (#789)
The old compose bar had a rounded gradient card with an inset box shadow, a bordered inner textarea, and a prominent filled Send button — visually heavy, and sitting on top of the terminal it looked like a separate panel instead of a prompt line. Rework it to sit flush on the terminal-theme background, Claude Code compose-area style: - Outer container uses resolvedBg directly (no gradient, no rounding, no box-shadow); separator from terminal output is a single 8%-alpha hairline border-top. - Textarea is fully borderless and transparent — no bg, no border, no focus ring, no inner shadow. Text sits directly on the terminal bg. - Send button removed entirely; Enter was already the send key, and the filled button was just visual weight. Shift+Enter still inserts a newline, Esc still closes. - Close (X) button shrunk to a minimal 6x6 ghost; transparent at rest, only gains a 10% overlay + full fg on hover. - Placeholder bumped from opacity-40 to opacity-70 so the "press Enter to send" hint is legible against dark and light terminal themes. 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> |
||
|
|
98e3a6b952 |
Let single Tab fall through to shell when only ghost text is shown (#745)
Closes #741. Bash/zsh use Tab for native completion, but our ghost-text accept on single Tab was swallowing the keystroke before it reached the PTY. Ghost text is still accepted with →; Tab in popup-menu mode is unchanged (popup is an explicit UI so intent is clear). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
1b23bdcf15 |
[codex] Preserve terminal focus when clicking the toolbar overlay (#734)
* fix terminal toolbar focus loss * restore focus after closing side panels * fix terminal side panel focus helper order |
||
|
|
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> |
||
|
|
2784ecdf28 | fix: sync inherited themes in editors | ||
|
|
75bbd1f300 | fix: preserve theme inheritance and modal rollback | ||
|
|
4ee4ef7b60 | fix: polish follow-app terminal theme UX | ||
|
|
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> |