mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
1d5cef09eca50f3cd3d52311e93bb6a0105d4e7f
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
+1 |
16061720e6 |
feat(ai): add safe OSC 133 shell readiness (#4110)
* fix(terminal): clear sticky broadcast latch on vim ex (#4107) (#4109) Fixes #4107. Merge gate: GitHub Codex clean on tip b7efbe347; local CLEAN residual (unknown colon-prefixed alt-screen challenges) left as documented thrash; CI green (lint-and-test / windows-fido / windows-broadcast-ssh); Electron smoke PASS NC_OUT=/workspace/netcatty-smoke-shots/pr-4109-b7efbe347-20261104-122316 (both panes exited vim via toolbar broadcast :q!). * perf(ai): stop freezing the app during agent discovery and chat backups (#4116) Both paths ran synchronous I/O on the Electron main process, which freezes every window and the terminal keystroke relay while it runs: - Agent discovery (opening the AI panel or Settings > AI) probed auth with execFileSync: `security find-generic-password` (4 s timeout), `gh auth status` (network, 5 s), `which cursor-agent` (4 s) and `cursor-agent status` (8 s), one after another. The probes now use a non-rejecting async execFile helper with the same result shape; discovery awaits them. - Cursor SDK detection evaluated `import("@cursor/sdk")` (~4 MB of ESM plus its transport stack) only to check that it is installed, and kept it resident afterwards. It now checks for the ESM entry that the dynamic import loads; the SDK itself still loads on first use. The package does not export package.json and its CJS build is stripped from releases, so the check walks require.resolve.paths() instead of using require.resolve. - The AI chat backup wrote the whole history (often several MB) with writeFileSync on every debounced change. Writes now use fs.promises and are serialized so generations cannot interleave. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * perf(ui): stop whole-shell re-renders on clicks, focus, typing and modifiers (#4117) Several everyday interactions re-rendered the entire shell (AppView, TopTabs, TerminalLayer and every pane) even though nothing they show had changed: - Clicking or focusing a split pane always replaced the workspaces array (twice per click: onClick + onFocusCapture), cascading through the whole app and re-saving the session restore snapshot. setWorkspaceFocusedSession and moveFocusInWorkspace now keep the same array when focus is unchanged (domain/workspace.ts setWorkspaceFocusedSessionId). - Every window focus/visibility change resynced app lock and produced a new runtime state object even when nothing changed, re-rendering the provider tree. Equal states keep the current object and useAppLockState's result is memoized. - Quick switcher keystrokes went through AppSideEffects state and the app-local UI store, re-rendering AppSideEffects, every host island, AppShell, AppView and TopTabs per character. QuickSwitcherOverlay now owns the query and host results; the overlay unmounts on close, which resets the query exactly where setQuickSearch('') used to. - Pressing/releasing Ctrl/Cmd (every ⌘C/⌘V/Ctrl+C) re-rendered the whole tab bar to toggle shortcut number badges. The held flag now lives in a small store read only by each tab's TabIconSlot. - AppView passed fresh inline callbacks that defeated TopTabs' memo comparator and every open editor tab; TextEditorTabView is now memoized. TopTabs memoizes per-workspace session lists and hoists the root tab icons. - Workspace drag previews only update state when the drop hint actually moves. React commits / render time for 10 repetitions in the real app (profiling build, 2 split panes, 300 hosts), main -> this change: window focus 42 / 17.1 ms -> 2 / 0.4 ms press/release Cmd 50 / 41.9 ms -> 22 / 6.6 ms click focused pane 42 / 69.6 ms -> 3 / 0.4 ms quick switcher typing 41 / 61.3 ms -> 16 / 34.8 ms Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * perf(terminal): cap live WebGL contexts, release them eagerly, bound note undo history (#4122) * perf(terminal): cap live WebGL contexts and stop the context-loss cascade Chromium keeps at most 16 WebGL contexts per renderer and force-loses the one that drew least recently past that. Hidden terminal panes keep their WebGL renderer unless hibernation is on, so with more than 16 terminal tabs every forced loss was rebuilt 50 ms later, evicting another context. With 20 local tabs, half of all tab switches landed on a lost context (xterm waits 3 s before falling back), and terminals that lost three contexts within a minute were parked on the DOM renderer for good. - Add a shared context budget (12). Past it, renderers of panes hidden for at least 3 s are released, least recently seen first. Visible panes are never released or refused; a released pane rebuilds when shown. - A context lost while hidden waits for the reveal instead of rebuilding at once, and no longer counts toward the breaker. - The short-hide CSS reveal path now also asks for the renderer (a no-op while it is live). - Disposing the addon left its context alive until GC. Lose it explicitly so GPU memory and the Chromium slot come back right away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(notes): bound the source editor's undo history Every undo step in the markdown source editor holds a full copy of the note, and the stack never shrank. A long session on a large note kept every intermediate version alive (a 100 KB note with 1,000 steps holds ~200 MB of UTF-16 text). Keep the 200 most recent steps and at most 8M characters across them, dropping the oldest first. The newest step always survives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * perf(terminal): stop per-second churn while connecting and while idle (#4118) * perf(terminal): stop per-second churn while connecting and while idle - Connecting sessions: the 200 ms progress animation and 1 s countdown were Terminal state threaded into the TerminalView ctx, so every connecting session (hidden tabs and startup restores included) re-rendered Terminal + TerminalView up to six times a second. Terminal now only publishes the timeout deadline and real progress events; the connection dialog animates and counts down locally (connectionTicker.ts). HostConnectionTestDialog keeps passing progress/timeLeft as before. - Monitor runtime: polled every second unconditionally and woke every subscriber each time because takenAt always changes. It now polls at 1 s only while something is monitored (here or in another window), 10 s otherwise, and skips notifying for unchanged idle replies. - Auto-reconnect progress log: capped at the newest 300 lines (it grew by a few lines every 5 s retry for as long as an outage lasted). - App Lock: report activity at most once a second instead of an IPC per keystroke / wheel tick / pointer event. - Tray/Dock: the renderer resends hosts only when the host list changed, and the main process rebuilds the macOS Dock menu (sort + one native item per host) only then, not on every session status change. Real app, profiling build, main -> this change: 3 SSH sessions connecting (3 s) 14 commits / 35.3 ms -> 8 / 1.7 ms idle (10 s) 13 commits / 3.1 ms -> 2 / 0.1 ms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(terminal): update observe-popup reconnect deps assertion for capped progress logs CI failed because #4118 wrapped setProgressLogs in useCallback to apply capConnectionProgressLogs and added it to scheduleAutoReconnect deps. The observe-popup source assertion still expected the old deps list. The attachExistingSession early-return behavior is unchanged; only the stale dependency regex needed updating. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * perf(state): stop handler churn on session updates and repeated JSON work (#4121) * perf(state): stop handler churn on session updates and repeated JSON work - Shell handlers: AppSideEffects registers ~58 glue callbacks for the Host islands. Several close over sessions/workspaces/hosts (split/copy/duplicate, close tabs, delete host, keyboard-interactive, connect...), so every session status change and host update (connect bursts, last-connected times) re-notified the bridge and rebuilt all four shell bags, re-rendering AppView and TopTabs. They are now registered behind per-key stable wrappers that call the latest implementation (stabilizeAppHandlers); local callbacks and their effects are unchanged. All registered entries are actions, setters or refs, never read during render. - Session actions: moveFocusInWorkspace, copySession and copyWorkspace read workspaces / orphan sessions / log views through refs at call time (the same snapshot the closure captured), so they keep a stable identity. Getters read during render (isBroadcastEnabled, getOrderedWorkTabs, ...) are untouched. - AI history: the live store was parsed five times when the AI state root mounted; parseSessionsStore parses once per call (two parses total). - AI history writes: the synced branch serializes once and reuses the string for the disk mirror, and rewriting the same immutable sessions array (save path, then cloud-sync collection) is skipped while storage still holds that exact write in the same mode. - Command history: saving after each Enter parsed the whole store (up to 10k entries) only to read its clear generation, and every other window parsed it again on the storage event. The generation is now serialized first and read from the raw string (full parse only to adopt a peer clear), and the debounced write runs when the renderer is idle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: retrigger CI after cancelled lint-and-test run Previous lint-and-test was cancelled mid-run. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: binaricat <binaricat@users.noreply.github.com> * chore: fix outstanding ESLint warnings (#4112) * chore: fix outstanding ESLint warnings - useSftpFollowTerminalCwd: drop activeSessionId/focusedSessionId from the syncFollowToTerminalCwd deps; the callback reads them through refs and the only consumer effect already re-runs on those ids. - useSftpPaneDialogs: list the stable setShowDeleteConfirm callback in the handleDelete/openDeleteConfirm deps. - csvProxy: remove the unnecessary `\[` escapes inside character classes (same matches under the `u` flag). - Remove unused test imports/variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: retrigger CI after runner SIGTERM cancel Previous lint-and-test was cancelled by runner shutdown, not a real failure. * chore: retrigger CI after second runner cancel Lint had already passed; plugin-contract step was cancelled by the runner. * chore: retrigger CI after third runner cancel Lint and schema steps passed; plugin-contract step was cancelled by the runner again. Empty commit to re-queue lint-and-test. * chore: retrigger CI after repeated runner cancel plugin-contract step keeps being cancelled by the Actions runner (not a test failure). Empty commit to re-queue; Actions rerun API denied for this PAT. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: binaricat <binaricat@users.noreply.github.com> * perf: add opt-in startup timeline and real-app startup harness (#4114) * perf: add opt-in startup timeline and real-app startup harness - electron/perfTrace.cjs records first-occurrence startup marks in the main process when NETCATTY_PERF_TRACE=1 (a no-op otherwise), then writes the main-window renderer timeline (navigation, paint, netcatty:* marks, JS heap) and app.getAppMetrics() to JSON after the first renderer-ready signal. - Marks: main.cjs entry / modules loaded / whenReady, main window creation, registerBridges and plugin-host start/end, loadURL, did-finish-load, renderer ready, window shown. The renderer adds three performance.mark() calls (entry evaluated, App mounted, renderer ready), also visible in DevTools. - scripts/perf-startup.live.cjs (npm run perf:startup) launches the built app N times against a throwaway --user-data-dir profile with ssh:// deep-link registration disabled, optionally seeds synthetic hosts over CDP, and reports cold plus warm p50/p90. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(harness): add --profile option to reuse a startup profile Lets the harness keep one profile across invocations, e.g. to compare warm V8 code caches across builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: retrigger CI after flaky monitorRuntimeIsolation failure Previous lint-and-test failed on known-preexisting `useEffect is not defined` in monitorRuntimeIsolation.test.ts. * chore: retrigger CI after monitorRuntimeIsolation useEffect flake Known pre-existing flake: monitor controls test fails with `useEffect is not defined`. Empty commit to re-run once. * test(app): bind React hooks in monitorRuntimeIsolation VM sandbox Extracting component declarations drops their React imports, leaving bare hooks such as useEffect undefined in the VM. Inject common React hooks and APIs while preserving explicit binding overrides to prevent intermittent monitor isolation failures in CI. Stub the startup performance mark through App test bindings so the mount effect can execute without browser globals. Production components remain unchanged. Validation: monitorRuntimeIsolation passed five consecutive runs. Plain npm run lint found 17 existing errors in git-ignored scratch files; excluding only _t.mjs and sim-4107.mjs passed with zero errors and eight existing warnings. * chore: retrigger CI after plugin-contract runner cancel Lint/schema passed; plugin-contract step cancelled by the runner (not a test failure). Empty commit to re-queue. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: binaricat <binaricat@users.noreply.github.com> * perf(main): stop blocking the first window on validator compilation (#4115) The main process ran ~1.4 s of synchronous work in registerBridges before the main window could start loading (app:// assets are served from the main thread too), even for users without plugins: - contractValidator: every createDefinitionValidator() built a fresh Ajv instance and re-registered the 200 KB plugin contract (~17 ms each, ~90 of them across the plugin host at startup, plus one per plugin view resource request). Share one Ajv per process, compile each definition on first use and memoize it; each validator still exposes its own `.errors`. - distributionSnapshot: compile the three distribution schemas lazily on the shared contract Ajv instead of a second Ajv at module load (273 ms -> 37 ms). - pluginBridge: hoist the PluginViewResourceRequest validator to module scope. - cloudSyncBridge: load webdav / @aws-sdk/client-s3 / @smithy/node-http-handler on first sync instead of at startup (108 ms -> 4 ms). - app:// scheme: enable codeCache so V8 reuses compiled renderer bundles across launches and windows. A same-length in-place edit of the cached entry chunk runs the new code, so stale cache is not reused after upgrades. Startup harness (2000 hosts, 10 runs, warm p50): registerBridges 1421 -> 116 ms, plugin host 871 -> 30 ms, renderer ready 2147 -> 723 ms, total memory 923 -> 823 MB. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * fix(ai): keep sessions past 2MB localStorage budget via overflow (#4123) Urgent fix for #4123: retain AI chat history past the 2MiB primary localStorage budget via overflow chunks + pre-split disk backup, with disk-only recovery markers, aggregate-quota degradation, import live-state retention, and count-cap marker resolution. Gate: local Codex CLEAN (no P1) on 084ed813; CI green on acabe0bbc; Electron smoke PASS (pr-4124-acabe0bbc). Residual P2s noted (cross-window reconcile; vault-restore marker clear; retention-cap during pending recovery). No release. * perf(renderer): cut the startup bundle by a third (#4120) * perf(renderer): cut the startup bundle by a third Every window parsed ~6.1 MB of JavaScript before the first render. The entry chunk carried all five UI locales, and the whole AI SDK chunk was preloaded even though the AI panel is lazy. - i18n: only English stays in the entry; other dictionaries load on demand (plus their same-base fallback, e.g. zh-TW -> zh-CN). index.tsx awaits the saved language before the first render, and I18nProvider re-renders when a runtime switch finishes loading. - AI runtime: aiStateSnapshots cleaned up chats through getAgentRuntime(), and the plugin AI/agent hosts created their runtimes on mount, which pulled the Catty harness and @ai-sdk providers into startup. Cleanup now goes through a light handle that the runtime registers (the reversible privacy flag and main-process privacy mapping are still cleared without a runtime), and both plugin hosts create their runtime on the first request, re-checking liveness after the async load. - Chunking: manualChunks' object form also moved Vite's dynamic-import preload helper into vendor-ai (the AI SDK itself uses import()), so the entry imported it from there and vendor-ai (649 KB) was preloaded on every launch. Vendor chunks now use the function form and the helper gets its own 1 KB chunk. - jsqr is loaded when a QR image is imported instead of with the host editor. - startupBundle.architecture.test.ts guards these invariants. Startup JS (index.html): 5.29 MB entry + 649 KB vendor-ai + 138 KB radix -> 3.80 MB entry + 1 KB helper + 174 KB radix (-35%). Startup harness, 2000 hosts, 10 runs, warm p50: loadURL -> renderer entry evaluated 321 -> 207 ms, loadURL -> renderer ready 481 -> 323 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(i18n): preload locale messages before static rendering * test(i18n): preload locales in remaining zh-CN UI tests Non-English dictionaries now load lazily, so I18nProvider can initially render English before its effect finishes loading zh-CN. Explicitly await loadLocaleMessages before rendering these localized UI tests to fix the remaining CI failures without timing-based waits or production changes. * chore: retrigger CI after locale preload fix Previous tip 38108ce66 was on the branch but the PR head stayed stuck on d49ad024e after a GitHub 500 during push. Empty commit to refresh the PR head and re-queue checks. * chore: retrigger CI after plugin-contract runner cancel --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * perf(terminal): cache ligature font parses across terminals (#4126) * fix(pty): forward childProcesses queries to terminal worker (#4127) Worker-owned PTY sessions register their PIDs in the worker, leaving the main process map empty during close-busy checks. Forward child-process queries to the terminal worker and register a worker handler for string and object payloads. Fall back to the main process tree if the worker is unavailable or returns a non-array result. * fix(ui): keep follow-system themeSource from chrome override (#4131) When Interface Theme is Follow System, chrome refresh called setTheme(light|dark) and locked nativeTheme.themeSource, so OS appearance flips no longer updated the UI. Keep setTheme('system') on system chrome preference. Fixes #4130 Gate: GH Codex CLEAN on |