mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 15:41:17 +00:00
dd1d97ffff064a08d3a3a7ec2c0fdcbdc8c2ed5d
1045
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
5b26a4a447 |
fix(sftp): download all selected files instead of only the right-clicked one (#811)
Closes #805. The SFTP file-list context menu's Download action only passed the right-clicked entry to the single-file handler, so selecting N files and hitting Download still downloaded only one — matching copy/move/ delete, which already iterate selectedFiles, this is the odd one out. Add onDownloadFiles through the SftpContext → pane callbacks → file- list chain. In the context menu, if the right-clicked row is part of pane.selectedFiles and the selection has >1 entry, fall into the new multi-file path; single selection stays on the existing handler so its save-dialog UX is unchanged. The new handleDownloadFilesForSide iterates local selections with the existing blob path (browser auto-saves each file). For remote panes it prompts for a target directory once via selectDirectory and streams every selected file into it — avoids the N-save-dialog prompt storm that a naive loop would trigger. Mirrors the existing directory- download branch. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
08f00ed143 |
fix(editor): address Codex review feedback on PR #808 (#809)
* fix(editor): address Codex review feedback on PR #808 Three issues raised on the merged editor-tab-form PR: P1 — Host-picker switch ignored onDisconnect cancellation SftpPaneDialogs' onSelectLocal / onSelectHost awaited onDisconnect() and unconditionally called onConnect() regardless of the dirty-editor prompt outcome. A user who hit Cancel on the "unsaved changes" dialog would still end up switched to the new host, stranding the editor tabs on a now-stale connection. Change onDisconnect to return Promise<boolean> (true when the disconnect actually ran, false on prompt cancel) and gate onConnect on it. Propagate the new signature through SftpPaneCallbacks, the pane-actions hook result, and both left/right implementations. P2 — setIsQuitting leaked across canceled quits electron/main.cjs called windowManager.setIsQuitting(true) at the top of before-quit, before the dirty-editor check returned. If the renderer reported hasDirty=true and the quit was canceled, isQuitting stayed true, changing later window-close behavior (close-to-tray paths gated on !isQuitting would stop firing). Move the setIsQuitting call into a commitQuit() helper that only runs once we've decided to actually proceed — on hasDirty=true we leave state untouched. P2 — SftpSidePanel unmount only cleaned active-pane connections The cleanup effect inspected only leftPane / rightPane (the active tab per side), missing editor tabs tied to inactive tabs in the same side panel. On unmount those tabs would survive with a dead save bridge. Iterate leftTabs.tabs and rightTabs.tabs and collect every connection id before calling forceCloseBySessions. npm test — 212/212 pass, tsc error count unchanged from main, lint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * perf(editor): stabilize bridge registration effect and memoize filename dedup Two perf concerns from a focused leak/perf audit of PR #808: 1. Bridge writer effect re-ran on every SFTP state change. SftpView / SftpSidePanel registered their bridge writer in an effect with `[sftp]` deps. The `sftp` object identity changes on every SFTP state update — transfer progress, directory listing, pane updates, tab switches — so the effect would unregister+reregister constantly during routine SFTP use. Not a leak (React runs cleanup before each re-effect), just high-frequency churn on the hot path. Route through sftpRef and run the effect once; writeTextFileByConnection is a methodsRef-backed dispatcher that stays valid across sftp re-renders. 2. O(n²) filename disambiguation scan in TopTabs render. Each editor tab ran `editorTabs.filter(same fileName)` inside the per-tab render branch. Negligible at ~20 tabs but trivially fixable: build a fileName→count map in a useMemo keyed on editorTabs and look up in O(1). Separately noted but NOT fixed here (needs a store refactor and deserves its own PR): App.tsx subscribing to useEditorTabs() means every keystroke in an editor tab re-renders the App root. Would need a useEditorTabIds() selector that only notifies on add/remove. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
b9e9a0d59c |
feat(editor): promote SFTP text editor into top-level tabs (#631) (#808)
* chore: ignore local .worktrees/ directory Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): editorTabStore scaffold with single-tab ops Implements the EditorTabStore class singleton (matching activeTabStore pattern) with updateContent, markSaved, setWordWrap, setSavingState, close, and subscribe. Includes useSyncExternalStore hooks and 6 passing unit tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): editorTabStore promoteFromModal with per-session path dedup * feat(editor): confirmCloseBySession for session teardown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(sftp): writeTextFileByConnection for pane-agnostic saves Adds a new `writeTextFileByConnection(connectionId, expectedHostId, filePath, content, filenameEncoding?)` method to `useSftpExternalOperations` that looks up the SFTP pane by connection ID (with a hostId safety check) instead of the left/right-side coupling used by `writeTextFile`. Threads the existing `getPaneByConnectionId` callback through the call site and re-exports the new method via `SftpStateApi`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(editor): editorSftpBridge singleton for out-of-React saves Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(editor): extract TextEditorPane from TextEditorModal Lift Monaco editor body + toolbar + theme sync + paste fallback into a pure TextEditorPane component. Adds sftp.editor.maximize i18n key to en.ts and zh-CN.ts locale files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(editor): drop unused getLanguageId import in TextEditorPane Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(editor): TextEditorModal delegates to TextEditorPane Replace the monolithic modal (560 lines including full Monaco setup) with a thin Dialog shell (~150 lines) that owns content/saving/saveError/ languageId state, save orchestration, and dirty-check on close, then delegates all editor chrome to <TextEditorPane chrome="modal" />. Exports TextEditorModalSnapshot for the optional onPromoteToTab callback so callers can later wire tab promotion (Task 12) without breaking the existing interface — the new prop is optional and existing callers (SftpOverlays.tsx) are source-compatible with zero changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): include fileName and wordWrap in TextEditorModalSnapshot Task 12 will populate the promoted tab with these fields, so the snapshot must carry them from the modal at maximize time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): UnsavedChangesDialog three-button confirm * fix(editor): resolve UnsavedChangesDialog re-entrance and unmount leaks - Re-entrance: if prompt() is called while a prior prompt is still pending, cancel the prior one so its caller doesn't hang forever. - Unmount: resolve any in-flight prompt as "cancel" in the effect cleanup so awaiters don't leak when the provider unmounts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): TextEditorTabView tab-form shell Add TextEditorTabView component that binds an editorTabStore entry to TextEditorPane, with CSS display:none toggling for inactive tabs so the Monaco instance persists across tab switches. Also adds setLanguage public method to EditorTabStore (lands Task 15's intent early — Task 15 can be a no-op). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): read live store state in TextEditorTabView handlers React state snapshot lags the store by a microtask. Closing over `tab` meant a keystroke between Monaco's onChange and a Ctrl+S would write stale content and mark a stale baseline. Read via editorTabStore.getTab at call time instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): dispatch editor:* tab ids in App and activeTabStore - Add EDITOR_PREFIX, isEditorTabId, toEditorTabId, fromEditorTabId helpers - Add useIsEditorTabActive hook to activeTabStore - Update useIsTerminalLayerVisible to exclude editor tabs - Import useEditorTabs and TextEditorTabView into App.tsx - Append editor tab ids (editor:<id>) to allTabs in hotkey handler - Mount TextEditorTabView per editorTab with CSS visibility toggling - Add editorTabs to executeHotkeyAction useCallback dependency array Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(editor): render editor tabs in TopTabs with icon/dirty/tooltip - Add `fromEditorTabId`, `isEditorTabId` imports to TopTabs.tsx - Add `FileCode`, `FileText` icons; use FileCode for code-like extensions - Extend `TopTabsProps` with `editorTabs`, `onRequestCloseEditorTab`, `hostById` - Build `editorTabMap` for O(1) lookup; add `editor` branch in `orderedTabItems` - Render editor tab chrome matching terminal tab style: file icon, dirty dot (●), filename with disambiguation suffix for duplicate filenames, close button - In App.tsx: add stub `handleRequestCloseEditorTab`, `orderedTabsWithEditors`, pass new props to `<TopTabs>` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(editor): hoist editor-tab code-extension regex and use onSelectTab - Move CODE_EXTENSIONS_RE to module scope so it isn't recompiled per render. - Call onSelectTab(tabId) for consistency with other tab types, instead of reaching into activeTabStore directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): maximize modal to tab and dirty-confirm tab close Wire onPromoteToTab from TextEditorModal through SftpOverlays and useSftpViewFileOps so clicking the maximize button snapshots editor state into editorTabStore and activates the new editor tab. Replace the stub handleRequestCloseEditorTab in App.tsx with a real dirty-confirm flow using UnsavedChangesProvider render-prop: clean tabs close immediately, dirty tabs prompt save/discard/cancel, and save routes through editorSftpBridge with markSaved on success. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(editor): register SFTP bridge and gate session close on dirty editor tabs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): make onDisconnect async so host-picker waits for dirty check The session-close dirty gate added in Task 13 made onDisconnect async, but the host-picker in SftpPaneDialogs still called it synchronously before kicking off onConnect — a fire-and-forget that raced past the dirty prompt and let unsaved editor tabs slip through. Propagate the Promise return type through SftpPaneCallbacks / SftpPaneDialogs / useSftpViewPaneActionsResult and await it at the host-picker call sites. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): block app quit while editor tabs are dirty Add a before-quit IPC guard that asks the renderer whether any editor tab has unsaved changes. If dirty tabs exist, preventDefault() blocks the quit and a warning toast is shown. The app quits normally once editors are clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(editor): add 5s timeout fallback to quit-guard IPC check If the renderer crashes or throws before reporting back, the quitGuard would stay busy forever and the app could not be quit. Fall back to force-quit after 5 s if no reply arrives. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): quit-guard uses quitConfirmed flag to prevent re-entry loop The prior flow reset quitGuardChannelBusy before calling app.quit(), which on macOS re-fires before-quit and re-entered the dirty check with the flag cleared — creating an infinite IPC loop. Introduce a separate quitConfirmed flag that commits to quitting before app.quit() fires, so the re-entry takes the fast path. Also extract QUIT_GUARD_TIMEOUT_MS and clarify that a concurrent quit while a check is in flight is swallowed (preventDefault) rather than letting the second event through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): use absolute inset-0 for tab panel and add sr-only DialogTitle Two bugs surfaced during the first dev-server smoke test: 1. Editor tab content was blank because TextEditorTabView used only className="h-full", while its sibling panels (VaultView, SftpView, TerminalLayerMount, LogView) all fill their flex-1 parent via `absolute inset-0`. In normal flow the editor tab collapsed to zero height. Match the sibling convention. 2. Radix printed an accessibility warning because the Task 7 refactor pulled the DialogTitle out of DialogContent and into the Pane header (now a plain span). Add a visually hidden DialogTitle that mirrors the filename, so screen readers have a title without showing it twice. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): raise tab panel z-index to 20 so it sits above TerminalLayer TerminalLayer's root is visibility:hidden when the active tab is an editor tab, but its inner panels set `absolute inset-0 z-10` on their own and those still paint. Without an explicit z on the editor tab panel, TerminalLayer's inner bg-background div was covering the Monaco content, producing a blank screen. Also add bg-background to the wrapper so the editor tab paints an opaque surface (matches the pattern VaultViewContainer / TerminalLayer follow). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): show host label and remote path next to filename in tab header The editor tab form previously only showed the bare filename in its header, which is ambiguous when the same filename is open against multiple hosts. Add an optional subtitle prop on TextEditorPane and populate it from the tab form with `<hostLabel>:<remotePath>` rendered in muted text beside the filename. The modal keeps its existing filename-only header. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): bridge supports multiple useSftpState instances useSftpState is instantiated in both the top-level SftpView and the terminal's SftpSidePanel, each owning its own pane registry. The editor bridge previously stored only one writer, so maximizing a file opened from the terminal side panel registered nothing (bridge was owned by SftpView which may never have mounted) and save failed with "bridge not registered". Change the bridge to track a Set of writers and dispatch by trying each until one owns the connectionId (signalled by its specific "connection no longer available" error). Add registerEditorSftpWriterScoped that returns an unregister fn so each instance's cleanup removes only its own entry. Register in both SftpView and SftpSidePanel. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(editor): Cmd+W closes editor tab + terminal close forces tab close Two behaviors added after user feedback from dev-server smoke-test: 1. Cmd/Ctrl+W (the closeTab hotkey) previously did nothing on editor tabs because executeHotkeyAction had no branch for editor:* ids. Add one that reaches into the UnsavedChangesProvider render-prop's close flow via a ref, routing through the existing dirty-confirm path. 2. Closing a terminal tab unmounts its SftpSidePanel which destroys the useSftpState instance that owned the connection. Any editor tab promoted from that panel would then be stuck — bridge gone, save channel dead. On SftpSidePanel unmount, gather the connection ids it owned and call a new editorTabStore.forceCloseBySessions to drop matching editor tabs. Dirty state is dropped because the user closed the terminal knowing the file was open — there is no save channel left anyway. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): Cmd/Ctrl+W works when focus is inside Monaco Monaco's internal key-event dispatcher swallows keydown before the capture-phase handler on the Pane's root div can see it, so the global hotkey dispatcher never got the chance to close the editor tab when the editor had focus. Register a Monaco editor command for the close-tab keybinding and route it through a handleCloseRef — mirrors the same pattern used for Cmd/Ctrl+S. Also drop the modal-only guard in the capture-phase handler so the outer-chrome path works in tab mode too. TextEditorTabView now receives an onRequestClose(tabId) prop that App.tsx wires via the render-prop-exposed handleRequestCloseEditorTabRef, same mechanism as the hotkey-dispatcher path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(editor): fall back to Vaults when forceCloseBySessions removes the active tab Closing a terminal tab triggers SftpSidePanel unmount which force-closes its editor tabs. If the editor tab being removed happened to be the active tab (user maximized → then closed the owning terminal from another path), the app ended up on a stale activeTabId with no selected tab and blank content. Inside forceCloseBySessions, if the active tab was one of the removed editor ids, redirect to 'vault'. Picking a more sophisticated neighbor would need the full orderedTabs list which isn't reachable from this layer; Vaults is always valid. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
f38afd8bfc |
Align snippet row icons with package row icons in tree (#802)
Snippet rows used a padding-based offset to account for the chevron column in package rows, but the flex gap between chevron and icon wasn't being compensated so the FileCode icon sat 4-6px to the left of the Package icon above it. Mirror the package row's flex layout literally by rendering an invisible chevron placeholder, so both row types share the same column structure. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
c3dabbfef2 |
Render snippets sidebar as an expandable tree (#800) (#801)
* Render snippets sidebar as an expandable tree (#800) The terminal sidebar used breadcrumb navigation, so switching between packages meant clicking out and back in. Replace that with a single tree view where each package row has a chevron to expand/collapse (SFTP-style), so snippets across multiple packages stay visible and reachable without drilling. - All discovered packages default to expanded, so the tree matches the user's expectation of seeing everything at once. - Search flattens to a list of matching snippets regardless of nesting, each annotated with its package path so the origin is still clear. - Implicit ancestor packages (e.g. "a/b/c" implies "a" and "a/b") are materialized so deeply nested snippets aren't orphaned when a parent package isn't explicitly listed. - Depth-based left padding + chevron rotation mirror the SFTP tree view's affordances. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Unify snippet row typography with tree + move command to tooltip Snippet rows were rendered as two-line blocks (label + inline command preview), which made them visually taller and heavier than the single-line package rows in the tree, and long commands overflowed the container. Collapse them to single-line rows that match the package row layout exactly (same text size, same padding, aligned icon column) and surface the full label + command text in a tooltip on hover. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Preserve collapsed packages across snippet refreshes (codex) The auto-expand effect compared prev.size to normalizedPackages.size to decide whether to repopulate, but collapsed rows shrink prev.size, so any later snippet/package change would trip the condition and overwrite the user's collapse state with a bulk re-expand. Track the set of packages ever observed in a ref and only auto-expand paths that are new since the previous render. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
0108390d4f |
Pin the host multi-select bar to the top of the page (#793)
The bulk-action bar for multi-select (selected count, Select All / Deselect All / Delete / close) was rendered inside the Hosts section, so it scrolled out of view as soon as the user moved past the first row of cards. Hoist the bar out of the scroll container and render it as a sibling right after the top header. It is now always visible below the header while multi-select is active in the Hosts section, and slims down visually: - Single flat row (no inner pill, no secondary border) - Compact button sizing: h-7, px-2, text-xs, icon-12 - Bottom-only border for separation from the scroll area - Count label forced to h-7 + leading-none so it vertically centers against the buttons 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>
|
||
|
|
7c55381f39 |
Add terminals to workspace + New Workspace from QuickSwitcher (#790)
* Add terminals to workspace + New Workspace from QuickSwitcher
Two entry points share a single multi-select picker that lets the
user add Local Terminal + any combination of hosts into a workspace:
1. Focus-mode sidebar "+" button appends the selected targets to the
active workspace as new panes.
2. QuickSwitcher "New Workspace" button (small inline action next to
the Jump To hint) spins up a brand-new workspace tab populated
with the selected targets.
## Changes
### domain/workspace.ts
- pruneWorkspaceNode now rebalances surviving siblings to EQUAL
sizes after removal, instead of re-normalising the prior skew.
Matches the "auto-redistribute on close" expectation.
- New appendPaneToWorkspaceRoot(root, sessionId, direction='vertical'):
if root already splits in the requested direction, pushes the new
pane onto its children and resets sizes to equal; otherwise wraps
root + new pane in a new 0.5/0.5 split. Flattens long chains of
appends instead of producing degenerate nested trees.
### application/state/useSessionState.ts
- appendHostToWorkspace(workspaceId, host, direction?) — atomic
"build a session for this host and append it to the root", keeps
activeTab on the workspace and focuses the new pane.
- appendLocalTerminalToWorkspace(workspaceId, options?, direction?)
— mirror of the above for local shells.
- createWorkspaceFromTargets(targets, name?) — accepts a mixed list
of {kind:'local',...} / {kind:'host',host} and creates a new
workspace with one pane per target. Defaults viewMode to 'focus'
so the QuickSwitcher flow lands in the sidebar layout.
- All three exported from the hook.
### components/workspace/AddToWorkspaceDialog.tsx (new)
QuickSwitcher-styled multi-select picker:
- Fixed top-center overlay, same chrome as QuickSwitcher (border,
shadow, rounded-xl, borderless search input, bg-primary/15 cursor).
- Two sections: Local Shells (currently just Local Terminal) and
Hosts. Hover follows keyboard cursor.
- Toggle rows with click or Space / Enter; ⌘/Ctrl+Enter submits;
Esc closes. Right-side Check marks visible items.
- Thin footer bar with Cancel + "Add N" button.
### App.tsx
- Root-mounted single instance of AddToWorkspaceDialog with a
discriminated-union state:
{ mode: 'append'; workspaceId } | { mode: 'create' } | null.
- onAdd dispatches based on mode — append loops through the picker
targets calling the two append helpers; create calls
createWorkspaceFromTargets once.
- TerminalLayer's focus "+" now sends an onRequestAddToWorkspace
(workspaceId) up to App instead of owning its own dialog.
- QuickSwitcher's onCreateWorkspace callback repurposed to open the
dialog in create mode (replaces the older CreateWorkspaceDialog
route for this specific flow).
### components/TerminalLayer.tsx
- Dropped the inline AddToWorkspaceDialog + addHostPanelOpen state;
replaced the two append callbacks with a single
onRequestAddToWorkspace prop wired to the "+" button.
- Focus-sidebar header: replaced the "Terminals · N" counter with an
immersive borderless search input (bg-transparent, shadow-none,
termFg color) for filtering the terminal list; "+" and Columns2
buttons moved to the right.
- Session list filtered client-side by the search term across
hostLabel / hostname / username.
### components/QuickSwitcher.tsx
- Re-introduced onCreateWorkspace prop (was removed as unused).
- "New Workspace" inline button (Plus icon + label) sits on the
right of the Jump To hint row: border, rounded, hover bg. Click
fires onCreateWorkspace then closes QS.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Add configurable New Workspace shortcut
Mirrors QuickSwitcher's "+ New Workspace" button via a keyboard
binding so the dialog can open in one keystroke without passing
through QS.
- domain/models.ts: new DEFAULT_KEY_BINDINGS entry id=new-workspace,
action=newWorkspace, default ⌘+Shift+J (Mac) / Ctrl+Shift+J (PC).
Audited the defaults — only quick-switch uses J (⌘+J), so the
shifted combo is free. The binding sits in the 'app' category so
it shows up in Settings → Shortcuts and can be rebound by the user.
- application/state/useGlobalHotkeys.ts: wire newWorkspace into the
HotkeyActions interface, getAppLevelActions() allowlist, and the
global keydown switch so the scheme-driven handler dispatches it.
- App.tsx: handle case 'newWorkspace' inside executeHotkeyAction by
calling setAddToWorkspaceDialog({ mode: 'create' }) — same entry
as QuickSwitcher's button, just without having to open QS first.
- application/i18n/locales/zh-CN.ts: add '新建工作区' translation for
settings.shortcuts.binding.new-workspace. English falls back to
the KeyBinding.label field ("New Workspace"), so no en.ts change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address codex P1: don't check setState flag after the updater returns
Codex flagged that appendHostToWorkspace / appendLocalTerminalToWorkspace
were racy: both flipped an `inserted` flag inside setWorkspaces'
updater and then read it synchronously to decide whether to commit
the matching session via setSessions. React does NOT guarantee
updaters run synchronously (concurrent rendering, StrictMode
double-invoke, etc.), so the flag could still be false at the read
site even though the workspace exists. In that case setSessions was
skipped while the queued workspace update could still insert a new
pane referencing newSessionId — leaving a pane with no backing
session in state.
Fix: add a workspacesRef kept in sync with the workspaces state on
every render, and perform the existence check synchronously *before*
queuing any setState. Once we've confirmed the workspace exists on
the latest committed state, both setWorkspaces and setSessions are
called unconditionally, so they can never diverge.
The ref approach also correctly handles the multi-target append
loop path — React batches the updaters and applies them in sequence,
so sibling pane/session writes land in matching order.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address codex P1+P2: narrow prune rebalance; append in root direction
### P1 — pruneWorkspaceNode over-rebalanced ancestor splits
The equal-sizes rebalance was unconditional during the recursive
walk, so closing a pane deep in one branch also rewrote unrelated
ancestor ratios (e.g., a root 0.8/0.2 vertical split got normalised
to 0.5/0.5 when a grand-child horizontal pane closed).
Now each split level tracks whether it actually lost a DIRECT
child. Only splits where a direct child disappeared get their
siblings reset to equal sizes. Ancestors whose direct children all
survived keep their original ratios (defensively re-normalised in
case a descendant subtree collapsed shape).
### P2 — Append path ignored the root's current direction
onAdd in App.tsx called the two append helpers without a direction,
so both defaulted to 'vertical'. appendPaneToWorkspaceRoot only
flattens into the root split when the directions match; if the
workspace root was horizontal (e.g., user split top/bottom earlier),
each append wrapped the entire existing tree into one side of a new
vertical split — existing panes crammed into one branch, new pane
hoarding half the space.
Read the current root direction out of the target workspace and
pass it down so new panes become peers of the existing root
siblings regardless of horizontal vs vertical.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address codex P2: allow serial hosts in create-workspace picker
The picker used to filter out every host with protocol='serial'
regardless of mode. That was correct for append mode (the
appendHostToWorkspace helper has no serial path and early-returns)
but a regression for create mode — the old createWorkspaceWithHosts
flow passed serial hosts through and createWorkspaceFromTargets
still builds a SerialConfig-backed session for them, so there was
no reason to block them in the "+ New Workspace" entry.
Move the filter from the dialog up to App.tsx:
- AddToWorkspaceDialog drops the serial filter; selectableHosts is
simply the hosts prop.
- App.tsx passes `hosts.filter(h => h.protocol !== 'serial')` when
mode is 'append', and the full list when mode is 'create'.
Result: users can once again build a workspace from serial hosts
via QuickSwitcher's "+ New Workspace" button or the ⌘/Ctrl+Shift+J
hotkey, while append-to-existing keeps its earlier safe behaviour.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address codex P2: don't commit session when append target disappears
Follow-up to the earlier ref-based guard. The ref check eliminates
the common "workspace already gone" case but still leaves a small
race: if closeWorkspace runs between the ref read and setWorkspaces'
updater firing, prev.map returns the unchanged workspaces but
setSessions / setActiveTabId still execute — leaving an orphan
session whose workspaceId points at a deleted workspace and jumping
activeTabId to a closed tab.
Nest setSessions + setActiveTabId inside the setWorkspaces updater
so the writes are gated on the same authoritative match used for
the tree update. The setSessions updater also de-dupes by newSessionId
so React 18 StrictMode's dev-time double-invoke of the outer updater
doesn't append the same row twice. Same pattern applied to
appendLocalTerminalToWorkspace.
The existing closeSession already uses the nested-setState shape, so
this matches the codebase convention.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
d582baaf53 |
Match Settings wordmark style with Vault sidebar (#791)
Settings > Application used `text-3xl font-semibold` on
`{appInfo.name}`, which resolved to lowercase "netcatty" (from
electron's app.getName() / package.json). The Vault sidebar already
renders the brand as `text-xl font-black italic tracking-tight`
with mixed-case "Netcatty", so the two brand surfaces didn't
match — same logo, different wordmark weights and capitalization.
Use the Vault's italic/heavy treatment in Settings too (keeping
the hero text-3xl size) and hardcode "Netcatty" mixed-case so the
wordmark is consistent everywhere the app presents its identity.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
8c1657f1ba |
Polish workspace focus-mode sidebar (#788)
* Polish workspace focus-mode sidebar
- Decouple from side panel position: replace flex-row-reverse on the
outer row with order-last on the side panel itself, so the workspace
focus-mode sidebar and terminal area stay in source order (sidebar
on the left) regardless of whether the terminal side panel is
pinned left or right.
- Make the sidebar width user-resizable. New storage key
STORAGE_KEY_WORKSPACE_FOCUS_SIDEBAR_WIDTH with a useStoredNumber
default of 224px (matches the old w-56), clamped 160..480. Drag
handle sits on the right edge using the same pattern as the side
panel; rAF-throttled mousemove, persisted on mouseup.
- Paint the sidebar with resolvedPreviewTheme.colors.background /
.foreground so it reads as one continuous surface with the focused
terminal's output area instead of a distinct tinted panel. The
border-r is kept as a thin separator from the terminal column.
- Session rows swapped from <div> to RippleButton to match the Vault
sidebar's click ripple feel, and restyled to avoid the old
primary-tinted selection:
* selected: bg-foreground/10 text-foreground (soft neutral over
the terminal-theme sidebar bg)
* unselected: bg-transparent text-foreground/75
* font weight upgrades to semibold on selected; font-size is fixed
* hover:text-inherit pins text color on hover so the ghost
variant's hover:text-accent-foreground doesn't flip the title
color when the cursor passes over a row
- Drop the former `border border-primary/30` selection outline and
the primary-tinted row bg entirely.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address codex P1: use terminal-theme colors for focus sidebar rows
Codex flagged that the session rows were mixing two theme systems:
the sidebar now paints with resolvedPreviewTheme (terminal theme),
but row classes like bg-foreground/10, text-foreground, and
hover:bg-foreground/15 resolve against the app theme CSS vars. With
followAppTerminalTheme off and app/terminal themes diverging (e.g.
light app + dark terminal), row text and selection tint no longer
match the surface and can become low-contrast or invisible.
Derive every row color from resolvedPreviewTheme.colors via
color-mix and apply via inline style:
- selectedBg = foreground 10% over transparent
- selectedHoverBg = foreground 15%
- unselectedHoverBg = foreground 10%
- unselectedFg = foreground 75% mixed toward termBg
- mutedFg = foreground 55% mixed toward termBg (used for
"Terminals · N" counter, switch-to-split icon color, fallback Server
icon, and the username@host secondary line).
- separator = foreground 10% over termBg (right-border and
header bottom-border now use this instead of border-border/50,
which was also app-theme bound).
Hover bg swap goes through onMouseEnter/Leave rather than
hover:bg-* utilities, since Tailwind arbitrary values can't easily
inject color-mix hover variants and we want terminal-theme alpha
either way.
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> |
||
|
|
8ca09b1616 |
Add right-click Edit/Delete to sidepanel snippets (#780) (#787)
The terminal-side ScriptsSidePanel was the surface the #780 reporter was actually looking at when they asked for right-click delete/modify on snippets. PR #783 closed the issue by adding a trash icon in the Vault edit panel, but the sidepanel snippet rows were still plain <button>s with no context menu — so the original complaint ("右键可以弹出一个菜单, 可以包含'删除, 修改'等操作") remained unaddressed at the exact spot the screenshot came from. Changes: - ScriptsSidePanel: wrap each snippet row in a ContextMenu with Edit and Delete items. Menu actions dispatch window events instead of threading new callbacks — matches the existing netcatty:snippets:add pattern the + button already uses. - QuickAddSnippetDialog: accept an optional onUpdateSnippet prop and listen for netcatty:snippets:edit. Prefills label/command/package from the dispatched snippet, and on save preserves the snippet's original tags/targets/shortkey/noAutoRun (the dialog only exposes the three quick-edit fields). Title flips to snippets.panel.editTitle in edit mode. - App.tsx: pass onUpdateSnippet wired to updateSnippets(map-replace), and register a window listener for netcatty:snippets:delete that filters the deleted id out of snippets. Delete needs no UI so it doesn't go through a dialog. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
70b05bfaaf |
New app logo + sidebar ripple + manager UI polish (#786)
* Replace app logo across window icon, tray, splash, and in-app brand
- public/logo.svg: new netcatty mark
- public/icon.png: regenerated 1024x1024 from new SVG (source for
electron-builder — .icns/.ico rebuilt automatically at pack time)
- public/dmg-fix-icon.png: regenerated 1024x1024
- public/tray-icon{,@2x}.png: regenerated color 16/32px for Linux/Windows
- public/tray-iconTemplate{,@2x}.png: regenerated monochrome silhouette
for macOS menu bar (background stripped, foreground flattened to
black on transparent so template-image rendering produces a clean
mask)
- components/AppLogo.tsx: render the new logo as a static <img>. The
old hand-coded inline SVG bound fills to the accent CSS variable;
the new mark has a fixed palette, so callers keep their sizing /
rounding classes via className while the asset itself is a single
file served from /public.
- index.html: splash screen now uses the same /logo.svg via <img>,
with border-radius for the rounded-square frame.
* Polish logo: theme the in-app mark, gloss the OS icon, shrink cat
- components/AppLogo.tsx: back to an inline SVG. Background rect fills
with hsl(var(--primary)) so the in-app brand follows the theme
accent (was fixed navy when imported as <img>). Cat scaled to 68%
of the frame and centred so it doesn't crowd the edges at small
sidebar sizes.
- public/logo.svg + regenerated PNGs: polished OS icon variant with a
large rounded-square clip (rx 224 on 1024), top-left spotlight
radial gradient, subtle top sheen + bottom darkening, and an inner
edge vignette for a slight chamfer. The cat is shrunk to the same
68% as the in-app logo for visual consistency.
- Monochrome tray template (macOS menu bar) is rebuilt from the
shrunk-cat path set with all fills flattened to black; keeps a
clean silhouette instead of a filled rounded square.
* Smooth paws, richer gloss on app icon
- Drop the dark toe/claw detail paths from the source illustration
(indices 22-25, 30, 35, 37, 39 — the ones tracing vertical claw
dividers inside the paws). At small sizes those read as teeth/
claws; paws now render as clean rounded blobs.
- public/logo.svg (OS icon source): richer depth pass —
* two-tone navy vertical gradient (lighter top, deeper bottom)
* brighter upper-left spotlight for glassy highlight
* top sheen + bottom darkening for sheen-across-curve effect
* soft elliptical ground shadow beneath the cat to anchor it
* 2% inner edge stroke to crisp the rounded-square chamfer
- components/AppLogo.tsx: regenerated with the same cleaned cat set,
still themed via hsl(var(--primary)). The in-app mark stays flat
(no gloss) because the effect adds nothing at 20-40px sidebar
sizes and would fight theme accents.
- All raster variants (icon.png, dmg-fix-icon.png, tray color + tray
macOS template) rebuilt from the cleaned sources.
* Respect Apple icon safe area; drop gloss, add thin border
macOS icon was rendering to the full 1024x1024 canvas, so it looked
noticeably larger than neighbour apps (VS Code, Ghostty, Zed) in the
Dock. Apple's Big Sur+ convention puts the artwork body inside an
~824x824 safe area centred in a 1024 canvas, which is how those apps
are sized.
- public/logo.svg: artwork body is now 824x824 centred with ~100px
transparent padding. Corner radius 185 (close enough to the macOS
squircle at Dock scale). Cat rescaled so it keeps the same 68%
proportion within the smaller body.
- Gloss layers (spotlight / sheen / ground shadow / vignette) removed
per request — went for a Ghostty-style clean look instead.
- Thin white inner border (stroke 3px, 22% opacity) outlines the
rounded square for definition.
- Tray PNGs for Linux/Windows keep the full-bleed variant (tray slots
expect the icon to fill the space, unlike the Dock safe area).
- components/AppLogo.tsx unchanged conceptually — it still fills its
own bounding box via hsl(var(--primary)); the Apple safe-area rule
is Dock-specific, not relevant to in-app rendering.
* AppLogo: tighten corner radius to match previous (rx 18.75%)
Previous AppLogo used rx=12 on a 64 viewBox (18.75%). The inline
replacement had rx=224 on a 1024 viewBox (21.9%), which combined
with the caller's rounded-xl class read noticeably rounder in the
sidebar. Drop to rx=192 on 1024 viewBox so the in-app mark matches
the old proportions.
* Beef up icon border so it survives Dock downscaling
3 px at 22% opacity disappeared when rasterised down to ~128 px Dock /
Launchpad size. Bumped stroke-width to 8 px and opacity to 40% so the
inner highlight reads as ~1 px at Dock scale. Stroke is inset by
stroke-width/2 so it sits fully inside the rounded-square body (no
anti-alias bleed outside the safe area). Same treatment applied to the
full-bleed tray variant.
* Enlarge cat inside icon tile (68% -> 85% of body)
Dock render had too much navy margin around the mark. Bump the cat's
scale so it fills 85% of the Apple safe-area body while keeping a
visible bezel to the rounded corners and the inner border. Tray color
variant and macOS template (scale 0.9, no border) follow the same
scale-up.
* Add ripple effect on sidebar nav and tidy logo in vault header
- Add RippleButton wrapper + ripple keyframe; use it for the six vault
sidebar nav entries (Hosts, Keychain, Port Forwarding, Snippets,
Known Hosts, Logs) so clicks get a subtle material-style ripple.
- Shrink vault sidebar AppLogo to h-8 w-8 and drop the outer rounded-xl
so the visible corner comes from the SVG's own rx instead of the
container clip.
- Relax AppLogo tile rx/ry to 144 for a more moderate corner radius.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* AppLogo: bump tile corner radius back up to rx 18.75%
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Unify manager toolbars, tighten tabs and vault sidebar title
- Manager toolbars (Keychain, KnownHosts, PortForwarding, Snippets)
normalised to h-14 / h-10 controls with bg-secondary/80 backdrop-blur
and the shared bg-foreground/5 secondary button treatment, so Hosts /
Keychain / Known Hosts / Port Forwarding / Snippets headers size and
tint identically.
- Keychain filter tabs: drop primary tint and cert-count pill; reuse
the same foreground/5 vs foreground/10 active states as other
managers. Search input grown to h-10 to match.
- Known Hosts: removed the leftover text-xs on Scan System / Import
File so they inherit Button's text-sm like every other action.
- TopTabs: drop the 2px active-accent top line and add rounded-t-md +
overflow-hidden so active tabs read as a clean soft tab shape rather
than a banner.
- VaultView sidebar: wordmark grown to text-xl font-black italic with
tightened tracking; logo gap trimmed from 3 to 2.5; outer bg dropped
from secondary/80 to flat secondary to sit flush against the
toolbars.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
e6ab69b516 |
Vault global search spans all groups/packages (#777) (#785)
* Vault global search spans all groups/packages (#777) Search was scoped to the current group (hosts page) or the current package (snippets page), so a host or snippet the user wanted to find could stay hidden unless they first navigated into the right group — especially confusing with the "root only shows ungrouped hosts" setting enabled. When the search box is non-empty: - hosts: skip the selectedGroupPath / showOnlyUngroupedHostsInRoot filters entirely. Each matching card shows a small outline badge with the host's group so cross-group origin is visible. - snippets: skip the current-package filter. Hide the sub-package grid (would be redundant alongside a flat cross-package match list). Each snippet card shows the package path as a small badge. Tree view already followed this "search crosses groups" shape — see `treeViewHosts` — so this aligns the flat grid/list views with it. * Show no-results feedback when snippet search is empty (#777) Addresses Codex P2 review on PR #785. With the package tile grid hidden during search and no matching snippets, the content area was blank and the global empty state did not render (it requires snippets.length === 0). Add a dedicated no-results panel for the "user is searching and nothing matched but there are other snippets" case, with i18n for en and zh-CN. * Drop group/package badges on search results (#777) Search is itself a filter, so decorating each result card with the group/package it came from added visual noise without adding information. Only difference vs. pre-search rendering now is that the result set spans all groups/packages. * Fix snippet no-results empty state with packages present (#777) Addresses Codex P2 on |
||
|
|
487b7adf3e |
Add 'Set to disabled' button to individual keybindings (#781) (#782)
The keybinding recorder couldn't assign the 'Disabled' sentinel — pressing Esc just cancels. Add a Ban-icon button next to 'Reset to default' that writes 'Disabled' for the active scheme, and render the button label using the localized 'Disabled' string instead of the raw sentinel. |
||
|
|
309996bf3c |
Add delete button in snippet edit panel (#780) (#783)
A right-click Delete already exists in the snippet grid's context menu, but users overwhelmingly open snippets by clicking — and the edit panel had no delete affordance, so many concluded the feature was missing. Surface a Trash2 icon next to Save when editing an existing snippet; it calls the existing onDelete and closes the panel. |
||
|
|
51a6b7efaa |
Preload compact history on first turn after app restart (#753 hedge) (#769)
* Preload compact history on first turn after app restart (#753 hedge) Symptom (confirmed on Copilot CLI, originally reported on Codex in #753): after closing and reopening Netcatty, the AI chat UI still shows the prior conversation but the agent responds "this is the beginning of our conversation, no previous records". Earlier context is lost entirely. Root cause: the bridge relied on session/load throwing "not found" to trigger the catch-block fallback that replays compact history. Some ACP agents (Copilot CLI, some Codex builds) silently spawn a new session when handed a stale id instead of erroring. The catch-block never fires → historyReplayFallback stays false → the first turn sends only the latest prompt → agent sees zero context. Fix: when we're creating a new provider process AND telling it to resume an existing session id AND the renderer gave us compact history, preload historyReplayFallback=true as a hedge. If the agent really did reload the session, the replay is ~3KB of redundant context (small waste). If the agent silently started fresh, the replay restores durable constraints + last few raw turns so the first response is coherent. After the first successful streamed turn clears the flag (the round-2 post-stream hook), steady state is back to sending only the latest prompt. Cost is bounded to one replay per app-restart-and-prompt. Test: "replays compact history on the first turn after app restart even when session/load 'succeeds'" — mocks createACPProvider to behave like Copilot CLI (no error thrown, no real resume), asserts the first streamText call carries history+latest (length 2) and the second only latest (length 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix AI session resume and agent switching * Preserve hidden draft when switching agents --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
30f5346035 |
Classify AI proxy / size-limit errors instead of showing raw Zod output (#765) (#768)
Symptom: when an AI request is proxied through nginx (or any gateway)
and the request body exceeds client_max_body_size, the proxy returns a
413 HTML error page. The Vercel AI SDK then fails to parse the HTML
as a chat completion and surfaces a cryptic Zod validation error like
"Expected 'id' to be a string." through the UI — users have no idea
what's wrong.
Root cause: classifyError only did light sanitization and returned the
raw SDK message. It also string-coerced the error before inspection, so
the structured statusCode / responseBody fields that APICallError
attaches were thrown away.
Fix: classifyError now accepts `unknown` and inspects the full error
shape. Adds explicit branches for:
- HTTP 413 (from statusCode, cause.statusCode, or message text) →
"Request too large — exceeded proxy size limit. Try shorter
message, fewer attachments, or raise client_max_body_size."
- HTTP 502/503/504 → retryable upstream-gateway message
- HTML response body (starts with <!DOCTYPE/<html> or contains such
tags anywhere) → "Server returned HTML error page, likely a proxy
intercept."
- Zod/schema parse shapes ("Expected 'X' to be …", "Invalid JSON
response", "Type validation failed") → "Response could not be
parsed; proxy may have replaced/truncated the body."
In every classified case the raw SDK text is still appended ("Raw: …")
so users can report the underlying error verbatim.
useAIChatStreaming.ts callers now pass the raw error to classifyError
instead of `.message`, so the new structured branches actually fire.
Also wired infrastructure/ai/*.test.ts into the npm test glob.
Closes #765
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
0425841032 |
Fix ACP history replay and compaction (#754)
* Fix ACP history replay and compaction * Fix PR keyword importance matching Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address codex review on #754: preserve short constraints + cancel-clear Two recovery-path regressions flagged by codex review: 1. Compact ACP history dropped short load-bearing user constraints (acpHistory.ts:55). The blanket length<10 rule treated short non-trivial messages like "Use ssh2" or "中文输出" as filler, while longer generic follow-ups still ate the budget. After stale-session recovery the fresh ACP session would resume without constraints that were present in the original chat. Removed the length heuristic; the TRIVIAL_USER_MESSAGE_PATTERNS regex already filters actual filler ("ok", "yes", "继续", "thanks"). 2. historyReplayFallback was only cleared on non-aborted streams (aiBridge.cjs:2837). If the user stopped the first turn after stale-session recovery, the flag stayed set. The next turn would then trigger shouldResetProviderForHistoryReplay, discard the freshly recovered ACP session (resumeSessionId is forced to undefined in that path), and re-spend tokens on another compact replay — breaking the cancel-preserves-session contract. Now we also clear on abort; the empty-but-not-aborted retry path in the if-branch above is unchanged. Tests: - New test in acpHistory.test.ts asserts "Use ssh2" / "中文输出" survive when pushed outside the recent raw window - New test asserts "ok" / "继续" still drop (sanity check that the trivial regex still does its job without the length backstop) - Updated "does not treat pr inside ordinary words as important" to no longer assert that approach/improve/prepare are absent — the test's real intent (priority-2 line still wins) is preserved by the 不要提交 assertion - New test in aiBridge.test.cjs simulates a user cancelling the first turn after recovery and verifies the next turn reuses the recovered session (no extra provider creation, no re-replay) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address codex re-review: preserve replay flag across orthogonal recreation + keep tool output in raw window Two more P2 regressions flagged on the second review pass: 1. historyReplayFallback was only carried over in the reset-for-replay branch of the provider recreation path. An orthogonal change between an empty recovered turn and its retry — a permission-mode toggle, MCP scope/fingerprint flip, or auth rotation — would flip shouldReuseProvider to false, enter the !shouldReuseProvider branch, and drop the flag because preserveHistoryReplayFallback only covered the shouldResetProviderForHistoryReplay case. The next turn then sent only the latest prompt and lost the recovered conversation. Now the flag is preserved on any recreation where a replay is still pending. 2. Tool messages didn't flow through toRawHistoryMessage at all, so on stale-session recovery they only survived as the 500-char compact summary in summarizeToolMessage. Any follow-up referencing the last tool output ("use that output", "what did cat show?") lost the actual bytes when they exceeded the compact cap. Now tool results travel through the recent raw window up to MAX_RAW_MESSAGE_CHARS (2000), flattened to the "assistant" role since ACP only accepts user/assistant. Tests: - aiBridge.test.cjs: new "preserves history-replay across provider recreation caused by permission-mode / MCP / auth change" — exercises the gap via a permission-mode toggle between an empty recovered turn and its retry. Extends mock to support a dynamic getPermissionMode. - acpHistory.test.ts: new "preserves recent tool results verbatim" — pushes a ~1500-char tool output through the pipeline and asserts the replay still contains enough bytes to exceed the 500-char compact cap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address codex round 3: inline tool_call context + bound durable scan Two findings from the third codex review pass, both legitimate: 1. [P2] When the raw window starts mid-tool-interaction, the preceding assistant tool_call message can fall outside the 6-item slice while the tool_result stays in. Without the call's name+arguments, the result was opaque bytes and follow-ups like "use that output" had no provenance. The compact pass only preserved calls that matched IMPORTANT_PATTERNS, so read_file / grep / terminal_exec were silently dropped. Fix: build a toolCallId → { name, arguments } index from every assistant message and inline a `[from <name>(<args>)]` label next to each Tool result line in the raw window. Args are truncated to MAX_TOOL_CALL_LABEL_CHARS (200) so a verbose JSON payload can't eat the entire raw budget. 2. [P3] buildCompactContext scanned messages.entries() over the full transcript for durable-user/assistant candidates, even though MAX_MESSAGES_TO_SCAN (20) suggested the path was meant to be bounded. On a long ACP chat, every send did O(N) regex work plus an O(N log N) sort — the very chat-length-dependent latency the token-compaction PR was meant to address. Fix: introduce MAX_DURABLE_SCAN_MESSAGES (200) and restrict the durable scan to that tail. 200 is large enough to cover realistic sessions (99th-percentile chats are << 200 turns) while giving a constant-time worst case. Constraints older than the window age out of the compact replay; the live ACP provider's own persisted session still carries them when it can resume, which is the common path. Tests: - "inlines tool_call name+args so tool_result is interpretable without the preceding assistant turn" — pushes the tool_call out of the raw window and asserts the result line carries [from <tool>(<args>)]. - "bounds the durable-candidate scan to avoid O(N) work per send on long chats" — builds a 600+ message chat with an ancient priority-2 constraint outside the scan window and a recent one inside; asserts only the recent one survives. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address codex round 4: preserve short assistant decisions + provenance on older tool results Two P2 findings from the fourth codex pass, both mirror-images of earlier fixes on a different code path: 1. Short assistant decisions dropped from compact replay (acpHistory.ts:75-83). isSubstantiveAssistantMessage required length >= 40 OR a small English keyword match OR a numbered list. Short but load-bearing replies like "Use ssh2", "rebase instead", "中文输出" satisfied none of those and were silently dropped from the durable- assistant compact section. Once they fell outside the 6-item raw window, "do what you suggested earlier" would replay only the user question without the assistant's actual decision. Fix: mirror the user-side loosening — drop the length/keyword gate, rely on TRIVIAL_ASSISTANT_MESSAGE_PATTERNS to filter actual filler ("ok", "ack", "got it", "明白"). 2. Older tool results lost provenance (acpHistory.ts:108-114). The raw-window fix (round 3) only covered the last 6 items. Once a tool result fell into the compact section via summarizeToolMessage, the paired assistant tool_call was usually gone too, so multiple older outputs surfaced as indistinguishable "Tool result (callN): ...". Follow-ups like "use the resolv.conf output" had no way to map to the right call. Fix: plumb the toolCallIndex through summarizeMessage → summarizeToolMessage and inline `[from <name>(<args>)]` labels in the compact section too, the same shape the raw window uses. Tests: - New: preserves short non-trivial assistant decisions that miss the keyword heuristic (Use ssh2 / 中文输出 / rebase instead) - New: still drops trivial assistant filler like 'ack' / 'ok' / '明白' - New: inlines tool_call context on OLDER summarized tool results - Updated earlier raw-window tool regex tests to match the [from X(Y)] shape ([^)] was failing to cross the args JSON's closing paren) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address codex round 5: de-dup raw ∩ compact + wire userSkills test into npm test [P2] The scanned loop (last 20) overlaps with recentRaw (last 6), so without a raw-window skip in the summarizeMessage path the same last-6 turns were summarized into the compact section AND appended verbatim in the raw section. Important user turns and large tool output paid the budget twice — eating into the 3k compact cap and crowding out older durable context the replay is meant to preserve. Added the same recentRawSourceIds skip the durable-user / durable-assistant passes already use, and a regression test that asserts markers inside the raw window don't surface in compact while still appearing in raw. [P3] electron/bridges/ai/userSkills.test.cjs (added by this PR) sat in a subdirectory that the default "npm test" glob (electron/bridges/*.test.cjs) didn't pick up. The new routing / index-budget regressions would never run locally or in CI until someone noticed. Extended the glob to also match electron/bridges/*/*.test.cjs; the userSkills tests are now included in the 148-test run. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address codex round 6: cancel+immediate-send race + tool-call id collision Two P2 regressions in the recovery path: 1. If the user clicks Stop and immediately sends the next prompt, the new stream handler's existingRun path unconditionally called cleanupAcpProvider — destroying the fresh ACP session the cancel IPC had just promised to preserve. The round-2 clear-on-abort fix ran too late (in post-stream code) to help, because the new stream can arrive before the aborted stream fully unwinds. In that common timing window the follow-up still started from a bare provider and lost all recovered conversation state. Fix: (a) cancel IPC now synchronously clears historyReplayFallback on the preserved provider entry, so the next stream can't trigger shouldResetProviderForHistoryReplay and tear the session down via that path; (b) the existingRun path skips cleanupAcpProvider when the prior run was already cancelled via the cancel IPC (captured via existingRun.cancelRequested before we overwrite it). True interrupt-and-restart without an explicit cancel still falls back to the old clean-slate behavior. 2. The tool-call provenance index used raw toolCall.id as the key. Nothing in ChatMessage or the ACP event path enforces per-chat unique ids, so a provider reusing "call1" across turns would overwrite the older entry and mis-label older tool results (e.g., an /etc/hosts result annotated as /etc/resolv.conf in the compact summary). That makes stale-session recovery misleading whenever a follow-up refers back to an earlier tool output. Fix: key the index by `${toolResultMessageId}:${toolCallId}` and walk the message stream in order, resolving each tool_result to the most recent preceding assistant tool_call with matching id. Each result keeps its own historically-correct label regardless of later id reuse. Tests: - aiBridge: "preserves recovered ACP session when user cancels then immediately sends the next prompt" — fires the next stream request after cancel but BEFORE releasing the first stream's blocked read, asserts providerCreationArgs.length stays at 2 (no third creation) and the second turn sends only the latest prompt. - acpHistory: "resolves tool_call provenance correctly when tool ids are reused across turns" — two interactions sharing id "call1", asserts each tool_result carries its own call's args label. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address codex round 7: turn-based scan bound + single-pass history build Two P2 regressions in long-chat / tool-heavy recovery paths: 1. MAX_DURABLE_SCAN_MESSAGES (200) bounded the scan by raw message count. ACP tool interactions store the user turn, assistant tool_call turn, and each tool_result as separate messages, so a tool-heavy chat can produce 5+ messages per logical turn. 200 messages could be only 30-40 user turns — early constraints like "不要提交" from turn 5 fell out of the compact replay long before the turn count justified aging them out. Fix: bound by MAX_DURABLE_SCAN_TURNS (100 user turns) instead. Walk backwards from the end and stop after seeing 100 user messages. Realistic tool-heavy 30-turn chats now keep their early constraints alive, while true 100+ turn chats still benefit from the bound. 2. buildToolCallIndex(messages) and messages.flatMap(...).slice(-6) both walked the entire transcript on every send, even after the bounded compaction window landed. Compaction's stated purpose was to remove chat-length-dependent latency, but these per-send linear passes kept it. Fix: compute the scan start once via computeDurableScanStart, then do all subsequent work over messages.slice(durableScanStart). buildToolCallIndex walks only the window; the raw-6 flatMap also runs over the window. On a 1000-message chat with 100-turn window, send-time cost drops from O(1000) to O(~window_size). Acceptable trade: if a tool_call's matching tool_result straddles the window boundary (result inside, call outside), the single surviving result loses its [from X(Y)] label. Tool_calls and their results are almost always adjacent, so this affects at most the first 1-2 messages of the window. Tests: - "preserves an early constraint in a tool-heavy chat where message count balloons past the raw-count limit" — 35 turns × 6 msgs/turn = 212 messages. The old bound would have dropped the early EARLY_CONSTRAINT_MARKER; with turn-based bound it survives. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
156550f7eb |
Add Close All / Others / To-the-Right tab actions (#748) (#764)
Adds three bulk-close items to the right-click context menu on tabs: - Close Others - Close Tabs to the Right - Close All Anchor is the right-clicked tab (matches VSCode/JetBrains/FinalShell UX), not the active tab. The "to the right" item is disabled when the anchor is already the rightmost tab; "Close Others" is disabled when it's the only tab. To avoid spamming a busy-shell modal per tab, the new closeTabsBatch helper in App.tsx expands workspace ids into their session ids, runs ONE confirmIfBusyLocalTerminal probe across the whole batch, and only proceeds when the user confirms. The probe + close path itself reuses the existing PR #739 plumbing (ptyProcessTree + confirmCloseBusy). Closes #748 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> |
||
|
|
f6f3147afb |
Tab bar: duplicate-adjacent insertion + wheel-to-horizontal scroll (#743)
* Improve tab UX: insert duplicated tabs adjacent to source, enable wheel scroll on tab bar Addresses #737. - Duplicating a tab now inserts the new tab immediately after the source in the tab order, instead of appending it to the far right where it was hard to find with many tabs open. - The top tab strip now translates vertical mouse-wheel deltas into horizontal scrolling, so users with many tabs can reach the ends of the strip without dragging. Trackpad gestures that already carry horizontal delta are left alone to preserve native two-finger swiping. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address Codex review: read source session inside functional updater Codex flagged that reading `session` from the closure broke the atomicity guarantee of the previous implementation — rapid repeated duplicates could miss freshly queued state. - Pre-allocate the new session id outside both setters so it stays stable across StrictMode double-invocations. - Move the source lookup back into `setSessions`' functional updater so it always reads the freshest committed/queued state. - Drop `sessions` from the useCallback dependency list now that we no longer read it. - Fast-path tabOrder insertion when the source is already in tabOrder to avoid re-deriving the full effective order in the common case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Address Codex review: gate active-tab and tab-order updates on successful create Codex flagged that `setActiveTabId(newSessionId)` and `setTabOrder(...)` ran unconditionally even when `setSessions` bailed out (source tab was closed before the duplicate handler ran). That left activeTabId pointing at an id that was never appended to sessions, putting the terminal layer into an invalid "no matching tab" state. Move both nested setState calls inside the `setSessions` functional updater so they only fire when the source is actually present. Mirrors the original pre-PR pattern; nested updates are idempotent so StrictMode's double-invocation is harmless. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
54b26511a1 |
Cloud sync data-loss prevention (4-layer defense) (#742)
* feat(sync-guard): extend SyncState with BLOCKED + add shrink event variants
* feat(sync-guard): add detectSuspiciousShrink pure function with 12 unit tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* polish(sync-guard): drop unnecessary cast, sharpen test naming, pin priority invariant
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(test): include domain/*.test.ts in npm test glob
* feat(sync-guard): gate syncToProvider with shrink detection + force-push override
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): reset overrideShrinkOnce before early return for invariant strictness
* fix(sync-guard): extend shrink guard to syncAllProviders (the actual sync entry point)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(sync-guard): apply empty-vault guard uniformly to auto and manual sync
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(sync-guard): preserve merge base on same-account re-auth
Adds providerAccountId persistence; completePKCEAuth and completeGitHubAuth
now only clear syncBase/anchor when the authenticated account id differs from
the previously stored one, preventing zombie-entry resurrection on token
refresh. disconnectProvider clears the stored id so a reconnect starts fresh.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(sync-guard): add i18n strings for sync-blocked banner + force-push modal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(sync-guard): add SyncBlockedBanner showing shrink findings with restore/force-push actions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): stable subscribeToEvents reference + type-safe finding narrowing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(sync-guard): force-push confirmation modal + scroll restore button into view
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* ux(local-backups): show version as title, demote reason+timestamp to meta line
* feat(local-backups): record + display sync data version (v5/v6...) on each backup
Each backup now captures the live CloudSyncManager.localVersion at creation
time. UI shows it as title (v5, v6, ...) with timestamp + reason demoted to
the meta line. Backups created before this field existed (or before any
successful cloud sync) fall back to timestamp as title.
Replaces the earlier app-version-transition title which conflated app
version with sync data version.
* fix(sync-guard): consume override flag at sync entry + restore provider status on block
- Snapshot+clear overrideShrinkOnce at top of syncToProvider and
syncAllProviders so an early-return cannot leak the flag to a later
unrelated sync (Codex P1).
- Restore provider status to 'connected' when shrink-block returns from
syncToProvider; previously left provider stuck on 'syncing' in the
UI (Codex P2).
- Process pre-existing check errors before returning from the
shouldBlockAll branch in syncAllProviders so a check-failed provider
isn't dropped from results (Codex P2).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): refactor force-push to parameter passing + add credential-availability guard
The previous design used a one-shot boolean flag on CloudSyncManager set
by forcePushOverrideShrink(). Even with snapshot+clear at sync entry
points, the renderer wrapper's await ensureUnlocked() could throw before
the flag was consumed, leaving it armed for the next unrelated sync.
Fix: pass overrideShrink as a call-time parameter through the chain.
Eliminates the persistent flag and its leak surface.
Also: force-push now runs the same ensureSyncablePayload(...) guard the
other manual sync entry points use, so a vault with encrypted-credential
placeholders won't be uploaded via the force path either.
Addresses the latest two Codex P1/P2 findings on #742.
* fix(sync-guard): backfill account id from in-memory state for upgrade-path re-auth
Users upgrading to this PR have no netcatty.sync.accountId.* persisted yet.
On their first re-auth the guard saw previousId=null and cleared the
merge base anyway, defeating the point of the same-account preservation.
Snapshot the in-memory account id BEFORE overwriting providers[provider]
and use it as a fallback when the persisted id is missing. New users
(no prior connection at all) still get the clear-on-first-auth path.
Addresses Codex P1 on #742.
* fix(sync-guard): inspect force-push results + mark blocked single-provider as error
- Force-push handler now inspects syncNow result entries: applies any
mergedPayload to local state, only clears the banner when all providers
report success, surfaces a toast error otherwise. Previously the banner
cleared unconditionally regardless of network/auth failures (Codex P1).
- syncToProvider shrink-block branches now mark provider status as
'error' with a 'Sync blocked: would delete too much' message instead
of 'connected'. Status aggregators treat 'connected' as healthy, so
the blocked upload was surfacing as 'synced' in the UI (Codex P2).
syncAllProviders already used this pattern; this brings the
single-provider path in line.
* fix(sync-guard): exempt USE_LOCAL conflict + clear post-merge BLOCKED + expose 'blocked' status
- USE_LOCAL conflict resolution now passes { overrideShrink: true }: the
conflict modal already served as user confirmation, and shrink-blocking
it left users with a closed modal and an opaque banner (Review C-1).
- Post-merge round-trip in useAutoSync now detects shrink-blocked results
and resets syncState to IDLE via new manager.clearShrinkBlockedState().
The merged data is already applied locally; the next user-triggered
sync will re-check, and we don't wedge the manager in BLOCKED with no
visible banner outside the Settings tab (Review I-1).
- overallSyncStatus now reports 'blocked' as a distinct value from
'error', so downstream UI (status icon, future badges) can offer
shrink-block-specific affordances (Review I-2).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): stabilize banner subscription dep + map 'blocked' status to error indicator
- The SyncBlockedBanner subscription useEffect depended on [sync] (the
whole hook return object), which gets a new reference every render.
This caused the listener to be unsubscribed+resubscribed on every
render, opening a tiny race window where a SYNC_BLOCKED_SHRINK event
could be missed and the banner would never appear. Destructure
subscribeToEvents (already useCallback-stable) and depend on it
directly, so the effect runs exactly once on mount.
- SyncStatusButton's status mapping had no arm for the new 'blocked'
value, falling through to 'none' (idle). The global status indicator
said healthy while the in-page banner said paused. Map 'blocked' to
the same error indicator used for 'conflict' so the UI is consistent.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): only clear banner on actual success + hydrate from manager state
- Banner subscription now clears only on SYNC_COMPLETED with result.success.
SYNC_STARTED (auto-sync timer ticks) and SYNC_FORCED (fires BEFORE upload)
could clear the banner prematurely, removing the user's recovery affordance
while the underlying issue was unresolved (Codex P2).
- Manager now persists the last shrink finding in state.lastShrinkFinding
alongside the SYNC_BLOCKED_SHRINK emission. New public getter
getShrinkBlockedFinding() returns it when syncState is BLOCKED. Renderer
hydrates the banner on mount so a block that happened off-screen
(auto-sync while user was on another tab) is still visible when they
open Sync Settings (Codex P2).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): unified BLOCKED-cleared event + USE_LOCAL inspects results
- USE_LOCAL conflict resolution now inspects syncNow() results, applies
any mergedPayload to local state, surfaces a toast error and KEEPS the
modal open on failure (so user can switch to USE_REMOTE). Mirrors the
force-push handler pattern. Without this, USE_LOCAL silently 'succeeded'
even when providers failed (Codex CLI P1).
- New SYNC_BLOCKED_CLEARED event emitted on every BLOCKED -> non-BLOCKED
transition via a private exitBlockedState() helper. Banner subscribes to
this single signal instead of guessing from per-provider SYNC_COMPLETED
events. Fixes:
- Multi-provider scenarios where first SYNC_COMPLETED clears the banner
while a later provider was still going to fail (Codex CLI P1).
- clearShrinkBlockedState() (post-merge self-heal) silently leaving
the banner stuck because no event was emitted (Codex CLI P2).
- disconnectProvider() now also exits BLOCKED state. Disconnecting
implicitly resolves any pending shrink-block warning, otherwise the
stale alert carried over to the next-account reconnect (Codex CLI P2).
- All BLOCKED -> non-BLOCKED transitions consolidated through
exitBlockedState() so lastShrinkFinding cleanup + event emission are
always paired (Codex CLI P3 #6 covered).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(sync-guard): only clear BLOCKED on actual success, not on transient ERROR/SYNCING/CONFLICT
Previous patch called exitBlockedState() at every BLOCKED -> non-BLOCKED
transition, but this clears the banner on transitions that don't actually
resolve the shrink concern:
- SYNCING (sync just started — about to try, may fail)
- ERROR (transient transport failure, shrink concern still real)
- CONFLICT (separate concern; doesn't resolve the shrink)
If a user was in BLOCKED then triggered a sync that failed for an unrelated
reason (network, auth), the banner cleared and they lost the warning.
Restrict exitBlockedState() to terminal-success transitions:
- IDLE on successful upload (data made it to cloud — concern resolved)
- explicit clears (disconnectProvider, clearShrinkBlockedState)
- conflict resolution (USE_REMOTE/USE_LOCAL also end in IDLE)
Found by Codex CLI review of commit
|
||
|
|
8ef91e1266 |
Ctrl+W close priority + local shell busy confirmation (#739)
* feat(ctrl-w): add ps-node + windows-process-tree + tsx deps for close-priority feature * fix(ctrl-w): drop ps-node dep and add windows-process-tree to asarUnpack Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add ptyProcessTree bridge with per-platform child-process enumeration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): ptyProcessTree uses args= for full command + warns on pid overwrite - Replace `comm=` with `args=` in defaultListPosix so the full command line is captured on both macOS (BSD ps) and Linux (GNU ps), avoiding the 15-char TASK_COMM_LEN truncation. - Add console.warn in registerPid when the same sessionId is overwritten with a different pid, making the race condition visible in logs. - Add test: registerPid warns exactly once on a pid change, not on a same-pid re-registration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): register local PTY pid with ptyProcessTree on spawn/exit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): unregister pids in cleanupAllSessions to match per-delete invariant Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add IPC handlers for pty child processes and confirm-close dialog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): guard BrowserWindow.fromWebContents null and document dialog dismiss contract Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): expose ptyGetChildProcesses and confirmCloseBusy on window.netcatty Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add i18n strings for close-busy-terminal dialog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): add resolveCloseIntent pure function with 8 unit tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): expose handleCloseSidePanel via ref to App.tsx Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): wire resolveCloseIntent + local-shell busy confirmation into closeTab hotkey Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ctrl-w): add re-entrancy guard, aggregate busy count, sync sidebar ref, dedupe intent branches Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ctrl-w): auto-close workspace when its last session is closed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): sidebar close wins over focused terminal in priority chain Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): sidebar priority applies to single-session tabs too, not just workspaces Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ctrl-w): compute empty-workspace auto-close outside setSessions updater Addresses Codex P2 on #739: React 18+ does not guarantee updater execution timing under concurrent scheduling. Moving the decision outside the updater makes the microtask queue deterministic. --------- Co-authored-by: Claude Sonnet 4.6 <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 |
||
|
|
3a748aa1aa | fix serial duplicate host save (#732) | ||
|
|
4574f1e2b2 |
fix: stabilize scoped AI draft/session transitions (#724)
* fix: correct terminal AI history resume behavior
The previous implementation plan mistakenly treated reopening an old terminal AI session in a fresh or reconnected SSH tab as a scope-retargeting feature.
The intended rule is draft-first:
- a fresh or reconnected terminal opens on a blank draft
- older chats remain available in history for manual access
- selecting history does not imply automatic scope transfer into the new tab
This change is a rule correction, not a conflict between product rules.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: harden ai draft transitions
* fix ai session continuation from history
* fix: clear stale activeSessionIdMap entry when view resolves to draft
Addresses the Codex P2 review on aiPanelViewState.ts:38. When a terminal
scope mounts with a persisted activeSessionIdMap entry but no explicit
panelView and no draft, resolveDisplayedPanelView now returns the
default draft view (terminal fresh-start behavior). The sync effect
that writes into activeSessionIdMap is guarded by `if (!activeSession)
return`, so the old entry stays put. That stale entry then leaks into
activeTerminalTargetIds in every other scope, and
getSessionScopeMatchRank uses it to suppress host-matched history that
is actually resumable — so valid sessions vanish from the history
drawer until another action rewrites the map.
Add a dedicated effect that clears the scope's activeSessionIdMap
entry whenever the resolved panel view is draft but a persisted
session id is still present. This keeps the map an accurate record of
"which session each scope is currently showing" instead of a lagging
snapshot.
Also extend sessionScopeMatch.test.ts to cover the rank=2 exact-match
branch and the scope-type mismatch short-circuit, which were missing
from the original suite.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: track cross-terminal session ownership by session id, not targetId
Addresses the Codex follow-up review on commit
|
||
|
|
081b167172 |
feat(ai-chat): fit-to-content popovers + keyboard nav for @/slash menus (#726)
* feat(ai-chat): fit-to-content popovers and keyboard nav for @/slash menus - Shrink the @ host and /skill popovers to their content width (auto width with min 220px, capped at the input width) instead of always filling the full input width, which left large empty gutters when the list was short. - Add keyboard navigation: ArrowUp/ArrowDown cycle through items, Enter commits the highlighted item, Escape closes the menu. Mouse hover stays in sync with the active index so keyboard and pointer agree on which row is current. Enter does not fall through to submit while a menu is open. - Expose aria-selected / aria-activedescendant for screen readers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * style(ai-chat): tone down popover radius to match other menus The @ and /skill popovers used rounded-[20px]/rounded-[16px] which stood out against every other popover in this file (rounded-lg with rounded-md items). Switch to the shared radii and drop shadow-2xl for the standard shadow-lg so the surface feels consistent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * style(ai-chat): tighten mention popover spacing - Drop the redundant "Hosts" / "User Skills" header row — the @ or / trigger already makes the popover's purpose obvious, and the header added ~30px of vertical whitespace above a single-line list. - Shrink wrapper and item padding (p-2.5/px-3 py-1.5 -> p-1/px-2 py-1) and remove the mt-0.5 gap between title and subtitle. - Hide the hostname subline when the label already contains the hostname (common case: "Rainyun-114.66.26.174" as label and "114.66.26.174" as hostname — no need to repeat). - Lower minWidth 220 -> 200 so short lists can shrink further. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ai-chat): address Codex review on PR #726 - Reset active menu index on any change to the *set* of visible items, not just its length. Watching only `.length` let Enter commit a different item when the slash query changed to a same-sized match set. Derive a stable identity key (sessionIds / skill ids) and use that as the effect dep instead. - Clamp the popover's minWidth to the measured panel width so narrow layouts don't end up with minWidth > maxWidth, which CSS resolves by honoring min and clips the menu off-screen. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
5bc5a6c8b2 |
fix: address Codex follow-up review on PR #720 (#723)
* fix: address Codex follow-up review on PR #720 Two issues surfaced by Codex's post-merge review of PR #720: P1 — useAutoSync.ts: startup retry exhaustion wedged auto-sync. The retry effect previously returned at `attempt >= 4` without opening `remoteCheckDoneRef`. A session with persistent inspect failures (long network outage, provider rate-limit loop) left auto-sync silently disabled for the rest of the session until restart or provider/unlock transition. After exhaustion, open the gate: the specific dangers we gate-closed against (empty-push, partial-apply push) are now covered by independent guards (`hasMeaningfulSyncData`, the apply-in-progress sentinel, and `checkProviderConflict`'s inspect-failure throw at upload time). This matches manual sync's existing semantic rather than silently strict-gating auto-sync. P2 — CloudSyncSettings.tsx: restore buttons were per-row disabled, not globally. A user could click Row A, then Row B while A was still applying — two concurrent `applyProtectedSyncPayload` calls in the same window. `withRestoreBarrier` serializes across windows but NOT same-window re-entry, so the second restore's sentinel-clear could mask a still-partial first apply. Disable every restore button while any restore is in flight. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: keep auto-sync gate closed on retry exhaust; open on manual sync Codex's re-review of PR #723 correctly flagged that opening the auto-sync gate after startup retry exhaustion reintroduces the destructive-clobber path the gate was supposed to prevent. Concrete scenario: local vault is partially lost (non-empty, just missing entries), remote has not changed since our last anchor, user edits a field after a long outage → auto-sync pushes the partially-lost vault over the intact remote. `checkProviderConflict` doesn't catch this (anchor matches), `hasMeaningfulSyncData` doesn't catch this (non-empty), and the empty-vault prompt doesn't fire. Revert the retry-exhaust gate-open. The gate now stays closed until either: 1. A startup `checkRemoteVersion` succeeds (normal path), OR 2. A `syncNow` completes successfully. A manual sync from Settings implicitly runs per-provider `checkProviderConflict` — the same inspect the startup path would have done — so a successful manual sync is equivalent to a successful startup reconciliation from the gate's point of view and opens the gate for the rest of the session. This preserves Codex's safety ask (no auto-push without a confirmed remote state) while giving the user a clear escape hatch (manual sync) that doesn't require a restart. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
6c8a39d269 |
feat: add stable CSS hooks to tab components (#714) (#722)
* feat: add stable CSS hooks to tab components (#714) Expose stable attributes on every tab-like element so custom CSS can target them reliably without chaining utility-class selectors or relying on inline-style substring matches: - data-tab-id: already present on session/workspace/logView/sftp tabs; now also added to the side-panel buttons (sftp/scripts/theme/ai) in TerminalLayer.tsx. - data-tab-type: session | workspace | logView | sftp | sidepanel, lets a selector target one tab family without matching the rest. - data-state: active | inactive, mirroring Radix Tabs' convention so users who already style Settings tabs can reuse the same idiom. - .netcatty-tab class: a single, scope-free hook for "every tab, anywhere" — pairs with data-state="active" for the common "style the selected tab" recipe. No visual changes. The existing inline-style / utility-class selectors the issue reporter had to chain ([style*="var(--top-tabs-active-bg"], .app-no-drag.relative.h-7.px-3, etc.) keep working, so no breakage for people who've already written custom CSS. Custom CSS can now be written as: .netcatty-tab[data-state="active"] { ... } [data-tab-type="sftp"][data-state="active"] { ... } [data-tab-id="ai"][data-state="active"] { ... } Closes #714 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add CSS hooks to the root Vaults/SFTP tabs (#714) The fixed-left root tabs ("Vaults" and "SFTP") in TopTabs.tsx were missed in the first pass — they don't go through the session / workspace / logView branches, so their div rendered without the new data-tab-id / data-tab-type / data-state attributes or the .netcatty-tab class. Add them so custom CSS can target the whole root tab row the same way: [data-tab-type="root"][data-state="active"] { ... } [data-tab-id="vault"] { ... } [data-tab-id="sftp"] { ... } No visual change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
db69d5ac39 |
[codex] Harden sync overwrite protection and add local restore history (#720)
* fix: harden sync overwrite recovery * refactor: separate backup retention settings * refactor: align backup retention controls * refactor: simplify backup retention card * fix: address PR #720 deep-review findings - Close the cross-window restore race by holding a time-bounded barrier in localStorage during every destructive apply; useAutoSync skips pushes while it's set, preventing a pre-restore snapshot from clobbering just-restored cloud data. - Round-trip startup three-way merges so merged-in local additions actually reach the cloud instead of living only on the device that ran the merge until the next edit. - Upgrade sync signatures from a 64-char ciphertext prefix to full SHA-256 (v3), closing the tail-mutation replay weakness. - Harden the vault-backup IPC: payload size cap, enum-validated reason, sanitized version strings, strict maxCount, concurrent-call mutex, monotonic createdAt to avoid same-ms ordering ties. - Extract the anchor-change decision into a pure module with unit tests covering no-anchor, resource-id drift, and signature mismatch paths. - Capture the protective backup from the pre-apply closure snapshot so it reflects what's being replaced rather than what was imported. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address PR #720 follow-up review findings Make protective backup abort-on-failure (was best-effort console.error), preserve nested syncedAt in fingerprint, use UTF-8 byte length for size guard, throw on conflict-inspect failure so stale uploads can't leak through, treat unreadable remote as changed, canonical-JSON signature meta, and hold the version stamp on transient backup failures so the retry path still fires. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address second-pass review findings on PR #720 - Hold version-change stamp when payload is non-meaningful (covers the startup vault-rehydrate race where a transient empty snapshot would permanently skip the upgrade backup). - readBackupRecord stat-checks before readFile so an oversized file in the backup dir cannot OOM the renderer on enumeration. - Reject maxBackups input outside 1..100 instead of silently clamping (matches the i18n error copy and the main-process sanitizer bound). - Wrap USE_LOCAL conflict-resolution push in withRestoreBarrier so a concurrent auto-sync in another window cannot interleave. - sha256Hex throws SyncSignatureUnavailableError on missing WebCrypto subtle; createSyncedFileSignature returns null, forcing the unreadable-remote → three-way-merge path instead of a weak length-only pseudo-signature. - Document that array order in normalizePayloadForHash is an invariant enforced by producers, not the hash function. - Drop three-way-merge completion logs from console.log to console.info. - Comment the implicit restore → store-listener refresh chain so future refactors don't silently break the UI reload path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address third-pass review findings on PR #720 Resolves I-3 through I-8 and related cleanup items identified in the deep review. Highlights: - replace setTimeout(0) post-merge round-trip with a direct syncAllProviders call using the already-computed merged payload, removing the React-commit race - resolve the empty-vault confirmation promise on unmount so a mid-dialog window teardown doesn't leak the resolver - retry the version-change backup as hosts/keys hydrate, instead of latching on the first (possibly empty) snapshot - heartbeat-refresh the cross-window restore barrier so long applies cannot expose a post-60s window to concurrent auto-sync - add a diagnostic warning when connected providers hold divergent bases (multi-account configurations) - surface a user-visible "Sync paused" toast when startup inspect fails, replacing the previous silent gate-open - tie-break backup list sort by id when createdAt collides - extract applyProtectedSyncPayload so the main and settings windows cannot drift on restore-barrier / protective-backup handling Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address deep-review findings on PR #720 Deep re-review surfaced six Important issues that survived the prior four review rounds. All are hardened here: - I1: fsync the protective backup file AND its directory before the rename completes, so a system crash between backup creation and the restore it guards cannot leave a torn/zero-length safety net. - I3: persist an apply-in-progress sentinel across the non-atomic localStorage writes in applySyncPayload. A crash mid-apply now surfaces on the next startup (toast + refuse auto-push) instead of silently pushing the half-applied state over an intact cloud copy. - I2: only open the auto-sync gate (remoteCheckDoneRef) when the startup inspect validated cleanly. Add a bounded exponential-backoff retry so a transient inspect failure self-heals instead of wedging auto-sync until restart. - I5: save the sync base BEFORE advancing the per-provider anchor inside uploadToProvider. A renderer crash between the two writes now degrades to "stale anchor forces re-inspect on next run," which re-merges against the fresh base — eliminating the silent base-drift window where a 3rd-device race could misclassify entries. - I6: main process broadcasts a vaultBackups:changed IPC event on every mutation; useLocalVaultBackups subscribes so protective backups created from the main window show up in the Settings backup list without manual refresh. - I4: update PR description + code comment to match the actual (safer) design: auto-sync gate opens on vault init, with hasMeaningfulSyncData + restore barrier preventing empty-push; the version-change backup is best-effort and retries as data hydrates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: serialize startup checkRemoteVersion and stabilize its deps Re-review flagged that checkRemoteVersion's useCallback depended on `config` — a fresh object literal from App.tsx on every render — so the retry effect restarted with attempt=0 on every vault edit and could spawn overlapping in-flight inspect+apply runs. Two concurrent commitRemoteInspection + onApplyPayload calls could race on the apply-in-progress sentinel around interleaved writes. Route `buildPayload`, `config.onApplyPayload`, and `config.startupReady` through refs so checkRemoteVersion's identity no longer churns with unrelated App state. Add an in-flight guard that returns early when a previous invocation is still awaiting the network, closing the same-window re-entry gap that withRestoreBarrier intentionally doesn't cover. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: release in-flight lock on no-connected-provider early return Third-pass review caught that `checkRemoteInFlightRef` was acquired before the `!connectedProvider` check, so that early return leaked the lock and every subsequent retry-timer tick silently no-op'd. Move the acquisition past the early return so the only path that takes the lock reaches the finally-release. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (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 |
||
|
|
717d8b718a |
Merge pull request #712 from tces1/dev
feat: scope AI draft and session resume state |
||
|
|
363f03a92d | fix ai draft scope state updates | ||
|
|
75dc3dd72b |
feat: scope AI draft and session resume state
- persist drafts, panel views, and active sessions per terminal/workspace scope - restore scoped AI session selection on reconnect and cold mount - prefer unsent drafts over implicit history fallback - avoid redundant active session map rewrites during scoped cleanup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> |
||
|
|
ebcfe49ed6 |
fix: clear stale model cache when ACP probe returns empty
Address Codex review feedback on #708: the previous guard silently returned on an empty-but-ok probe response, which left any previously cached runtimeAgentModelPresets[currentAgentId] in place. That kept Claude/Copilot pickers showing stale model IDs (and skipped currentModelId reconciliation) instead of falling back to the hardcoded presets when the backend no longer advertised a catalog. Now we explicitly drop the cache entry so the agentModelPresets memo falls through to getAgentModelPresets(...) via the `?? ` branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
bc8ac08b9a |
feat: probe claude-agent-acp for available models instead of hardcoded presets
Claude agents now advertise their real model catalog via the ACP initSession response, just like Copilot already does. Confirmed locally that `claude-agent-acp` returns `models.availableModels` with full ids + names + descriptions (default / sonnet / haiku on subscription; and would return Bedrock/Vertex/custom-proxy ids when the user has configured those). This closes the gap where the Claude picker was stuck on three hardcoded entries from CLAUDE_MODEL_PRESETS regardless of what the underlying CLI actually supports. If the probe fails or returns an empty list, we keep the hardcoded presets as a fallback. Codex keeps its existing path via `aiCodexGetIntegration` (reads ~/.codex/config.toml) — we deliberately do not probe codex-acp, since probing would just return the stock OpenAI model list even when the user has a custom model_provider set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
11f831d820 |
fix: decouple Claude agent auth from netcatty provider list
Apply the same fix as #706 to the Claude Code agent. The `claude` CLI has its own auth surface (`claude auth login/logout/status`) that manages subscription-based logins (Claude Max / Pro via claude.ai) alongside ANTHROPIC_API_KEY / settings-based configs. Silently forwarding a netcatty-configured provider's API key to claude-agent-acp overrides that login — the user's subscription gets bypassed and charges go to their API balance without their knowledge. Claude's settings card never surfaced the `claude auth status` so this regression was more hidden than the Codex one, but the underlying coupling is the same class of bug. Changes: - Stop forwarding any providerId for managed ACP agents from the renderer; claude-agent-acp now resolves auth purely from its own CLI config / login state / shell env. - Remove ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL injection at all three codex-acp / claude-acp spawn sites in aiBridge. - Drop Claude from the authFingerprint computation (it no longer has any netcatty-side input to hash). - Delete the now-unused `findManagedAgentProvider` helper and its ProviderConfig import from managedAgents.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
cc2702b825 |
fix: decouple Codex agent auth from netcatty provider list (#705)
Codex agent auth must be determined entirely by ~/.codex/auth.json or ~/.codex/config.toml. Before this change, if the user configured any OpenAI-compatible API provider in netcatty settings (for Catty agent use), useAIChatStreaming would silently hand that provider's apiKey to the Codex agent too, causing aiBridge to spawn codex-acp with authMethodId "codex-api-key" and completely override the user's ChatGPT login. The regression was introduced in PR #702 (v1.0.89) when findManagedAgent Provider started matching generic "custom" providers for Codex. Users who logged into Codex via ChatGPT and also had a netcatty-configured custom provider saw the UI flip to "API mode" on refresh and their ChatGPT session get ignored. Remove the codex branch from the agentProviderId resolver and from findManagedAgentProvider itself. Also drop the now-meaningless hasCompatibleProvider hint on the Codex settings card and its i18n copy. Claude agent behavior is unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|
|
af2589e60b |
Merge pull request #704 from tces1/MoreSkills
feat: add Netcatty user skills scanning and chat selection flow |
||
|
|
59364e0c75 | fix: preserve user skill selections on refresh errors | ||
|
|
ac83c4c27d | fix: keep user skills state in sync | ||
|
|
1f3e531d7b | Fix AI skill selection handling |