fix(terminal): bypass rejected macOS login sessions#9301
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a cached macOS 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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.
🧹 Nitpick comments (1)
src/main/providers/macos-tcc-login-shell.ts (1)
1-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse Node path utilities for the macOS executable paths.
Construct the
/usr/bin/loginand/usr/bin/printfpaths withpath.join(or an equivalent Node path utility) instead of hard-coding slash-separated paths.As per coding guidelines,
**/*.{js,jsx,ts,tsx}files must usepath.joinor Electron/Node path utilities for file paths and must not assume/or\.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0b8dcf46-7b8f-4465-b662-814916dbc7ab
📒 Files selected for processing (2)
src/main/providers/macos-tcc-login-shell.test.tssrc/main/providers/macos-tcc-login-shell.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/providers/macos-tcc-login-shell.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: aa9dfc20-28d4-485c-9f7a-d643cebd90aa
📒 Files selected for processing (10)
src/main/daemon/daemon-entry.tssrc/main/daemon/daemon-main.tssrc/main/daemon/daemon-server.test.tssrc/main/daemon/daemon-server.tssrc/main/daemon/pty-subprocess.test.tssrc/main/daemon/types.tssrc/main/ipc/pty.test.tssrc/main/providers/local-pty-provider.tssrc/main/providers/macos-tcc-login-shell.test.tssrc/main/providers/macos-tcc-login-shell.ts
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 65fcae62-6fd1-4735-be39-3dca475f1c62
📒 Files selected for processing (4)
src/main/daemon/daemon-server.test.tssrc/main/daemon/daemon-server.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.ts
Summary
login(1)account/session path before using it to launch a terminal shell.login(1)can return zero after an EOF-driven failed authentication prompt.SIGKILLtimeout; cache and deduplicate the result per PTY-host process.Login incorrect/login:.login(1)launch path on compatible macOS accounts.ELI5
On macOS, Orca starts terminal shells through a system login helper so command-line tools can keep the right privacy permissions. On some Macs, account policy rejects that helper even though the user is already signed in. The terminal then gets stuck showing “Login incorrect” instead of opening a shell.
This change gives the helper one quick test before using it. If the test succeeds, Orca keeps the permission-friendly behavior. If it fails or hangs, Orca safely opens the shell the normal way. The test runs only once, does not freeze the app, and has a half-second hard limit. The daemon version is also bumped so an old background process cannot keep using the broken behavior.
Electron + real Codex account proof
Tested in the Electron build from this PR worktree with the machine's real ChatGPT-backed Codex login. Orca spawned Codex CLI 0.144.5 through a fresh visible terminal, and the authenticated model returned the deterministic response
ORCA_E2E_AUTH_OK.The screenshot contains no token, email address, account ID, or other credential.
Reliability contract
login:prompt. Existing terminals and unrelated daemon RPCs stay responsive during detection.SIGKILL, output is capped at 1 KiB, concurrent callers share one child, pending creations are cancelable before subprocess registration, and failure is cached as direct-spawn fallback.ORCA_DISABLE_MACOS_LOGIN_SHELL=1remains the escape hatch. A mid-process account-policy change takes effect after PTY-host restart; until then the cached result deliberately favors a usable direct shell.Testing
oxfmtandoxlintpass (10 files)pnpm run typecheck:nodepingremains responsive while preparation is pending and concurrent creates yield one PTY subprocesskill/cancelCreateOrAttach/ shutdown and local shutdown prevent pending subprocess creation, cancel all concurrent generations, and permit later session-ID reusepnpm lintreaches an unrelated existing exhaustiveness error insrc/renderer/src/components/skills/skill-freshness-group.tsx:101; changed-file lint passespty-subprocess.test.tshas two existing deleted-cwd cases that exceed Vitest's 5 s timeout on this Mac; the changed protocol assertion passes and the macOS case already took about 9 s before this updatepnpm buildnot run; node typecheck, local Electron dev build, CLI build, and macOS computer-use sidecar build passAI Review Report
A deeper review found and fixed three material regressions in the initial implementation:
spawnSynccould stall Electron or the daemon event loop for 40-500 ms, freezing UI and live terminal traffic. The probe is now async, bounded, and deduplicated.The final review covered local and daemon spawn boundaries, concurrency, process cleanup, caching, deleted-cwd behavior, daemon migration, shell fallback, cross-platform gates, SSH execution, and failure diagnostics. No additional change met the bar for a meaningful senior-level fix.
Security audit
The probe uses fixed absolute system binaries, passes the resolved username as a literal argv element without shell interpolation, bounds time and captured output, closes stdin, and never logs captured output. No secrets, credentials, dependencies, IPC schemas, or persisted settings are added. A rejected probe only reduces behavior to the established direct-shell path.