* fix(theme): broadcast native system theme updates to renderers
nativeTheme.updated only fires for listeners in the main process, so a renderer sitting in system mode never learned that Windows changed the application theme. Forward the resolved preference to every window and let the settings hook re-apply it.
* fix(theme): keep terminal chrome separate from native system policy
refreshActiveChromeThemeSurfaces called setTheme(light|dark), which the main process writes into nativeTheme.themeSource. The stored preference stayed 'system' while Electron was pinned to a fixed color, so Windows application theme changes were ignored.
Only paint the surfaces here. Also re-assert a fixed independent terminal theme when the OS preference changes: the fingerprint short-circuit skipped the refresh, and the hook effect never re-ran while the terminal props stayed stable.
* test(theme): bound the new jsdom chrome tests
A hanging jsdom/React render should fail the test with its name instead of consuming the CI job budget.
* test(theme): provide native theme in bridge registrar fixtures
* test(theme): provide nativeTheme in child-process registrar fixture
The worker tests introduced in #4127 omitted nativeTheme after the system-theme listener registration became part of the production registrar. Provide a real EventEmitter, matching the transfer-limit fixture, so registrar setup succeeds without weakening production behavior.
* ci: retrigger lint-and-test after runner shutdown
The previous ubuntu-latest lint-and-test run was canceled during plugin
contract verification (annotation: "The operation was canceled."). Lint
had already passed; tests never started. Tree is unchanged.
---------
Co-authored-by: HHXXYY123 <117068187+HHXXYY123@users.noreply.github.com>
* fix(main): stop the process error guards from logging into a dead stdio sink
#4128 reports the main process freezing with an `EIO` write error raised from
`logError` -> `console.error`. That is the same feedback loop as #4136: the
guard writes diagnostics through the sink that just failed, the failure comes
back as another process-level error, and the handler logs again.
The `ignore` short-circuit that fixed the terminal worker does not cover this
one, because `EIO` is not a benign stream teardown: it is classified as
`suppress`, which logs.
- Add `createDiagnosticLogger()`. It holds an `error` listener on the
diagnostics streams so a failed stdio write is no longer re-raised as an
uncaught exception, and it latches closed after an async sink error or a
synchronous throw, so later diagnostics are dropped instead of re-entering.
- Use it for the main-process logger and warner in `main.cjs`.
Errors are still captured for the crash log through `captureError`.
* fix(error-guards): forward the first stdio failure to the crash log
createDiagnosticLogger holds an `error` listener on stdout/stderr, so it
consumes the stream failure before the process guards can see it. Once the
sink latched closed, the failure was dropped from the crash log entirely:
a closed stdout pipe produced one report before the sink guard landed and
none after.
- Add an `onError` option to `createDiagnosticLogger`. It latches the sink
closed first, then forwards only the first stream error; a throwing
reporter cannot escape.
- Main process: report the failure through
`crashLogBridge.captureError("stdio", err)`.
- Terminal worker: fold the inline `consoleBroken` latch onto
`createDiagnosticLogger` and forward the first failure through
`report`/`reportWorkerError`.
Regression coverage spawns a subprocess whose stdout/stderr pipe is closed
by the parent and asserts exactly one report is produced.
* ci: retrigger tests after unrelated plugin SIGKILL flake
PluginLogSettings.test.tsx was SIGKILL'd and the lint-and-test job was
canceled; the failure is unrelated to the stdio guard change.
---------
Co-authored-by: shibo.li <shibo.li@d-robotics.cc>
Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
Fixes#4136.
When the terminal utilityProcess console pipe is already dead, classifyProcessError marks EPIPE / ERR_STREAM_DESTROYED as ignore, but installTerminalWorkerErrorGuards still called logError → console.error. That write failed with EPIPE, re-entered uncaughtException, and busy-looped.
- On action === ignore: only report, never logError.
- Latch consoleBroken on stdout/stderr error so the default console.error path no-ops after the transport dies.
- Harden compressed extract cancel rollback under SIGTERM (ignore HUP/INT/TERM during cleanup, unlink archive first) and stabilize the FIFO cancel test that was flaking CI.
Out of scope: #4128 main-process EIO twin.
* fix(transfer): keep SSH alive when canceling mid-transfer (#4134)
Cancel of a large isolated SFTP upload/download used to call sftp.end()
mid-WRITE on a channel that shares the terminal SSH transport. That
CHANNEL_CLOSE with in-flight traffic can make the remote drop the whole
connection, so the shell shows [session closed by remote (no exit status)].
Abort now drains like the shared browse path (no mid-flight end); dispose
only after settle. Cancel returns { cancelled: true } so the pool does not
treat channel-closed as session loss.
* fix(transfer): deferred-dispose soft-cancelled isolated SFTP (#4134)
Codex P2 on 88b4890: softDispose dropped cancelled isolated download
channels from the pool without ending them, leaking remote subsystems.
Schedule sftp.end() after a ~2s quiet settle instead of abandoning forever
or ending mid-flight on the shared SSH transport.
Aligned cheap fix for isolated fastPut cancel: after force-settle, defer
end of the disposable channel the same way. Stopping ssh2 fastXfer
internal scheduling still needs invasive hooks — left as documented
residual; deferred end after quiet is the minimal leak fix.
Tests cover mid-flight isolated upload/download cancel (no end while
held) and eventual deferred end after settle.
* Revert "fix(transfer): deferred-dispose soft-cancelled isolated SFTP (#4134)"
This reverts commit 5b85ee70c0.
* fix(transfer): dispose soft-cancelled SFTP only after request drain (#4134)
Codex 4475686359 on 5b85ee70: fixed 2s deferred sftp.end() still fired while
READs were pending and could recreate the shared-SSH drop. Poll sftp._requests
for quiescence before ending; if still pending past the hard max, skip end
(abandon until session close) rather than ending mid-flight.
Tests: held isolated download READs past 2s must not end until released;
fastPut gate cancel still deferred-ends after drain.
* Revert "fix(transfer): dispose soft-cancelled SFTP only after request drain (#4134)"
This reverts commit 7e9934cd7e.
* chore: retrigger CI after lint-and-test runner cancel (#4135)
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
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.
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>
* 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(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>
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>
Only call openMainWindowReady() when the runtime is locked (UI needed to
unlock). Unlocked tray starts deliver via sendToMainWindow with focus:false
so a hidden/minimized main window stays in the background.
Fixes#4081
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
* fix(mcp): recognize Oh My Zsh ➜ idle prompts
Oh My Zsh robbyrussell paints idle prompts like `➜ ~` / `➜ ~ git:(main) ✗`.
The POSIX idle whitelist never matched leading Unicode ➜, so MCP
terminal_execute stayed SHELL_NOT_READY after a session switched into zsh.
Accept common robbyrussell ➜ lines (two-space theme form and `➜ ~`) and
still reject pending input and bare ➜.
Fixes#4078
* chore: retrigger CI after unrelated PluginAIContextHost flake
* chore: retrigger CI (lint-and-test hung after cancelled plugin-verify step)
* chore: empty commit to retrigger CI
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
Powerlevel10k paints idle prompts like `~ ❯` / `alice@host ~/src ❯`.
The POSIX idle whitelist never matched Unicode ❯, so MCP terminal_execute
stayed SHELL_NOT_READY while bash `$` worked. Accept common p10k ❯ lines
and still reject pending input and bare ❯.
Fixes#4075
* fix(terminal): forward xterm onBinary for legacy mouse (#3811)
Legacy DEC mouse (ttymouse=xterm2) is emitted via onBinary; only onData
was wired. Preserve 0-255 through the write path with a binary/latin1
Buffer so high coordinate bytes are not UTF-8-corrupted.
* chore: retrigger CI after lint-and-test runner shutdown (exit 143)
* chore: retrigger CI after lint-and-test runner shutdown (2)
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
Contributor GOUKI9999 session_reconnect/session_recover. Maintainer gate fix: do not report ready while still offline/connecting (pending instead); connected keeps advisory shellReady; regenerate capability tool specs. Unit tests 12/12. Electron smoke PASS (SSH shell path). Residual P2 hung-worker readiness left timeout-bounded. No release.
Gate for contributor #4057 (same tip). cwd+stdout FD instead of -C/-f for Windows tar.exe ANSI argv; GNU tar --exclude for in-tree archive; resolve System32 tar.exe before cwd switch.
Local Codex CLEAN on 73ff25a31 (residual P2 glob-escape deferred). Electron smoke PASS NC_OUT pr-4057-73ff25a31. CI green on tip after plugin-manager focus flake retrigger.
* feat(monitor): 优化磁盘IO展示与系统分区告警 [4030]
* fix(monitor): 修复磁盘监控评审问题 [4030]
* fix(monitor): align Partitions bars with Memory; hide bare / label
Label-above-bar for partition list; single-root `/` hides the label and
centers the bar like Memory/CPU (unchanged). Multi-disk keeps top align +
system alerts. Disk IO adds a spacer row to track usage labels.
Review crops under .github/review/ for PR discussion (drop before merge OK).
* fix(monitor): keep bare-/ align; multi-disk labels stay left
Address Chris density feedback: keep the single root label hidden and vertically centered with Memory, and restore side-by-side labels for multiple disks. Remove the Disk I/O spacer and update the review crops.
* chore(monitor): drop PR #4031 discussion review crops
---------
Co-authored-by: wendeng.dong <wendeng.dong@sailuntire.com>
Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
Continuation of #3969 by @hexart (Joseph Hau). Preserves original commit recognition and adds spaces / %#→# coverage so idle macOS zsh terminals accept AI commands.
Codex CLEAN (gpt-6.1-terra) vs main. CI green. No release.
Co-authored-by: Joseph Hau <hexart@gmail.com>
* feat(ai): add /rename and /chats slash commands plus a session durability layer
Panel slash commands (#4015 feedback):
- /rename <title> renames the current chat via updateSessionTitle; the
command is intercepted in ChatInput's system-command branch and never
reaches the agent. Empty title shows a usage hint. The history drawer
gains an inline rename affordance.
- /chats renders a dismissible system-style note listing the panel's
visible chats (title / agent backend / workspace-or-terminal scope with
a dangling marker / relative last-active time; current chat marked).
Deliberately not named /resume: session.resume already means
flow-recovery-after-cancel. Listing logic is pure (aiChatsListing.ts)
so a future rebind action can attach per-entry actions.
- i18n keys added for en/es/ru/zh-CN/zh-TW.
Durability layer (additive; cleanup/eviction semantics untouched):
- Every successful store write schedules a debounced (~2s) mirror of the
exact persisted JSON to {userData}/ai-sessions-backup/ through a new
aiSessionsBackupBridge: atomic temp+rename writes, 5 rolling
generations, timestamped names.
- On boot, a missing/empty live store is restored from the newest
parseable backup generation. The asymmetry is deliberate: empty ->
restore, non-empty -> leave alone, so restored data can never
resurrect explicitly deleted chats.
- Manual export/import in the history drawer via real file dialogs
(fixed-path fallback where dialogs are unavailable); import merges by
id with newer updatedAt winning.
Tests: bridge rotation/corruption/rejection, restore decisions, merge
semantics, debounce throttle, mirror-on-write, slash interception and
/chats listing seams. eslint clean; tsc unchanged vs baseline.
* fix(ai): repair sessions backup IPC and restore/import guards
- Forward write/export payloads through preload unchanged so the main
bridge receives a string json (was double-wrapped → invalid-json).
- Restore from disk only when the live store is missing or corrupt;
treat a valid [] as an intentional clear. Flush the debounced mirror
on beforeunload so deletions land before quit.
- Require id + messages[] + finite updatedAt when parsing backup/
import entries so malformed objects cannot reach pruneSessionsForStorage.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): complete /rename from partial slash and harden import shape
- Selecting Rename from the slash picker replaces the active slash token
with `/rename ` so a following title is intercepted, not sent to the agent.
- parseBackupSessions also requires title, agentId, and a scope object with
a string type before accepting an imported/backup entry.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): validate backup messages and skip prune on synced restore
- Drop backup/import sessions whose messages lack id/role/timestamp.
- When cloud AI-session sync is enabled, restore parsed sessions without
pruneSessionsForStorage so local retention cannot truncate synced history.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): export prepareRestoredSessions helper
Missed in the previous commit; required by useAIState boot restore and tests.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): require message content on backup import; raise disk cap to 64MB
* fix(ai): normalize corrupt sessions store to [] before boot restore
* fix(ai): skip non-array backup generations when reading latest
* fix(ai): emit sessions change on backup restore; skip unusable gens
* fix(ai): treat empty backup gen as wipe; align gen usability with parser
* fix(ai): seed backup on boot for live store; report durable import count
* fix(ai): emit sessions change after backup import
* docs(ai): clarify sessions backup recovers in-profile store only
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
Reuse the selection-token snapshot comparison for list and install, including a rejected stale or withdrawn selection. Preserve synchronous unavailable-source validation before the asynchronous list operation. The loaded-row regression rejects installation without downloading or executing a package.
A peer FIN can leave readyState closed while destroyed is still false.
Concurrent tool calls wrote into that socket, hit writeAfterFIN, and
failed with "TCP connection lost" instead of sharing one reconnect.
Treat that socket as down, and make later callers join the in-flight re-auth.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
Keeping the restore guard for registration-time chrome setup is right, but
it also swallowed explicit setTheme/setBackgroundColor pushes: windows that
had never enabled blur stopped repainting their native backing, leaving the
color stale after theme changes on every platform.
Separate the two call kinds with an explicit forceBackgroundColor flag so
registration still preserves the window's creation-time color while theme
and background-color pushes always land.
Co-authored-by: Cursor <cursoragent@cursor.com>
Addresses review feedback on the frosted glass background setting.
- Detached #/session-window renderers run with settings sync disabled, so
`applySharedWindowSetting` now forwards the blur key. Previously the main
process put native vibrancy on those windows while their renderer class
stayed stale, leaving them opaque with blur on and double-applying opacity
with blur off.
- Only settings-owning windows persist the blur preference and drive
`setWindowBackgroundBlur`, matching the other OS-effect guards. Detached
windows still apply the transparent backing class locally.
- Search entries can declare `platforms`; the macOS-only blur setting is
filtered out on Windows/Linux so a hit never jumps to a tab whose anchor is
not rendered (including the default empty-query list).
- Restoring chrome only rewrites the background of windows this module made
transparent, falling back to the active theme color when no theme color has
been pushed yet.
Co-authored-by: Cursor <cursoragent@cursor.com>