Repository navigation
fix(windows): restore a CIM fallback for relay hosts with no native binding - #16550
Conversation
|
Too many files changed for review (124 files, 100 file limit). Bypass the limit by tagging |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe PR adds a PowerShell CIM fallback for Windows process enumeration when the native process-tree module is unavailable. It validates JSON output, process identifiers, command data, execution limits, and current-process presence. Tests cover parsing, fallback selection, native precedence, error propagation, and platform behavior. Relay dependency tests analyze reachable native addons and verify configured versions. Documentation records the fallback behavior and relay dependency coverage. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 12.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 142 functions across 56 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description provides a detailed, relevant explanation of the bug, implementation, trade-offs, testing, and rollback plan, but it does not follow the repository template. It omits required section headings and content for Linked Issue, Visual Proof with an explicit N/A statement, AI Disclosure, Review, Agent skill upstream boundary, and Checklist. Resolution Reformat the description to include every template section. Add a valid linked issue using the required “Fixes #” format, add “N/A” with a reason under Visual Proof if no visual change exists, complete or explicitly address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist, and place the testing details under Testing.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (6)
src/main/ipc/pty/provider/local-configure.ts (1)
104-106: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: drop the duplicate
markClaudePtyExitedcall.
clearProviderPtyStatealready callsmarkClaudePtyExited(id). The repeat here (and inbind-listeners.ts,liveness.ts) suggests the guard is owned by two layers.clearProviderPtyState(id) ptyOwnership.delete(id) - markClaudePtyExited(id)src/main/ipc/pty/provider/listener-lifecycle.ts (1)
97-106: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winNull the references before invoking the unsubscribe callbacks.
If one unsubscribe throws, the later ones never run and the stale references remain, which re-creates the duplicate-listener leak described at Lines 3-6.
♻️ Proposed refactor
export function unbindLocalProviderListeners(): void { - localDataUnsub?.() - localExitUnsub?.() - localBackgroundStreamUnsub?.() - localWriteUnavailableUnsub?.() - localDataUnsub = null - localExitUnsub = null - localBackgroundStreamUnsub = null - localWriteUnavailableUnsub = null + const unsubs = [ + localDataUnsub, + localExitUnsub, + localBackgroundStreamUnsub, + localWriteUnavailableUnsub + ] + localDataUnsub = null + localExitUnsub = null + localBackgroundStreamUnsub = null + localWriteUnavailableUnsub = null + for (const unsub of unsubs) { + try { + unsub?.() + } catch (error) { + console.warn('[pty] provider listener unsubscribe failed', error) + } + } }src/main/ipc/pty/ipc/spawn-env-codex.ts (1)
54-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the repeated Codex-home selection expression.
The same
getCompatibleSelectedCodexHomePath(ctx.codexSelectionTarget, ctx.deps.getSelectedCodexHomePath?.(...))shape appears four times with onlylaunchAgentandunavailableManagedHomePathdiffering. A single local helper that takes those two values removes the duplication and keeps the argument list in one place.src/main/ipc/pty/ipc/spawn-commit-persist.ts (1)
86-91: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueHandle the missing
registerPreAllocatedHandleForPtycase.
ctx.agentTeamsLeaderHandleis cleared only when the runtime exposesregisterPreAllocatedHandleForPty. If the method is absent, the pre-allocated handle is neither registered nor released, so the leader handle stays owned by nobody. Add an else branch that releases or explicitly retains the handle.src/main/ipc/pty/host-env/path.ts (1)
28-29: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winReuse
resolvePathEnvKeyfor the PATH key.When
envcontains onlypathon Windows, the current logic writesPATHand leavesenv.pathunchanged. Windows uses the first case-insensitive key, so the shim can remain absent from the effective PATH.♻️ Proposed refactor
- const currentPathKey = env.PATH !== undefined || env.Path === undefined ? 'PATH' : 'Path' + const currentPathKey = resolvePathEnvKey(env, process.platform)src/main/ipc/pty/ipc/spawn-begin.ts (1)
26-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCompute the pane key once.
initialPaneKey(Lines 26-35) andearlyPaneKey(Lines 62-71) use identical predicates and inputs. Extract one local pane-key resolution and reuse it for both the Codex-home snapshot and the reservation key.♻️ Proposed refactor
- const initialLeafId = - typeof args.leafId === 'string' && isTerminalLeafId(args.leafId) ? args.leafId : null - const initialPaneKey = + const leafId = + typeof args.leafId === 'string' && isTerminalLeafId(args.leafId) ? args.leafId : null + const paneKey = typeof args.worktreeId === 'string' && typeof args.tabId === 'string' && isValidTerminalTabId(args.tabId) && args.tabId.length <= 512 && - initialLeafId - ? makePaneKey(args.tabId, initialLeafId) + leafId + ? makePaneKey(args.tabId, leafId) : nullThen use
paneKeyat Lines 38, 72-76, and 89-98 and delete theearly*duplicates.Also applies to: 62-76
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1f15cc56-245c-4622-ba27-bc08edc3b998
📥 Commits
Reviewing files that changed from the base of the PR and between b57b812 and 616d2a4ec8c58eacec32b4b65483d03e2e3fff56.
📒 Files selected for processing (124)
config/max-lines-baseline.txtdocs/reference/windows-process-enumeration.mdsrc/main/ipc/pty-applied-size-reporting.test.tssrc/main/ipc/pty-buffer-snapshot-dispatch.test.tssrc/main/ipc/pty-controller-spawn-admission.test.tssrc/main/ipc/pty-daemon-controller-teardown.test.tssrc/main/ipc/pty-daemon-ssh-lease-lifecycle.test.tssrc/main/ipc/pty-ipc-hidden-delivery-gate.test.tssrc/main/ipc/pty-ipc-producer-flow-control.test.tssrc/main/ipc/pty-listener-teardown-and-orphans.test.tssrc/main/ipc/pty-pane-claim-arbitration.test.tssrc/main/ipc/pty-pane-materialization-race.test.tssrc/main/ipc/pty-runtime-kill-and-exit.test.tssrc/main/ipc/pty-serializer-settlement-mapping.test.tssrc/main/ipc/pty-session-liveness-and-ownership.test.tssrc/main/ipc/pty-spawn-runtime-handle-binding.test.tssrc/main/ipc/pty-startup-barrier-ordering.test.tssrc/main/ipc/pty.tssrc/main/ipc/pty/delivery/accept.tssrc/main/ipc/pty/delivery/accounting.tssrc/main/ipc/pty/delivery/constants.tssrc/main/ipc/pty/delivery/debug-snapshot.tssrc/main/ipc/pty/delivery/debug.tssrc/main/ipc/pty/delivery/exit.tssrc/main/ipc/pty/delivery/flush.tssrc/main/ipc/pty/delivery/hidden-transition.tssrc/main/ipc/pty/delivery/interactive.tssrc/main/ipc/pty/delivery/lifecycle-reset.tssrc/main/ipc/pty/delivery/payload.tssrc/main/ipc/pty/delivery/pending.tssrc/main/ipc/pty/delivery/producer-sync.tssrc/main/ipc/pty/delivery/ssh-intake.tssrc/main/ipc/pty/delivery/visibility-state.tssrc/main/ipc/pty/delivery/wire-session.tssrc/main/ipc/pty/host-env/assembly.tssrc/main/ipc/pty/host-env/codex-home.tssrc/main/ipc/pty/host-env/codex-resume.tssrc/main/ipc/pty/host-env/fresh-spawn-routing.tssrc/main/ipc/pty/host-env/path.tssrc/main/ipc/pty/host-env/pi-agent.tssrc/main/ipc/pty/host-env/spawn-cwd.tssrc/main/ipc/pty/host-env/spawn-env-keys.tssrc/main/ipc/pty/host-env/types.tssrc/main/ipc/pty/ipc/inspect.tssrc/main/ipc/pty/ipc/resize-visibility.tssrc/main/ipc/pty/ipc/serialize-buffer.tssrc/main/ipc/pty/ipc/snapshot.tssrc/main/ipc/pty/ipc/spawn-begin.tssrc/main/ipc/pty/ipc/spawn-commit-persist.tssrc/main/ipc/pty/ipc/spawn-commit.tssrc/main/ipc/pty/ipc/spawn-env-codex.tssrc/main/ipc/pty/ipc/spawn-env.tssrc/main/ipc/pty/ipc/spawn-execute.tssrc/main/ipc/pty/ipc/spawn-options.tssrc/main/ipc/pty/ipc/spawn-preflight.tssrc/main/ipc/pty/ipc/spawn-run.tssrc/main/ipc/pty/ipc/spawn-state.tssrc/main/ipc/pty/ipc/spawn-types.tssrc/main/ipc/pty/ipc/spawn.tssrc/main/ipc/pty/ipc/write-input.tssrc/main/ipc/pty/ipc/write.tssrc/main/ipc/pty/kill-all.tssrc/main/ipc/pty/pane/adopt-stable.tssrc/main/ipc/pty/pane/agent-session-owners.tssrc/main/ipc/pty/pane/key-state.tssrc/main/ipc/pty/pane/launch-authority.tssrc/main/ipc/pty/pane/serializer-state.tssrc/main/ipc/pty/pane/spawn-reservation.tssrc/main/ipc/pty/pane/stable-owner.tssrc/main/ipc/pty/provider/bind-listeners.tssrc/main/ipc/pty/provider/listener-lifecycle.tssrc/main/ipc/pty/provider/liveness.tssrc/main/ipc/pty/provider/local-configure.tssrc/main/ipc/pty/provider/ownership-state.tssrc/main/ipc/pty/provider/registry.tssrc/main/ipc/pty/provider/shutdown-detect.tssrc/main/ipc/pty/provider/state-cleanup.tssrc/main/ipc/pty/register-handlers.tssrc/main/ipc/pty/register-headless-runtime.tssrc/main/ipc/pty/runtime/controller-deps.tssrc/main/ipc/pty/runtime/controller.tssrc/main/ipc/pty/runtime/kill.tssrc/main/ipc/pty/runtime/operations.tssrc/main/ipc/pty/runtime/spawn-commit.tssrc/main/ipc/pty/runtime/spawn-early.tssrc/main/ipc/pty/runtime/spawn-execute.tssrc/main/ipc/pty/runtime/spawn-options.tssrc/main/ipc/pty/runtime/spawn-preflight.tssrc/main/ipc/pty/runtime/spawn-state.tssrc/main/ipc/pty/runtime/spawn.tssrc/main/ipc/pty/session.tssrc/main/ipc/worktree-push-target-setup.test.tssrc/main/ipc/worktree-push-target-setup.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-ssh-fork-push-target-remote.test.tssrc/main/runtime/orca-runtime.tssrc/main/skills/skill-upload-retained-paths.tssrc/main/skills/skill-upload-session-admission-regression.test.tssrc/main/skills/skill-upload-session-record.tssrc/main/skills/skill-upload-session-service.tssrc/main/ssh/relay-native-dependency-coverage.test.tssrc/main/ssh/ssh-connection-sftp-namespace.test.tssrc/main/ssh/ssh-relay-deploy.tssrc/main/windows/windows-process-table-cim-scan.test.tssrc/main/windows/windows-process-table-cim-scan.tssrc/main/windows/windows-process-table.test.tssrc/main/windows/windows-process-table.tssrc/renderer/src/components/Terminal.tsxsrc/renderer/src/components/settings/Settings.tsxsrc/renderer/src/components/settings/SettingsSidebar.test.tsxsrc/renderer/src/components/settings/SettingsSidebar.tsxsrc/renderer/src/components/sidebar/sleep-worktree-activation-race.test.tssrc/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.tssrc/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.tssrc/renderer/src/components/ui/dropdown-menu.tsxsrc/renderer/src/lib/active-agent-note-send.tssrc/renderer/src/lib/agent-paste-draft.tssrc/renderer/src/lib/sidebar-worktree-activation.test.tssrc/renderer/src/lib/sidebar-worktree-activation.tssrc/renderer/src/runtime/host-live-terminal-probe.tssrc/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.tssrc/renderer/src/runtime/host-session-mirror-settle-census.test.tssrc/renderer/src/runtime/web-session-tabs-sync-window-visibility.test.tsxsrc/renderer/src/runtime/web-session-tabs-sync.ts
💤 Files with no reviewable changes (3)
- src/renderer/src/components/settings/Settings.tsx
- config/max-lines-baseline.txt
- src/renderer/src/components/settings/SettingsSidebar.test.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| `src/main/ssh/relay-native-dependency-coverage.test.ts` asserts that every | ||
| native addon reachable from the relay entry is either installed on relay hosts | ||
| or listed there with the reason its absence is safe. That test exists because | ||
| #15749 shipped this gap: the relay tests injected a fake module through |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Keep the issue reference in the paragraph.
Line 65 begins with #15749, so Markdown renders it as a heading. Prefix it with issue or escape the hash.
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 65-65: No space after hash on atx style heading
(MD018, no-missing-space-atx)
Source: Linters/SAST tools
| const runtimeSpawn = | ||
| readRepoSource('src/main/ipc/pty/runtime/spawn.ts') + | ||
| readRepoSource('src/main/ipc/pty/runtime/spawn-early.ts') + | ||
| readRepoSource('src/main/ipc/pty/runtime/spawn-preflight.ts') | ||
|
|
||
| const rendererSource = | ||
| readRepoSource('src/main/ipc/pty/ipc/spawn.ts') + | ||
| readRepoSource('src/main/ipc/pty/ipc/spawn-begin.ts') + | ||
| readRepoSource('src/main/ipc/pty/ipc/spawn-preflight.ts') | ||
| const rendererSpawnStart = rendererSource.indexOf("ipcMain.handle('pty:spawn'") | ||
| const rendererSpawn = rendererSource.slice(rendererSpawnStart) | ||
|
|
||
| for (const spawnBlock of [runtimeSpawn, rendererSpawn]) { | ||
| const barrierIndex = spawnBlock.indexOf( | ||
| 'const startupPromise = getLocalPtyStartupPromise(args.connectionId)' | ||
| ) | ||
| const providerIndex = spawnBlock.indexOf('const provider = getProvider(args.connectionId)') | ||
| const barrierIndex = spawnBlock.indexOf('getLocalPtyStartupPromise(args.connectionId)') | ||
| const providerIndex = spawnBlock.indexOf('getProvider(args.connectionId)') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Test invocation order, not concatenated source order. This assembly always places spawn-early.ts before spawn-preflight.ts, so the test can pass after a reversed runtime call order; block startup and assert provider resolution waits.
| const existingRawLength = existing.rawLength ?? existing.data.length | ||
| const next: PendingPtyData = { | ||
| data: existing.data + data, | ||
| ...(!preservesSeq || existing.transformed || transformed | ||
| ? { rawLength: existingRawLength + rawLength, transformed: true as const } | ||
| : {}), | ||
| ...(nextContainsBackgroundOutput ? { containsBackgroundOutput: true } : {}) | ||
| } | ||
| updatePendingProjectionAdmissions(next, projectionState) | ||
| if (typeof existing.startSeq === 'number') { | ||
| next.startSeq = existing.startSeq | ||
| } | ||
| return dropOversizedPendingPtyData(session, id, next) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 '\bappendPendingPtyData\s*\(' --type=tsRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- applicable repository conventions ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
case "$f" in
*learnings*) continue ;;
*) printf '\n### %s\n' "$f"; cat "$f" ;;
esac
done
printf '%s\n' '--- pending.ts outline ---'
ast-grep outline src/main/ipc/pty/delivery/pending.ts
printf '%s\n' '--- changed area and nearby definitions ---'
cat -n src/main/ipc/pty/delivery/pending.ts | sed -n '130,225p'
printf '%s\n' '--- pending API references ---'
rg -n -C3 'appendPending|PendingPtyData|rawLength|preservesSeq' src/main/ipc/pty src --glob '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- pending.ts symbols and relevant implementation ---'
ast-grep outline src/main/ipc/pty/delivery/pending.ts
cat -n src/main/ipc/pty/delivery/pending.ts | sed -n '1,225p'
printf '%s\n' '--- direct pending API references in main PTY code ---'
rg -n -C4 'PendingPtyData|pendingPty|appendPending|enqueuePending|preservesSeq|rawLength' src/main/ipc/pty --glob '*.{ts,tsx}' \
-g '!**/*.test.ts' -g '!**/*.spec.ts'
printf '%s\n' '--- repository-owned convention files by path ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -not -path '*/learnings/*' -printRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- accept path ---'
cat -n src/main/ipc/pty/delivery/accept.ts | sed -n '50,180p'
printf '%s\n' '--- pending flush path ---'
cat -n src/main/ipc/pty/delivery/flush.ts | sed -n '140,205p'
printf '%s\n' '--- payload construction ---'
cat -n src/main/ipc/pty/delivery/payload.ts | sed -n '1,35p'
printf '%s\n' '--- rawLength producers with transformed metadata ---'
rg -n -C5 'sequenceChars|rawLength|transformed' src/main/ipc/pty/provider src/main/ssh-pty-output-intake.ts src/main --glob '*.{ts,tsx}' \
-g '!**/*.test.ts' -g '!**/*.spec.ts' | head -n 260Repository: stablyai/orca
Length of output: 30534
Preserve rawLength when merging pending PTY data.
When acceptPtyDataForRenderer first queues data with rawLength !== data.length and transformed === false, a later preserving append omits rawLength. The pending flush then derives the payload sequence from rendered length and loses the earlier sequence delta.
| restoreOrStripOverlayEnv(baseEnv, { | ||
| primary: 'PI_CODING_AGENT_DIR', | ||
| overlay: 'ORCA_PI_CODING_AGENT_DIR', | ||
| source: 'ORCA_PI_SOURCE_AGENT_DIR' | ||
| }) | ||
| restoreOrStripOverlayEnv(baseEnv, { | ||
| primary: 'PI_CODING_AGENT_DIR', | ||
| overlay: 'ORCA_OMP_CODING_AGENT_DIR', | ||
| source: 'ORCA_OMP_SOURCE_AGENT_DIR' | ||
| }) | ||
| delete baseEnv.ORCA_OMP_STATUS_EXTENSION | ||
| delete baseEnv.ORCA_PRIME_AGENT_SOURCE_AGENT_DIR | ||
| delete baseEnv.ORCA_PRIME_AGENT_STATUS_EXTENSION | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
ast-grep run --pattern 'export function restoreOrStripOverlayEnv($$$) { $$$ }' --lang typescript src/main/ipc/pty/host-env/pi-agent.tsRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- helper references ---'
rg -n --glob '*.ts' 'restoreOrStripOverlayEnv' src/main/ipc/pty/host-env
printf '%s\n' '--- assembly context ---'
sed -n '150,215p' src/main/ipc/pty/host-env/assembly.tsRepository: stablyai/orca
Length of output: 3543
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- assembly import ---'
sed -n '1,40p' src/main/ipc/pty/host-env/assembly.ts
printf '%s\n' '--- helper implementation ---'
sed -n '125,180p' src/main/ipc/pty/host-env/pi-agent.tsRepository: stablyai/orca
Length of output: 4376
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact source/overlay references ---'
rg -n --glob '*.{ts,tsx,js,jsx}' 'ORCA_(PI|OMP)_(SOURCE_AGENT_DIR|CODING_AGENT_DIR)|PI_CODING_AGENT_DIR' src shared
printf '%s\n' '--- preceding assembly calls ---'
sed -n '85,120p' src/main/ipc/pty/host-env/assembly.tsRepository: stablyai/orca
Length of output: 26672
Handle the shared PI_CODING_AGENT_DIR cleanup in one decision. restoreOrStripOverlayEnv assigns primary from each call's source value, or deletes it when it matches that call's overlay. Therefore, the second call can overwrite the Pi value with ORCA_OMP_SOURCE_AGENT_DIR or delete it when the OMP overlay matches.
| if (session.mainWindow.isDestroyed()) { | ||
| return Promise.resolve(null) | ||
| } | ||
|
|
||
| const requestId = randomUUID() | ||
| return new Promise<SerializeResult>((resolve) => { | ||
| const timeout = setTimeout(() => { | ||
| settleSerializeRequest(session, requestId, null) | ||
| }, 750) | ||
| session.pendingSerializeRequests.set(requestId, { resolve, timeout }) | ||
| const payload: { | ||
| requestId: string | ||
| ptyId: string | ||
| opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean } | ||
| } = { requestId, ptyId } | ||
| if (opts) { | ||
| payload.opts = opts | ||
| } | ||
| session.mainWindow.webContents.send('pty:serializeBuffer:request', payload) | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Treat a destroyed webContents like a destroyed window.
Line 91 returns null when the window is destroyed. Line 109 then sends on webContents without the same check. mainWindow.isDestroyed() can be false while the webContents is already destroyed during teardown, and send then throws. The throw escapes the Promise executor, so the caller sees a rejection instead of the documented null result.
🛡️ Proposed fix
export function requestSerializedBuffer(
session: PtyIpcSession,
ptyId: string,
opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean }
): Promise<SerializeResult> {
- if (session.mainWindow.isDestroyed()) {
+ if (
+ session.mainWindow.isDestroyed() ||
+ (typeof session.mainWindow.webContents.isDestroyed === 'function' &&
+ session.mainWindow.webContents.isDestroyed())
+ ) {
return Promise.resolve(null)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (session.mainWindow.isDestroyed()) { | |
| return Promise.resolve(null) | |
| } | |
| const requestId = randomUUID() | |
| return new Promise<SerializeResult>((resolve) => { | |
| const timeout = setTimeout(() => { | |
| settleSerializeRequest(session, requestId, null) | |
| }, 750) | |
| session.pendingSerializeRequests.set(requestId, { resolve, timeout }) | |
| const payload: { | |
| requestId: string | |
| ptyId: string | |
| opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean } | |
| } = { requestId, ptyId } | |
| if (opts) { | |
| payload.opts = opts | |
| } | |
| session.mainWindow.webContents.send('pty:serializeBuffer:request', payload) | |
| }) | |
| if ( | |
| session.mainWindow.isDestroyed() || | |
| (typeof session.mainWindow.webContents.isDestroyed === 'function' && | |
| session.mainWindow.webContents.isDestroyed()) | |
| ) { | |
| return Promise.resolve(null) | |
| } | |
| const requestId = randomUUID() | |
| return new Promise<SerializeResult>((resolve) => { | |
| const timeout = setTimeout(() => { | |
| settleSerializeRequest(session, requestId, null) | |
| }, 750) | |
| session.pendingSerializeRequests.set(requestId, { resolve, timeout }) | |
| const payload: { | |
| requestId: string | |
| ptyId: string | |
| opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean } | |
| } = { requestId, ptyId } | |
| if (opts) { | |
| payload.opts = opts | |
| } | |
| session.mainWindow.webContents.send('pty:serializeBuffer:request', payload) | |
| }) |
| export function rememberPaneKeyForPty(ptyId: string, paneKey: unknown): string | null { | ||
| const normalizedPaneKey = typeof paneKey === 'string' ? paneKey.trim() : '' | ||
| if (!isValidPaneKey(normalizedPaneKey)) { | ||
| return null | ||
| } | ||
| // Why: a re-registered ptyId would otherwise leave its old paneKey pointing here. | ||
| const previousPaneKey = ptyPaneKey.get(ptyId) | ||
| if (previousPaneKey && previousPaneKey !== normalizedPaneKey) { | ||
| if (paneKeyPtyId.get(previousPaneKey) === ptyId) { | ||
| paneKeyPtyId.delete(previousPaneKey) | ||
| } | ||
| } | ||
| ptyPaneKey.set(ptyId, normalizedPaneKey) | ||
| paneKeyPtyId.set(normalizedPaneKey, ptyId) | ||
| return normalizedPaneKey | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Also clear the previous ptyId when a paneKey moves to a new PTY.
The function clears the stale reverse entry for a re-registered ptyId, but not the stale forward entry when the same paneKey moves from ptyId A to ptyId B. ptyPaneKey keeps A -> paneKey, so a later teardown of A runs the paneKey teardown listeners for a paneKey that B now owns and clears B's paneKey-scoped state.
🐛 Proposed fix
ptyPaneKey.set(ptyId, normalizedPaneKey)
+ const previousPtyId = paneKeyPtyId.get(normalizedPaneKey)
+ if (previousPtyId && previousPtyId !== ptyId && ptyPaneKey.get(previousPtyId) === normalizedPaneKey) {
+ ptyPaneKey.delete(previousPtyId)
+ }
paneKeyPtyId.set(normalizedPaneKey, ptyId)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function rememberPaneKeyForPty(ptyId: string, paneKey: unknown): string | null { | |
| const normalizedPaneKey = typeof paneKey === 'string' ? paneKey.trim() : '' | |
| if (!isValidPaneKey(normalizedPaneKey)) { | |
| return null | |
| } | |
| // Why: a re-registered ptyId would otherwise leave its old paneKey pointing here. | |
| const previousPaneKey = ptyPaneKey.get(ptyId) | |
| if (previousPaneKey && previousPaneKey !== normalizedPaneKey) { | |
| if (paneKeyPtyId.get(previousPaneKey) === ptyId) { | |
| paneKeyPtyId.delete(previousPaneKey) | |
| } | |
| } | |
| ptyPaneKey.set(ptyId, normalizedPaneKey) | |
| paneKeyPtyId.set(normalizedPaneKey, ptyId) | |
| return normalizedPaneKey | |
| } | |
| export function rememberPaneKeyForPty(ptyId: string, paneKey: unknown): string | null { | |
| const normalizedPaneKey = typeof paneKey === 'string' ? paneKey.trim() : '' | |
| if (!isValidPaneKey(normalizedPaneKey)) { | |
| return null | |
| } | |
| // Why: a re-registered ptyId would otherwise leave its old paneKey pointing here. | |
| const previousPaneKey = ptyPaneKey.get(ptyId) | |
| if (previousPaneKey && previousPaneKey !== normalizedPaneKey) { | |
| if (paneKeyPtyId.get(previousPaneKey) === ptyId) { | |
| paneKeyPtyId.delete(previousPaneKey) | |
| } | |
| } | |
| ptyPaneKey.set(ptyId, normalizedPaneKey) | |
| const previousPtyId = paneKeyPtyId.get(normalizedPaneKey) | |
| if (previousPtyId && previousPtyId !== ptyId && ptyPaneKey.get(previousPtyId) === normalizedPaneKey) { | |
| ptyPaneKey.delete(previousPtyId) | |
| } | |
| paneKeyPtyId.set(normalizedPaneKey, ptyId) | |
| return normalizedPaneKey | |
| } |
| const sequenceBeforeProviderSpawn = expectedPtyId | ||
| ? (ctx.deps.runtime?.getPtyOutputSequence?.(expectedPtyId) ?? 0) | ||
| : 0 |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the reconcile contract and its baseline argument.
rg -nP --type=ts -C 20 'synchronizePtyOutputSequenceFromProvider\s*\(' -g '!**/*.test.ts'Repository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- changed function context ---'
sed -n '1,230p' src/main/ipc/pty/runtime/spawn-execute.ts
printf '%s\n' '--- candidate definitions and calls ---'
rg -n -S 'synchronizePtyOutputSequence|snapshotKittyFlagsCoverReconciledSeq|spawnForStablePane|expectedPtyId|stablePaneOwnerCandidate' src/mainRepository: stablyai/orca
Length of output: 21354
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- runtime synchronization contract ---'
sed -n '12235,12325p' src/main/runtime/orca-runtime.ts
printf '%s\n' '--- stable-pane spawn flow ---'
sed -n '240,390p' src/main/ipc/pty/pane/stable-owner.ts
printf '%s\n' '--- focused sequence tests ---'
sed -n '9930,10100p' src/main/runtime/orca-runtime.test.tsRepository: stablyai/orca
Length of output: 12079
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- remainder of synchronization contract ---'
sed -n '12305,12375p' src/main/runtime/orca-runtime.ts
printf '%s\n' '--- stable-owner retirement and fresh-spawn callers ---'
sed -n '1,320p' src/main/ipc/pty/pane/stable-owner.ts
printf '%s\n' '--- runtime-spawn tests and sequence assertions ---'
rg -n -C 12 'sequenceBeforeProviderSpawn|snapshotKittyFlagsCoverReconciledSeq|fresh.*spawn|stable.*owner|owner.*retir' src/main/ipc/pty/runtime src/main/ipc/pty/pane --glob '*test.ts'Repository: stablyai/orca
Length of output: 13680
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- snapshot flag producer and consumer ---'
sed -n '210,265p' src/main/ipc/pty/runtime/spawn-options.ts
sed -n '275,320p' src/main/ipc/pty/runtime/spawn-commit.ts
printf '%s\n' '--- sequence and provider-state helpers ---'
rg -n -C 8 'getPtyOutputSequence\(|ptyOutputSequenceById|providerSnapshotPreferredPtys|snapshotKittyFlagsCoverReconciledSeq' src/main/runtime/orca-runtime.ts src/main/ipc/pty/runtime
printf '%s\n' '--- runtime spawn entry points ---'
rg -n -C 15 'executeRuntimePtySpawn\(' src/main/ipc/ptyRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- spawn result sequence contract ---'
rg -n -C 8 'providerSequence' src/main/providers src/main/ipc/pty src/main/daemon --glob '*.ts' --glob '!**/*.test.ts' | head -160
printf '%s\n' '--- fresh-spawn sequence handling ---'
rg -n -C 10 'onFreshSpawn|providerSequence:|generation: .*(continued|reset)' src/main/providers src/main/ipc/pty --glob '*.ts' --glob '!**/*.test.ts' | head -220Repository: stablyai/orca
Length of output: 19942
Use a zero baseline when spawnForStablePane returns a different PTY id. sequenceBeforeProviderSpawn belongs to the retired owner. Reusing it can classify early output on the fresh PTY as pre-spawn output and publish stale kitty flags with an invalid snapshotSeq. Derive the baseline from ctx.result.id; use zero when the id differs.
| * `unverifiable` is a verdict, never a synonym for `none`: loss of contact | ||
| * with the execution host is no evidence a host-owned PTY exited. | ||
| */ | ||
| export type HostLiveTerminalProbeVerdict = 'live' | 'none' | 'unverifiable' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the SSH verdict vocabulary consistently. Replace none and unavailable with unverifiable in the probe and missing-host handling. The execution boundary permits only live, unverifiable, and exited; using synonyms can break consumers that rely on the established verdict contract.
📍 Affects 2 files
src/renderer/src/runtime/host-live-terminal-probe.ts#L15-L15(this comment)src/main/ipc/pty-session-liveness-and-ownership.test.ts#L94-L107
Source: Coding guidelines
…inding #15749 moved the Windows process table onto @vscode/windows-process-tree, but relay deployment installs only node-pty and @parcel/watcher, so a Windows SSH host has no binding at all. Every read rejected, and agent recognition reads a rejection as "no evidence" -- so agent panes on those hosts identified as powershell.exe/cmd.exe for the life of the relay. Verified on real Windows hardware (1486 processes): from the deployed relay directory the require is MODULE_NOT_FOUND, and the pre-fix table rejects instantly with "windows process table unavailable". With this change the same bundle returns 1485 rows in 1.1-1.35s with agent command lines intact. Not fixed by adding the package to RELAY_NATIVE_DEPS: it ships no prebuilds, so that would put a from-source node-gyp build (MSVC + SDK + Spectre-mitigated libs) on the critical path of every Windows relay deploy, and pnpm patches do not cross SSH, so the remote would get the unpatched 1024-process cap regardless -- the exact truncation #15749 existed to remove. The gate is narrow: absence only. A binding that loads but fails, wedges, or returns an unreadable table still rejects, so a blocked reader never starts forking a shell at the caller's poll rate. A fallback that also fails rejects too, and the scan keeps the native path's self-presence guard, so "unavailable" never degrades into "nothing is running". relay-native-dependency-coverage.test.ts asserts every native addon reachable from the relay entry is either installed on relay hosts or listed with the reason its absence is safe. #15749's relay tests passed because they inject a fake module loader, so nothing exercised the real require; this reads the actual esbuild module graph instead.
616d2a4 to
e4084a7
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Took this over for the release cut — force-pushed the branch down to just the Windows relay fix. What changed: the previous head Dropped from this branch (recoverable at
Verified on real Windows hardware rather than only against injected fakes — full before/after in the description. Short version, from the actual deployed relay directory on a Windows SSH host (1486 processes): the require is Two things worth knowing before this merges:
|
|
Ran this past two more frontier models as independent reviewers. Neither found a defect in the fix, but both surfaced things worth recording. Summary of what I accepted, what I'm deferring, and what I'm rejecting. Accepted — precision corrections to the original report:
Accepted — the blast radius is genuinely fail-safe. Both reviewers went looking for a path that reads the rejection as "process dead" and neither found one, which matches what I found: Deferring — no failure cooldown on the CIM path. Correctly observed: the native path has a 30 s Rejecting "not mergeable as-is." The three majors raised — no cooldown, PowerShell spawn rate, 8 MiB silent truncation — are all exact 1.4.188 characteristics, not defects this change introduces. The spawn-rate and truncation ones are already in the description. On truncation specifically: Not corroboration: one reviewer couldn't build the relay bundle (path error) and reached its conclusion from static import reachability alone. The CI: two shards failed on |
…16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in #16550 stayed a clean cherry-pick.
The CIM fallback from #16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now.
The CIM fallback from #16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now.
…16598) * feat(windows): let a relay host bind the native process table directly The CIM fallback from #16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now. * build(relay): ship the Windows process-table addon to relay hosts The CIM scan restored correctness on Windows SSH hosts, but it costs a powershell.exe and ~1.4s per read where the native addon costs ~57ms. It was always the floor, not the destination. The addon cannot be npm-installed on a relay host: it carries a binding.gyp, so npm rebuilds from source and the build wants Spectre-mitigated libraries even where MSVC is already present. The binary inside the published tarball loads, but predates our patch and still caps enumeration at 1024 processes -- on a 1486-process host it returned exactly 1024 rows with the querying process among the missing, which reads as unavailable only under load. No published alternative clears the bar either; the one fork with a working prebuild story still carries the same cap. So build it where a compiler exists and ship the result. The build script refuses unpatched source -- checking the source rather than trusting the install, because the Spectre hunk fails loudly while the 1024 hunk fails silently -- and verifies the PE machine field so a cross-build cannot emit host arch for another target. The artifact is optional: hashed when present so a relay carrying it never shares an immutable directory with one that does not, and never probed, since requiring a file only a Windows build machine can produce would make a correct relay read as MISSING and redeploy forever. Builds on any other OS keep using the scan, unchanged. arm64 cross-compiles from the x64 runner but needs the optional MSVC ARM64 toolset, so it stays best-effort: a runner image without that component should cost arm64 relays the fast path, not fail the release the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a per-arch list rather than a flag for exactly that reason. * build(relay): require the arm64 process-table addon too The arm64 cross-compile is no longer unproven. On a Windows x64 machine with the MSVC v143 ARM64 build tools component installed, node-gyp --arch=arm64 produces a genuine ARM64 image: x64 machine=0x8664 152064 bytes arm64 machine=0xaa64 139776 bytes So arm64 stops being best-effort and joins x64 in the required list. It was only best-effort because the component is optional and I had not seen it succeed; a runner image without it now fails the build with MSB8020 naming the missing component, and that step runs before the long packaging step so the failure costs seconds rather than twenty minutes. The env var stays a per-arch list rather than reverting to a flag, so a future arch can land best-effort before being promoted the same way.
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick. (cherry picked from commit 1c9fb84)
…inding (stablyai#16550) Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.
…tablyai#16598) * feat(windows): let a relay host bind the native process table directly The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now. * build(relay): ship the Windows process-table addon to relay hosts The CIM scan restored correctness on Windows SSH hosts, but it costs a powershell.exe and ~1.4s per read where the native addon costs ~57ms. It was always the floor, not the destination. The addon cannot be npm-installed on a relay host: it carries a binding.gyp, so npm rebuilds from source and the build wants Spectre-mitigated libraries even where MSVC is already present. The binary inside the published tarball loads, but predates our patch and still caps enumeration at 1024 processes -- on a 1486-process host it returned exactly 1024 rows with the querying process among the missing, which reads as unavailable only under load. No published alternative clears the bar either; the one fork with a working prebuild story still carries the same cap. So build it where a compiler exists and ship the result. The build script refuses unpatched source -- checking the source rather than trusting the install, because the Spectre hunk fails loudly while the 1024 hunk fails silently -- and verifies the PE machine field so a cross-build cannot emit host arch for another target. The artifact is optional: hashed when present so a relay carrying it never shares an immutable directory with one that does not, and never probed, since requiring a file only a Windows build machine can produce would make a correct relay read as MISSING and redeploy forever. Builds on any other OS keep using the scan, unchanged. arm64 cross-compiles from the x64 runner but needs the optional MSVC ARM64 toolset, so it stays best-effort: a runner image without that component should cost arm64 relays the fast path, not fail the release the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a per-arch list rather than a flag for exactly that reason. * build(relay): require the arm64 process-table addon too The arm64 cross-compile is no longer unproven. On a Windows x64 machine with the MSVC v143 ARM64 build tools component installed, node-gyp --arch=arm64 produces a genuine ARM64 image: x64 machine=0x8664 152064 bytes arm64 machine=0xaa64 139776 bytes So arm64 stops being best-effort and joins x64 in the required list. It was only best-effort because the component is optional and I had not seen it succeed; a runner image without it now fails the build with MSB8020 naming the missing component, and that step runs before the long packaging step so the failure costs seconds rather than twenty minutes. The env var stays a per-arch list rather than reverting to a flag, so a future arch can land best-effort before being promoted the same way.
…tablyai#16598) * feat(windows): let a relay host bind the native process table directly The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now. * build(relay): ship the Windows process-table addon to relay hosts The CIM scan restored correctness on Windows SSH hosts, but it costs a powershell.exe and ~1.4s per read where the native addon costs ~57ms. It was always the floor, not the destination. The addon cannot be npm-installed on a relay host: it carries a binding.gyp, so npm rebuilds from source and the build wants Spectre-mitigated libraries even where MSVC is already present. The binary inside the published tarball loads, but predates our patch and still caps enumeration at 1024 processes -- on a 1486-process host it returned exactly 1024 rows with the querying process among the missing, which reads as unavailable only under load. No published alternative clears the bar either; the one fork with a working prebuild story still carries the same cap. So build it where a compiler exists and ship the result. The build script refuses unpatched source -- checking the source rather than trusting the install, because the Spectre hunk fails loudly while the 1024 hunk fails silently -- and verifies the PE machine field so a cross-build cannot emit host arch for another target. The artifact is optional: hashed when present so a relay carrying it never shares an immutable directory with one that does not, and never probed, since requiring a file only a Windows build machine can produce would make a correct relay read as MISSING and redeploy forever. Builds on any other OS keep using the scan, unchanged. arm64 cross-compiles from the x64 runner but needs the optional MSVC ARM64 toolset, so it stays best-effort: a runner image without that component should cost arm64 relays the fast path, not fail the release the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a per-arch list rather than a flag for exactly that reason. * build(relay): require the arm64 process-table addon too The arm64 cross-compile is no longer unproven. On a Windows x64 machine with the MSVC v143 ARM64 build tools component installed, node-gyp --arch=arm64 produces a genuine ARM64 image: x64 machine=0x8664 152064 bytes arm64 machine=0xaa64 139776 bytes So arm64 stops being best-effort and joins x64 in the required list. It was only best-effort because the component is optional and I had not seen it succeed; a runner image without it now fails the build with MSB8020 naming the missing component, and that step runs before the long packaging step so the failure costs seconds rather than twenty minutes. The env var stays a per-arch list rather than reverting to a flag, so a future arch can land best-effort before being promoted the same way.
…inding (stablyai#16550) Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com> (cherry picked from commit e4d95e0)
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick. (cherry picked from commit 1c9fb84)
…tablyai#16598) * feat(windows): let a relay host bind the native process table directly The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now. * build(relay): ship the Windows process-table addon to relay hosts The CIM scan restored correctness on Windows SSH hosts, but it costs a powershell.exe and ~1.4s per read where the native addon costs ~57ms. It was always the floor, not the destination. The addon cannot be npm-installed on a relay host: it carries a binding.gyp, so npm rebuilds from source and the build wants Spectre-mitigated libraries even where MSVC is already present. The binary inside the published tarball loads, but predates our patch and still caps enumeration at 1024 processes -- on a 1486-process host it returned exactly 1024 rows with the querying process among the missing, which reads as unavailable only under load. No published alternative clears the bar either; the one fork with a working prebuild story still carries the same cap. So build it where a compiler exists and ship the result. The build script refuses unpatched source -- checking the source rather than trusting the install, because the Spectre hunk fails loudly while the 1024 hunk fails silently -- and verifies the PE machine field so a cross-build cannot emit host arch for another target. The artifact is optional: hashed when present so a relay carrying it never shares an immutable directory with one that does not, and never probed, since requiring a file only a Windows build machine can produce would make a correct relay read as MISSING and redeploy forever. Builds on any other OS keep using the scan, unchanged. arm64 cross-compiles from the x64 runner but needs the optional MSVC ARM64 toolset, so it stays best-effort: a runner image without that component should cost arm64 relays the fast path, not fail the release the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a per-arch list rather than a flag for exactly that reason. * build(relay): require the arm64 process-table addon too The arm64 cross-compile is no longer unproven. On a Windows x64 machine with the MSVC v143 ARM64 build tools component installed, node-gyp --arch=arm64 produces a genuine ARM64 image: x64 machine=0x8664 152064 bytes arm64 machine=0xaa64 139776 bytes So arm64 stops being best-effort and joins x64 in the required list. It was only best-effort because the component is optional and I had not seen it succeed; a runner image without it now fails the build with MSB8020 naming the missing component, and that step runs before the long packaging step so the failure costs seconds rather than twenty minutes. The env var stays a per-arch list rather than reverting to a flag, so a future arch can land best-effort before being promoted the same way. (cherry picked from commit 19e9ec6)
…inding (stablyai#16550) Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.
…tablyai#16598) * feat(windows): let a relay host bind the native process table directly The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a powershell.exe and ~1.4s per scan where the native reader costs ~57ms. It is a parachute, not the destination. Teach the loader a second source: the desktop app keeps resolving the npm package, and a relay host -- which has none of our node_modules -- binds a bare `windows-process-tree.node` staged beside the bundle. The CIM scan stays as the last resort, so a host with neither is unchanged. Bind the addon directly rather than its package wrapper. lib/index.js adds only a queue over getProcessList, and that queue is the wedge this module already defends against: it latches a module-global requestInProgress with no try/catch. We hold our own single-flight and deadline, so going straight to the addon drops the duplicate. Measured on a Windows 11 SSH host with ~1490 processes, running the relay-externals bundle from the deployed relay directory: no addon staged nativeAvailable=false 1247ms (CIM) addon staged nativeAvailable=true 57ms memory restored Degradation was exercised on that host, not just in fakes: a truncated upload, a text file, and a foreign-arch ELF each fall through to the scan rather than throwing, and restoring a good addon recovers. A file that loads but lacks getProcessList is rejected by shape, because binding to it would reject every read forever where falling through still answers. No artifact is staged yet, so this is inert until the packaging change lands: today every relay takes the same CIM path it does now. * build(relay): ship the Windows process-table addon to relay hosts The CIM scan restored correctness on Windows SSH hosts, but it costs a powershell.exe and ~1.4s per read where the native addon costs ~57ms. It was always the floor, not the destination. The addon cannot be npm-installed on a relay host: it carries a binding.gyp, so npm rebuilds from source and the build wants Spectre-mitigated libraries even where MSVC is already present. The binary inside the published tarball loads, but predates our patch and still caps enumeration at 1024 processes -- on a 1486-process host it returned exactly 1024 rows with the querying process among the missing, which reads as unavailable only under load. No published alternative clears the bar either; the one fork with a working prebuild story still carries the same cap. So build it where a compiler exists and ship the result. The build script refuses unpatched source -- checking the source rather than trusting the install, because the Spectre hunk fails loudly while the 1024 hunk fails silently -- and verifies the PE machine field so a cross-build cannot emit host arch for another target. The artifact is optional: hashed when present so a relay carrying it never shares an immutable directory with one that does not, and never probed, since requiring a file only a Windows build machine can produce would make a correct relay read as MISSING and redeploy forever. Builds on any other OS keep using the scan, unchanged. arm64 cross-compiles from the x64 runner but needs the optional MSVC ARM64 toolset, so it stays best-effort: a runner image without that component should cost arm64 relays the fast path, not fail the release the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a per-arch list rather than a flag for exactly that reason. * build(relay): require the arm64 process-table addon too The arm64 cross-compile is no longer unproven. On a Windows x64 machine with the MSVC v143 ARM64 build tools component installed, node-gyp --arch=arm64 produces a genuine ARM64 image: x64 machine=0x8664 152064 bytes arm64 machine=0xaa64 139776 bytes So arm64 stops being best-effort and joins x64 in the required list. It was only best-effort because the component is optional and I had not seen it succeed; a runner image without it now fails the build with MSB8020 naming the missing component, and that step runs before the long packaging step so the failure costs seconds rather than twenty minutes. The env var stays a per-arch list rather than reverting to a flag, so a future arch can land best-effort before being promoted the same way.
ELI5
Orca needs to know what program is actually running inside a terminal pane — is that Claude, or Codex, or just a plain shell sitting at a prompt? On Windows the only way to answer that is to ask the OS for the list of every running process and look at what's underneath the pane's shell.
There are two ways to ask Windows for that list:
@vscode/windows-process-tree) that asks the OS directly. Takes ~16 ms.powershell.exeand have it run aGet-CimInstance Win32_Processquery. Takes ~1.4 s and starts a whole extra process every time.Orca used to do it the slow way. #15749 switched it to the fast way, which was the right call — the slow way was causing real damage (see "Why the fast way exists" below).
Here's what got missed. When you use Orca against a remote machine over SSH, Orca ships a small program called the relay to that machine and runs it there. The relay only installs two native add-ons on the remote host:
node-ptyand@parcel/watcher. Nobody added the new process-table add-on to that list.So on a Windows machine used as an SSH host, the fast way isn't there at all. The code asks for it, doesn't find it, gives up — and because the slow way had been deleted, there's no way left to answer the question. Every pane on that machine falls back to reporting the shell's name instead of the agent's. Forever, until the relay restarts (and then it fails again).
This PR puts the slow way back, but only as a parachute: it's used exclusively on machines where the fast add-on isn't installed. Your local Windows machine still uses the fast way and is completely unaffected.
An analogy: #15749 replaced the stairs with an elevator. Great — except the elevator was never installed in the remote building, and the stairs had already been demolished. This rebuilds the stairs, and only in buildings with no elevator.
The bug in detail
#15749 moved the Windows process table onto
@vscode/windows-process-tree. Relay deployment installs onlynode-ptyand@parcel/watcher(RELAY_NATIVE_DEPS,src/main/ssh/ssh-relay-deploy.ts:700), and the addon isn't in the relay bundle's esbuild externals either (config/scripts/build-relay.mjs:81) — it's resolved at runtime throughcreateRequire, so esbuild can't see it and the build succeeds while the runtime require fails.The chain on a Windows SSH host:
cachedModulelatchesnullon first failure with no production re-probe, so it never recovers within the life of the relay process.#15749 is not in
v1.4.188(git merge-base --is-ancestor 057fbfcffc9 v1.4.188→ false). It's inorigin/adhoc/1.4.189-cherrypicksand is the only windows-process-table commit in that delta, so 1.4.189 is the first release that would carry this.Verified on real Windows hardware
Windows 11 x64, 1486 processes, run from the actual deployed relay directory on a Windows SSH host (
~/.orca-remote/relay-*, whosenode_modulescontains only@parcel/watcher,node-ptyand transitives — no@vscodescope at all):createRequire(...)('@vscode/windows-process-tree')MODULE_NOT_FOUNDrequire('node-pty')(control)windows-process-table.tsfrommain, bundled with the relay's esbuild externalsnativeAvailable=false; rejects in 0 ms,"windows process table unavailable", every callnativeAvailable=false; 1485 rows in 1.1–1.35 s, own pid present,claude.exerows with full command linesAlso checked on that host:
windowsPowerShellPath()resolves (SystemRoot=C:\WINDOWS), the absolutepowershell.exepath exists and executes from the relay process, and the function has no Electron dependency. Separately,out/relay/win32-x64/relay.jswas built and grepped to confirm the module really is in the shipped bundle with the require left as a runtime call.Why not just add it to
RELAY_NATIVE_DEPSnode-gypand needs MSVC + the Windows SDK + Python + Spectre-mitigated libs on every Windows SSH host.installNativeDepsthrows on failure and the toolchain-skip retry is Linux-gated (ssh-relay-deploy.ts:1026→throwat:1071), so Windows relay deploy would break outright.Why the fast way exists (what we must not undo)
The header of
windows-process-table.tsrecords what the PowerShell reader cost. Seven independent readers each forkedpowershell.exe:None of that changes for local Windows. This PR reintroduces PowerShell on relay hosts only, where the alternative is no answer at all.
The fix
Restore the
Get-CimInstance Win32_Processscan insrc/main/windows/windows-process-table-cim-scan.ts, engaged fromwindows-process-table.tsonly when the module cannot be required. The gate is deliberately narrow:Constants (
timeoutMs: 3000,maxOutputBytes: 8 MiB) match the pre-#15749 reader exactly (git show 057fbfcffc9^:src/main/providers/windows-foreground-process-rows.tslines 6, 230–231). The scan goes throughrunProcess, which pinswindowsHide(no flashing console windows) and kills the child on timeout — so it self-heals and doesn't need the native path's 30 s wedge cooldown, which guards a different failure mode (the vendored addon latches a global flag and leaks a callback per call).memoryBytesis undefined on this path. It has zero consumers —grepfinds only an unrelated local insrc/main/memory/collector.ts.The ratchet
src/main/ssh/relay-native-dependency-coverage.test.tsreads the real esbuild module graph from the relay entry and asserts every native addon it reaches is either inRELAY_NATIVE_DEPSor listed with the reason its absence is safe.This is the test that should have existed before #15749. Its relay tests passed because they inject a fake module through
__setWindowsProcessTreeLoaderForTests, so nothing ever exercised the real require.Confirmed non-vacuous: removing the
DEGRADES_WITHOUT_INSTALLentry fails it withexpected [ '@vscode/windows-process-tree' ] to deeply equal [].User-facing trade-offs
Who is affected: only people using a Windows machine as an SSH remote host. Local Windows, macOS, and Linux behavior is byte-for-byte unchanged — the native path is still taken everywhere it exists.
What gets better on those hosts:
claude,codex, …) instead of showing the shell name. This also restores anything keyed off agent identity — pane titles, agent status, and idle/working detection.local-workspace-port-scanner.ts:499).verifyWindowsTreeKillTargetcan answer again, so thetaskkill /T /Fatpty-descendant-termination.ts:275resumes running. Onmainit always answersunknown, which is not permission to kill, so descendants that escaped the pane's job object survive teardown. (The job-object path runs first and normally covers this, so it's a secondary effect.)What gets worse on those hosts — the real cost:
powershell.exespawn every ~1.4–1.9 srunProcesspinswindowsHide, so nothing flashes on screen.Where it still degrades (no worse than
main): on a very busy host the scan can exceed the 3 s timeout or the 8 MiB output cap. At 1486 processes I measured 1.36 s and 4.76 MiB, so headroom is ~2× on time and ~1.7× on bytes. On overflow,createOutputSinktruncates silently, the truncated JSON fails to parse, and the read rejects — degrading to today's behavior rather than reporting a wrong table. Both limits are exact 1.4.188 parity, not new.The honest summary: this trades ~1.4 s of remote CPU every couple of seconds for agent recognition working at all on Windows SSH hosts. The native fast path stays unavailable there until prebuilds or a remote toolchain story is solved; that gap is documented in
docs/reference/windows-process-enumeration.md.Risk and rollback
Low. The change is additive and gated on a condition that is false on every machine that has the addon — local Windows takes an identical code path to
main. On macOS/Linux theprocess.platform === 'win32'guard means the fallback is never even constructed.To roll back, revert this commit; relay hosts return to reporting shell names.
Validation
pnpm tccleansrc/main/windows/, the new ratchet,src/relay/pty-shell-utils.test.ts,src/main/providers/, and the child-process import boundaryoxlintcleanpackage (windows), all 16 shards, e2e, and SSH docker watcher isolationScope note
This branch previously carried three unrelated changes at
616d2a4ec8c(now replaced): a worktree push-target remote-rollback fix, a dropdown-menu shadow CSS fix, and their tests. They were dropped so this stays a clean cherry-pick into the release.The dropdown CSS bug is real and still on
main—shadow-[0_12px_28px_rgba(0,0,0,0.22)],inset_...]has a stray)]that breaks the light-mode shadow, atsrc/renderer/src/components/ui/dropdown-menu.tsx:35and:211. Both dropped changes deserve their own PRs.Follow-ups (deliberately not in this PR)
main.@vscode/windows-process-treeso relay hosts can have the fast path too.windows-process-enumeration.mdquotes 706 ms p50 for the CIM scan, measured at 1050 processes; at 1486 it's 1.36 s.