Repository navigation
fix terminal attribution shim removal edge cases - #14187
Conversation
|
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: 📥 CommitsReviewing files that changed from the base of the PR and between e02dbe1d983495b5071c64076d0fc8b81e45a7b2 and 636e7e5. 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe change adds compatibility checks for disabling legacy terminal attribution. Mobile, CLI, renderer, and remote session flows validate runtime capabilities before terminal creation or splitting. These flows pass attribution-disabled environment data and expected runtime identities. Runtime dispatch and subscription paths reject stale runtime identities. Legacy shim directories are neutralized with platform-specific wrappers. PTY environments remove legacy attribution variables and paths. Persistence removes retired attribution settings. Terminal split RPCs forward environment deletion requests. Mergeability Score: 🟡 Moderate · up to Terminal launches can still remain pending during mobile host stalls, unsupported hosts may fail without visible feedback, and a trailing-slash PATH entry can cause git or gh wrapper recursion; the related tests also have cleanup and hanging-worker risks. These bounded issues should be fixed or explicitly accepted before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
mobile/src/session/use-mobile-diff-review-send-actions.ts (1)
112-120: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftAdd an end-to-end deadline to mobile terminal launch flows. Both flows use bare RPC calls for compatibility verification and terminal creation. A stalled host can leave the operation pending indefinitely.
mobile/src/session/use-mobile-diff-review-send-actions.ts#L112-L120: apply timeout handling before the send-sheet flow waits on terminal creation.mobile/src/session/pr-ai-triage-launch.ts#L23-L27: apply the same bounded launch policy before prompt delivery.Source: Learnings
mobile/app/h/[hostId]/session/[worktreeId].tsx (1)
3775-3785: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winShow the compatibility failure for the standard create flow.
When
handleCreateTerminal()has nooptions.errorToast, this block only updatescreateError.createErroris visible only in the empty-session state at Line 4504. A user who already has tabs receives no update-required message after a rejected create request.Show
messagein a toast for this path, or render it in the create-tab sheet.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8fe0ed4f-aa76-47a2-bdfb-c715c2bf56d1
📒 Files selected for processing (39)
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.tssrc/cli/handlers/terminal.test.tssrc/cli/handlers/terminal.tssrc/cli/index.test.tssrc/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/index.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.tssrc/main/providers/provider-dispatch.test.tssrc/main/pty/legacy-terminal-shim-dir.test.tssrc/main/pty/legacy-terminal-shim-dir.tssrc/main/runtime/rpc/methods/terminal-split-env.test.tssrc/main/runtime/rpc/methods/terminal.tssrc/relay/pty-handler.test.tssrc/relay/pty-handler.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/runtime-agent-background-create.tssrc/renderer/src/runtime/remote-agent-session-launch.test.tssrc/renderer/src/runtime/remote-agent-session-launch.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.ts
e4ffa87 to
04968c6
Compare
|
@coderabbitai review |
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/pty/legacy-terminal-shim-dir.test.ts (2)
33-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the temporary directories after each test.
Every test creates a directory with
mkdtempSyncand never removes it. The suite leaves at least six directories in the system temp path per run, including executable wrapper files. Track the created paths and remove them inafterEach.♻️ Proposed cleanup
-import { spawn } from 'node:child_process' import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, + rmSync, statSync, writeFileSync } from 'node:fs'describe('legacy terminal shim neutralization', () => { + const tempRoots: string[] = [] + + const makeUserDataDir = (): string => { + const dir = mkdtempSync(join(tmpdir(), 'orca-legacy-shim-')) + tempRoots.push(dir) + return dir + } + beforeEach(() => { __resetLegacyTerminalShimNeutralizationForTests() }) afterEach(() => { vi.useRealTimers() + while (tempRoots.length > 0) { + rmSync(tempRoots.pop() as string, { recursive: true, force: true }) + } })Then replace each
mkdtempSync(join(tmpdir(), 'orca-legacy-shim-'))call withmakeUserDataDir().Note: the permission test at Lines 111-122 restores mode
0o700in itsfinallyblock, so the cleanup can remove that directory.Also applies to: 61-64, 79-82, 103-105, 111-116, 137-143
136-181: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winTerminate the child shell if the readiness wait fails.
waitForOutputrejects when the stream ends before the marker. In that case,await readyat Line 174 throws andchild.stdin.end(...)never runs. If bash is alive but produced no marker, for example whenhash -pfails for another reason, the process stays attached to the open stdin pipe until Vitest tears the worker down. Add a guard that kills the child on failure.🛡️ Proposed guard
- await ready + try { + await ready + } catch (error) { + child.kill('SIGKILL') + throw error + } neutralizeLegacyTerminalShimDir(userData)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0ba9f324-38e5-455f-a39c-1adb86a31b36
📒 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/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.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/streaming.test.tssrc/preload/api-types.tssrc/preload/index.tssrc/preload/runtime-environment-subscriptions.test.tssrc/preload/runtime-environment-subscriptions.tssrc/relay/pty-handler.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/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 skipped from review as they are similar to previous changes (18)
- mobile/src/session/pr-ai-triage-launch.ts
- mobile/src/session/use-mobile-diff-review-send-actions.ts
- src/main/providers/local-pty-provider.ts
- mobile/src/session/pr-ai-triage-launch.test.ts
- mobile/src/session/use-mobile-diff-review-send-actions.test.ts
- src/cli/handlers/terminal.ts
- mobile/src/session/ai-vault-resume-launch.ts
- src/shared/legacy-terminal-attribution-env.test.ts
- mobile/src/session/ai-vault-resume-launch.test.ts
- mobile/src/session/ai-vault-resume-preparation.test.ts
- mobile/src/session/mobile-terminal-attribution-compat.test.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
- src/relay/pty-handler.ts
- src/main/providers/local-pty-provider.test.ts
- src/renderer/src/runtime/web-runtime-session.ts
- src/cli/index.test.ts
- src/renderer/src/runtime/web-runtime-session.test.ts
- src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.ts
| remove_path_entry "$legacy_wrapper_dir" | ||
| remove_path_entry "$wrapper_dir" | ||
| unset ORCA_ENABLE_GIT_ATTRIBUTION ORCA_GIT_COMMIT_TRAILER ORCA_GH_PR_FOOTER | ||
| unset ORCA_GH_ISSUE_FOOTER ORCA_ATTRIBUTION_SHIM_DIR ORCA_REAL_GIT ORCA_REAL_GH ORCA_ATTRIBUTION_BYPASS | ||
|
|
||
| real_command="$(PATH="$cleaned_path" type -P "$command_name" || true)" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Normalize POSIX PATH entries before command lookup.
Line 51 removes only the exact $wrapper_dir value. A PATH entry with a trailing slash remains. Line 55 can resolve this wrapper again, and Line 60 then starts an infinite wrapper recursion.
Remove trailing separators when comparing PATH entries. Add a wrapper execution test with a posix/ PATH entry.
Proposed fix
remove_path_entry "$legacy_wrapper_dir"
remove_path_entry "$wrapper_dir"
+remove_path_entry "${legacy_wrapper_dir%/}/"
+remove_path_entry "${wrapper_dir%/}/"📝 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.
| remove_path_entry "$legacy_wrapper_dir" | |
| remove_path_entry "$wrapper_dir" | |
| unset ORCA_ENABLE_GIT_ATTRIBUTION ORCA_GIT_COMMIT_TRAILER ORCA_GH_PR_FOOTER | |
| unset ORCA_GH_ISSUE_FOOTER ORCA_ATTRIBUTION_SHIM_DIR ORCA_REAL_GIT ORCA_REAL_GH ORCA_ATTRIBUTION_BYPASS | |
| real_command="$(PATH="$cleaned_path" type -P "$command_name" || true)" | |
| remove_path_entry "$legacy_wrapper_dir" | |
| remove_path_entry "$wrapper_dir" | |
| remove_path_entry "${legacy_wrapper_dir%/}/" | |
| remove_path_entry "${wrapper_dir%/}/" | |
| unset ORCA_ENABLE_GIT_ATTRIBUTION ORCA_GIT_COMMIT_TRAILER ORCA_GH_PR_FOOTER | |
| unset ORCA_GH_ISSUE_FOOTER ORCA_ATTRIBUTION_SHIM_DIR ORCA_REAL_GIT ORCA_REAL_GH ORCA_ATTRIBUTION_BYPASS | |
| real_command="$(PATH="$cleaned_path" type -P "$command_name" || true)" |
|
@coderabbitai review |
|
e02dbe1 to
636e7e5
Compare
|
@coderabbitai review |
|
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.
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.
* Revert "fix terminal attribution shim removal edge cases (#14187)" This reverts 585dd6d. 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 #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 #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.
* fix(terminal): fully retire attribution shim * fix(terminal): harden shim tombstone path lookup
…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 earlier attribution-shim removal deleted the generated wrappers, but terminals and daemons that survived an upgrade could still retain and execute the old
git/ghwrapper path. This follow-up neutralizes that stale state and refuses terminal creation or splitting unless the connected host proves it implements the removal contract.What Changed
git/ghwrapper paths atomically with inert pass-through tombstones so already-resolved command paths remain usable.terminal.attribution-removed.v1before protected mutations.expectedRuntimeIdrequest field and rejects requests that reach a replacement runtime before dispatch.enableGitHubAttributionsetting from loaded, updated, and persisted settings.envToDeletethroughterminal.splitand rejects Windows real-command paths that recurse into the wrapper directory.The wire change is additive and optional. Older peers can ignore the field; behavior that relies on it is capability-gated. No protocol bump or new stream opcode is introduced.
Why
Deleting the shim directory alone did not cover retained panes, long-lived daemons, mixed client/host versions, runtime replacement, or ambiguous retries. Those paths could preserve stale attribution behavior or duplicate an agent launch. Compatibility tombstones, spawn-owner cleanup, capability checks, and the runtime fence close those gaps while keeping retained terminals operational.
Linked Issue
N/A — this is a follow-up to merged PR #14141; no separate issue was filed.
Visual Proof
N/A — no bespoke layout or visual component was added. The only rendered feedback uses the existing standard Sonner error toast, covered by unit tests.
Testing
Validated on exact head
636e7e58aa8002d8d9185443f068f4bdc9df37c8:v799.v1.4.181: 4 passed.git diff --checkpassed.No physical mobile-device, live WSL/SSH mixed-version, or native cmd/PowerShell wrapper execution run was performed.
AI Disclosure
OpenAI Codex was used extensively for implementation support, test authoring, validation, and code review.
Review
Three independent exact-SHA reviews found no P0/P1/P2 issues.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass or are covered by CIAuthor