Repository navigation
rm git shim: neutralize stale wrappers without a host gate - #14255
Conversation
This reverts 585dd6d. Re-landed in the next commit without the host capability gate. Nothing shipped with it, so no migration constraint.
Re-lands the cleanup half of #14187: pass-through tombstones for retained wrapper paths, env/PATH scrubbing at every spawn owner, and the retired setting drop. Only writes tombstones when the legacy directory already exists, so a clean install no longer has it created. Leaves out the terminal.attribution-removed.v1 capability gate: the tombstone neutralizes each host locally, so refusing terminal create/split against older hosts denied service without adding cleanup.
📝 WalkthroughWalkthroughThe change removes legacy terminal-attribution compatibility checks, environment rewriting, and runtime identity fencing across mobile, CLI, renderer, IPC, preload, and shared runtime transport paths. Terminal creation and splitting now send direct requests. Runtime RPC contracts no longer include Mergeability Score: 🔵 Low · up to The PR removes the remote compatibility gate and relies on host-local cleanup, but stale wrappers may remain active when their directory is inaccessible, and some mobile terminal operations may still hang through reconnects and block launch or review screens. The change is mergeable with explicit owner awareness and follow-up, including an assertion for the split-failure notification. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts (1)
2156-2172: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winKeep ambiguous create recovery retryable after fatal errors. When a later create error is non-recoverable, this catch calls
recovery.cancel(), soretryRecovery()cannot replay the pendingclientMutationIdorclientOperationId. Keep recoverydisconnectedwhen either reconciliation flag is set, and add a timeout-then-unauthorizedregression test.
🧹 Nitpick comments (2)
src/renderer/src/lib/worktree-activation-created-agent.test.ts (1)
615-620: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the fixed one-turn wait with
vi.waitFor.
await new Promise((resolve) => setTimeout(resolve, 0))grants exactly one macrotask turn. If the activation path later adds another await hop, these two tests fail intermittently instead of waiting for the call. The sibling testsrc/renderer/src/lib/worktree-activation-empty-remote.test.tsalready polls withwaitForfor the same condition.♻️ Proposed change for both wait sites
- await new Promise((resolve) => setTimeout(resolve, 0)) - + await vi.waitFor(() => { + expect(callRuntimeEnvironment).toHaveBeenCalled() + }) expect(callRuntimeEnvironment).toHaveBeenCalledWith(Also applies to: 679-684
src/renderer/src/runtime/remote-agent-session-launch.test.ts (1)
47-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the default capability when
hostAuthorityCapabilityis omitted.Only the test at Line 35 pins a capability string. No test proves that an omitted
hostAuthorityCapabilityprobesAGENT_SESSION_HOST_AUTHORITY_CAPABILITY. That default now gates every non-OMP structured launch, so a change to it would pass this suite.♻️ Proposed assertion
).resolves.toBe('legacy') + expect(mocks.supportsCapability).toHaveBeenCalledWith( + 'env-1', + 'agent-session.host-authority.v1' + ) expect(legacy).toHaveBeenCalledOnce()
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 41632f43-ccdc-4d75-85da-af43662a98ac
📒 Files selected for processing (66)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/session/ai-vault-resume-launch.test.tsmobile/src/session/ai-vault-resume-launch.tsmobile/src/session/ai-vault-resume-preparation.test.tsmobile/src/session/mobile-terminal-attribution-compat.test.tsmobile/src/session/mobile-terminal-attribution-compat.tsmobile/src/session/pr-ai-triage-launch.test.tsmobile/src/session/pr-ai-triage-launch.tsmobile/src/session/use-mobile-diff-review-send-actions.test.tsmobile/src/session/use-mobile-diff-review-send-actions.tsmobile/src/transport/rpc-client.tsmobile/src/transport/types.tssrc/cli/handlers/terminal.test.tssrc/cli/handlers/terminal.tssrc/cli/index.test.tssrc/cli/runtime/client.tssrc/cli/runtime/transport.test.tssrc/cli/runtime/transport.tssrc/main/ipc/runtime-environment-connectivity-handlers.tssrc/main/ipc/runtime-environment-request-connections.tssrc/main/ipc/runtime-environment-transport-routing.tssrc/main/ipc/runtime-environments.test.tssrc/main/ipc/runtime-environments.tssrc/main/pty/legacy-terminal-shim-dir.test.tssrc/main/pty/legacy-terminal-shim-dir.tssrc/main/runtime/rpc/core.tssrc/main/runtime/rpc/dispatcher-computer-errors.test.tssrc/main/runtime/rpc/dispatcher.tssrc/main/runtime/rpc/methods/terminal-split-env.test.tssrc/main/runtime/rpc/methods/terminal.tssrc/main/runtime/rpc/streaming.test.tssrc/preload/api-types.tssrc/preload/index.tssrc/preload/runtime-environment-subscriptions.test.tssrc/preload/runtime-environment-subscriptions.tssrc/renderer/src/components/terminal-pane/pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tssrc/renderer/src/lib/launch-agent-background-session-remote.test.tssrc/renderer/src/lib/runtime-agent-background-create.tssrc/renderer/src/lib/worktree-activation-created-agent.test.tssrc/renderer/src/lib/worktree-activation-empty-remote.test.tssrc/renderer/src/runtime/abortable-runtime-environment-call.tssrc/renderer/src/runtime/remote-agent-session-launch.test.tssrc/renderer/src/runtime/remote-agent-session-launch.tssrc/renderer/src/runtime/runtime-environment-authority.tssrc/renderer/src/runtime/runtime-rpc-client-pairing-revision.test.tssrc/renderer/src/runtime/runtime-rpc-client.tssrc/renderer/src/runtime/runtime-rpc-environment-call.test.tssrc/renderer/src/runtime/runtime-rpc-environment-call.tssrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/shared/legacy-terminal-attribution-env.test.tssrc/shared/legacy-terminal-attribution-env.tssrc/shared/protocol-version.tssrc/shared/remote-runtime-client.test.tssrc/shared/remote-runtime-client.tssrc/shared/remote-runtime-memory-limits.tssrc/shared/remote-runtime-shared-control-admission.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-send.tssrc/shared/remote-runtime-shared-control-subscription-start.tssrc/shared/remote-runtime-shared-control-subscriptions.test.tssrc/shared/remote-runtime-shared-control-subscriptions.tssrc/shared/remote-runtime-shared-control-types.tssrc/shared/runtime-rpc-envelope.ts
💤 Files with no reviewable changes (26)
- src/cli/handlers/terminal.test.ts
- src/cli/runtime/transport.ts
- mobile/src/session/mobile-terminal-attribution-compat.test.ts
- src/shared/runtime-rpc-envelope.ts
- src/preload/index.ts
- mobile/src/session/use-mobile-diff-review-send-actions.test.ts
- src/cli/runtime/client.ts
- src/main/runtime/rpc/methods/terminal-split-env.test.ts
- src/shared/legacy-terminal-attribution-env.test.ts
- src/shared/remote-runtime-shared-control-subscriptions.ts
- src/shared/legacy-terminal-attribution-env.ts
- src/cli/runtime/transport.test.ts
- src/main/runtime/rpc/core.ts
- src/shared/remote-runtime-memory-limits.ts
- src/renderer/src/runtime/runtime-rpc-environment-call.test.ts
- src/main/runtime/rpc/dispatcher.ts
- mobile/src/session/mobile-terminal-attribution-compat.ts
- src/main/runtime/rpc/methods/terminal.ts
- src/preload/api-types.ts
- src/shared/remote-runtime-shared-control-types.ts
- src/preload/runtime-environment-subscriptions.ts
- src/shared/protocol-version.ts
- mobile/src/transport/types.ts
- src/shared/remote-runtime-shared-control-subscriptions.test.ts
- src/main/runtime/rpc/streaming.test.ts
- src/renderer/src/runtime/runtime-environment-authority.ts
| const response = await client.sendRequest('session.tabs.createTerminal', { | ||
| worktree: `id:${worktreeId}`, | ||
| afterTabId: activeSessionTabId ?? undefined, | ||
| clientMutationId, | ||
| ...(options?.startupCommand ? { command: options.startupCommand } : {}), | ||
| ...(options?.startupCommandDelivery | ||
| ? { startupCommandDelivery: options.startupCommandDelivery } | ||
| : {}), | ||
| ...(options?.agentPrompt ? { agentPrompt: options.agentPrompt } : {}), | ||
| ...(agent ? { agent } : {}), | ||
| activate: false, | ||
| select: true, | ||
| navigation: 'caller' | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Add end-to-end deadlines to mobile terminal operations.
The mobile RPC client waits for connectivity before it starts its post-connect request timer. These bare calls can wait through reconnect indefinitely and leave creation or review UI blocked.
mobile/app/h/[hostId]/session/[worktreeId].tsx#L3668-L3681: Add a finite deadline to terminal creation and to the optional initialterminal.send. Treat timeout as delivery-unknown and show retry feedback.mobile/src/session/pr-ai-triage-launch.ts#L18-L23: Add a finite deadline to both terminal creation andterminal.send. Preserve a clear failure result for the caller.mobile/src/session/use-mobile-diff-review-send-actions.ts#L107-L112: Add finite deadlines tosession.tabs.createTerminal,terminal.send, andsession.tabs.list. Add timeout-specific UX and regression coverage.
Based on learnings: terminal-related terminal.send, session.tabs.createTerminal, and session.tabs.list calls must have explicit timeout or end-to-end deadline behavior.
📍 Affects 3 files
mobile/app/h/[hostId]/session/[worktreeId].tsx#L3668-L3681(this comment)mobile/src/session/pr-ai-triage-launch.ts#L18-L23mobile/src/session/use-mobile-diff-review-send-actions.ts#L107-L112
Source: Learnings
Readiness review follow-ups: warn on each failed attempt and on give-up (was silent and undiagnosable); write a VERSION marker distinct from the retired shim's '7' so a rolled-back build rewrites its own wrappers; clear a captured ORCA_REAL_* path that no longer exists so the cmd wrapper's where.exe fallback can run; stop a locked temp file masking the real error. Adds retry-exhaustion coverage.
1689b3f to
dad0865
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/pty/legacy-terminal-shim-dir.ts (1)
108-115: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winRetry when the legacy root cannot be inspected.
existsSync(rootDir)returnsfalsefor missing paths and suppressed filesystem errors. Treat onlyENOENTfromlstatSyncorstatSyncas absent. Retry other errors so inaccessible legacy wrappers remain subject to neutralization.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 67007910-fc8d-4b7d-be31-409cccd803f9
📥 Commits
Reviewing files that changed from the base of the PR and between e690121 and 1689b3fbe061764a846dd1e49eecbd81b85b40ab.
📒 Files selected for processing (2)
src/main/pty/legacy-terminal-shim-dir.test.tssrc/main/pty/legacy-terminal-shim-dir.ts
Round-2 review follow-ups: string-pin that a stale ORCA_REAL_* is cleared before the where.exe fallback, and count the initial attempt in the give-up warning so it agrees with the per-attempt line.
The revert took a toast that #14187 added alongside the gate but which stands on its own: without it a failed remote split only reaches the console and the pane silently never appears. Also pins attempt ordinals in the retry-exhaustion test.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 67343e89-5c6f-4e4a-9bf4-5ad4a327e341
📒 Files selected for processing (2)
src/main/pty/legacy-terminal-shim-dir.test.tssrc/renderer/src/runtime/web-runtime-session.ts
| const message = error instanceof Error ? error.message : String(error) | ||
| // Why: a split that fails only in the console leaves the user with a pane that silently | ||
| // never appears. | ||
| toast.error(message) | ||
| console.warn('[web-runtime-session] failed to split terminal:', message) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Assert the toast in the split failure test.
When terminal.split rejects, the supplied src/renderer/src/runtime/web-runtime-session.test.ts test checks console.warn and telemetry, but it does not assert toast.error. Add an assertion for the user-visible failure notification so this behavior cannot regress independently of logging.
The supplied rejection test is the basis for this finding.
Upstream removed the terminal git/gh attribution shim (rm git shim stablyai#14141, stablyai#14255) and actively scrubs it on every spawn. Restoring terminal-attribution.ts and orca-attribution.ts as standalone source for reference/later rework, without rewiring the ~119 other files upstream touched to remove it (settings toggle, PTY spawn, RPC methods, locales, protocol version) — full revival would fight upstream's active cleanup logic.
…14255) * Revert "fix terminal attribution shim removal edge cases (stablyai#14187)" This reverts 35969c5. Re-landed in the next commit without the host capability gate. Nothing shipped with it, so no migration constraint. * rm git shim: neutralize stale wrappers without a host gate Re-lands the cleanup half of stablyai#14187: pass-through tombstones for retained wrapper paths, env/PATH scrubbing at every spawn owner, and the retired setting drop. Only writes tombstones when the legacy directory already exists, so a clean install no longer has it created. Leaves out the terminal.attribution-removed.v1 capability gate: the tombstone neutralizes each host locally, so refusing terminal create/split against older hosts denied service without adding cleanup. * rm git shim: surface neutralization failures and fix rollback marker Readiness review follow-ups: warn on each failed attempt and on give-up (was silent and undiagnosable); write a VERSION marker distinct from the retired shim's '7' so a rolled-back build rewrites its own wrappers; clear a captured ORCA_REAL_* path that no longer exists so the cmd wrapper's where.exe fallback can run; stop a locked temp file masking the real error. Adds retry-exhaustion coverage. * rm git shim: pin the cmd fallback order and correct the give-up count Round-2 review follow-ups: string-pin that a stale ORCA_REAL_* is cleared before the where.exe fallback, and count the initial attempt in the give-up warning so it agrees with the per-attempt line. * rm git shim: keep the split-failure toast The revert took a toast that stablyai#14187 added alongside the gate but which stands on its own: without it a failed remote split only reaches the console and the pane silently never appears. Also pins attempt ordinals in the retry-exhaustion test.
ELI5
The attribution shim removal needed a follow-up to neutralize wrappers left on disk by older installs. #14187 did that, but also made clients refuse to create terminals against any host that hasn't upgraded yet. This reverts it and re-lands only the cleanup half — the part that actually stops attribution.
Two commits: a pure mechanical revert, then the re-land. Only the second commit needs review.
What Changed
Kept from #14187:
git/ghwrapper paths, so already-resolved command paths keep workingenableGitHubAttributiondropped from loaded and persisted settingsFixed:
orca-terminal-attribution/directory containinggit/ghwrappers and aVERSIONmarker — recreating the directory the removal deleted, on machines that never ran the feature.Dropped:
terminal.attribution-removed.v1capability gate and the probe/fence plumbing that served it.Why drop the gate
The shim only fires when three things coincide: wrapper scripts on disk, the shim dir on PATH, and
ORCA_ENABLE_GIT_ATTRIBUTION=1. The tombstone breaks the first one locally, on the machine that has the problem, with no coordination — each host neutralizes itself when it upgrades.The gate added a second mechanism requiring both sides to agree before a terminal could be created. It bought no cleanup: refusing to talk to an un-upgraded host does not clean that host. It only denied service — and
enableGitHubAttributiondefaulted tofalse, so most blocked hosts had nothing to neutralize.It also cost a
status.getround trip before every remote terminal create and split, uncached, serialized ahead of the operation (web-runtime-session.ts,cli/handlers/terminal.ts). That was the only steady-state perf regression in the whole effort.Per
docs/reference/remote-wire-compatibility.md: "Mixed versions are the normal state, not an edge case." Av1.4.181host does not advertise the capability, so an updated client could not open a terminal against it.Net effect
vs −455 with #14187 in place. Test lines drop 1,227 against current main.
Testing
pnpm typecheck(desktop + mobile): passpnpm lint: pass, including reliability gates, max-lines ratchet, and the three localization verifiersagent-exec-handlercases that reproduce identically onorigin/mainCo-authored-bygonegitresolves through the tombstone, real git runs, empty commit has no trailerNot verified: native
cmd/PowerShell wrapper execution (reviewed on macOS; those wrappers are unchanged from #14187), and live mixed-version SSH.Follow-up worth considering separately
The host-side
expectedRuntimeId→runtime_replacedcheck indispatcher.tswas 21 additive lines and sound on its own merits — rejecting a mutation that lands on a replacement runtime is a real safety property. It went out with the revert only because nothing would send the field once the probe is gone. If you want it, it deserves its own PR with a client that already knowsruntimeIdrather than probing for it.Why the compat surface is low-risk
Neither #14141 nor #14187 appears in any release tag (
git tag --containsis empty for both), and mobile0.0.43was cut long before either. So the capability gate andexpectedRuntimeIdare being un-shipped before they ever reached a user — removing them cannot break a deployed client.This also defuses the one structural hazard: dropping the capability means a newer host stops advertising it, which would have hard-failed AI Vault resume, PR AI triage, and diff-review sends on any mobile build carrying #14187's gate. No such build exists in the wild.
Accepted tradeoff, stated precisely
With the gate gone, a new client talking to a host that has not yet upgraded still gets attribution on that host's terminals. The tombstone is written by the host when it runs the new build — it is not pushed by the client. Since #14141 never shipped, that is every deployed remote host on day one, until it updates.
That is the deliberate choice: the gate's alternative was refusing terminal create/split outright, which denied service without cleaning anything.
Readiness review
Reviewed against the 7-section readiness checklist by four independent agents (two Claude, one Grok, one GPT). No P0. One P1 and four P2s found and fixed in
1689b3fbe06:VERSIONmarker was byte-identical to the retired shim's'7', so a rolled-back build would treat tombstones as current and its attribution toggle would silently lie → now'7-neutralized'.where.exefallback whenORCA_REAL_GITpointed at a missing file → now clears the stale value first, matching the.ps1semantics.writeFileAtomically'sfinallycould mask the original error → now isolated.Security (section 03) came back clean from two independent reviewers: written content is fully static (command names are a compile-time
'git' | 'gh'tuple), the temp write usesO_CREAT|O_EXCLso it cannot follow a planted symlink, and no dependency, lockfile, install-hook, or CI surface is touched.Known residual risk
The cmd wrapper's
call :orca_append_path "%%~P"is subject to the documented CALL quote-escape issue when a PATH entry ends in\(common on Windows). Inherited unchanged from #14187. Not fixed here: no cmd.exe was available to reproduce it, and a blind edit to batch quoting was judged more likely to break than fix. Worth a follow-up from a Windows machine.Windows
.cmdhas since been executed on real Windows (awin, Win 10.0.26200, git 2.55.0.windows.3): pass-through, staleORCA_REAL_GITfallback, trailing-backslash PATH entry, and a real commit with attribution env set (0 trailers) all pass. The pre-fix wrapper fails the same stale-path case with exit 3, confirming that fix..ps1remains unexecuted, but it is not on PATH asgit— live Windows hitsgit.cmd. The POSIX tombstone was executed end to end.