Repository navigation
Conversation
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit bd9187588de9f53d8ee4eab42989b32f71c0d115 on Jul 1, 2026 11:13pm UTC. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 27066757c595554acdeac8cb026434ec2ca71899 and 819f5f2. 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThis change adds ChangesCompact metadata
Related issues: None specified Suggested labels: macos, pty, testing 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
config/patches/[email protected] (1)
169-173: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winWiden the helper definitions to include OpenBSD.
pty_format_spawn_error()is used from the sharedPtyForkpath, andpty_disclaim_spawn_responsibility()is called from the OpenBSD-compiledpty_posix_spawn()flow, but both helpers are still guarded by#if defined(__APPLE__). That leaves OpenBSD without matching definitions and breaks the build there.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3308c7c6-e189-4077-a743-788dba9eb501
📥 Commits
Reviewing files that changed from the base of the PR and between 07bbd44 and 6a1231a45598ae9c790c4a6d1e7696ec0bc7d6b7.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
config/patches/[email protected]config/scripts/node-pty-macos-responsibility-patch.test.mjs
6a1231a to
bd91875
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/providers/macos-tcc-login-shell.ts (1)
50-52: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueOptional: consider caching the
existsSynccheck.
existsSync(MACOS_LOGIN_PATH)runs a synchronous fs stat on every shell spawn. Since/usr/bin/loginis a static system path unlikely to change during process lifetime, this could be memoized to avoid a blocking syscall on each terminal open. Given shell spawns are infrequent (not a hot loop), this is a minor optimization, not a fix.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a340e6ca-5a24-4ccd-b418-515af7742e9d
📥 Commits
Reviewing files that changed from the base of the PR and between 6a1231a45598ae9c790c4a6d1e7696ec0bc7d6b7 and bd9187588de9f53d8ee4eab42989b32f71c0d115.
📒 Files selected for processing (6)
src/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/providers/local-pty-utils.test.tssrc/main/providers/local-pty-utils.tssrc/main/providers/macos-tcc-login-shell.test.tssrc/main/providers/macos-tcc-login-shell.ts
bd91875 to
2706675
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/providers/macos-tcc-login-shell.ts (1)
19-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDoc comment is long relative to the "short why-comment" guideline.
The rationale here is valuable, but as per coding guidelines, comments explaining non-obvious behavior should be "Keep comments short — one or two lines, capturing only the non-obvious reason." This ~30-line block covers multiple concerns (TCC rationale, flag semantics, SHELL interposition, no-op conditions). Consider trimming to the essential "why" and moving the deep design rationale to a linked doc/ADR or the PR/issue description.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e276c145-1cb2-4f75-8bdc-ddb0e178d3e1
📥 Commits
Reviewing files that changed from the base of the PR and between bd9187588de9f53d8ee4eab42989b32f71c0d115 and 27066757c595554acdeac8cb026434ec2ca71899.
📒 Files selected for processing (7)
src/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/ipc/pty.test.tssrc/main/providers/local-pty-utils.test.tssrc/main/providers/local-pty-utils.tssrc/main/providers/macos-tcc-login-shell.test.tssrc/main/providers/macos-tcc-login-shell.ts
✅ Files skipped from review due to trivial changes (1)
- src/main/daemon/pty-subprocess.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/providers/local-pty-utils.test.ts
- src/main/daemon/pty-subprocess.ts
- src/main/providers/local-pty-utils.ts
macOS was attributing a spawned CLI's "access other apps' data" request (kTCCServiceSystemPolicyAppData) to Orca's bundle identifier and never persisting the grant, so signed CLIs like the 1Password op CLI re-prompted on every launch (stablyai#6996). Launch macOS PTY shells through `/usr/bin/login -flpq`, the same spawn shape native terminals use, so tccd resolves each terminal child's own code identity and remembers the decision. The wrapper preserves cwd (-l), Orca's env including its ZDOTDIR shell integration (-p), and suppresses the login banner (-q); the underlying shell keeps its own args so login-shell behavior is unchanged. Because login(1) overwrites SHELL with the account shell from the user database even under -p, the wrapper interposes `/usr/bin/env SHELL=<shell>` between login and the shell, re-asserting the SHELL value Orca terminals deliberately export (fallback shells, custom shells). The interposition is a same-process exec, so it does not disturb login's TCC attribution. The wrapper is a no-op off macOS, when already wrapped, or when the login binary or username is unavailable, and can be disabled with ORCA_DISABLE_MACOS_LOGIN_SHELL. This replaces the earlier node-pty native disclaim patch, which used a private Apple API and would have made platform-binary login shells (/bin/zsh) their own TCC-responsible process, a configuration macOS silently denies protected-folder access to. Closes stablyai#6996 Co-authored-by: Orca <[email protected]>
2706675 to
819f5f2
Compare
…guard gate validators (#7321) Quality pass on main-process/build PRs merged 2026-07-03: - ios-emulator-backend: resolve the serve-sim executable via a lazily-cached getter instead of eagerly in the constructor. The bridge is built before the main window is shown, so the one-time recursive copy + xattr subprocess (first launch after each version bump) no longer blocks macOS startup for a feature that may go unused (#7174). - index: collapse the two near-identical `{webContentsId, until}` reload flags (expectedRendererReload / recoveryReloadInFlight) into one `createWebContentsTimedFlag` primitive; behavior preserved, including consume-on-read for the recovery reload (#7290). - check-reliability-gates: coerce gate.commands/testFiles/platforms/providers with an `asArray` helper before `.includes`, so a hand-edited manifest with a missing/mistyped field reports a validation failure instead of throwing an uncaught TypeError; extract `hasCompleteRedGreenEvidence` for the duplicated status check (#7295). - claude-pty: derive FABLE_WEEKLY_LABEL_RE from WEEKLY_RE.source so a future weekly- wording change stays in one place and can't reopen the parsing gap it just closed. - macos-tcc-login-shell: trim the 30-line flag-by-flag JSDoc to the two non-obvious whys (TCC identity, env(1) SHELL re-assertion) per the repo comment guidance (#7003). Typecheck, oxlint, oxfmt, `check:reliability-gates`, and touched unit suites all pass.
A conclusive PAM rejection was cached for the process lifetime, so one false verdict (the probe runs over pipes, not a PTY) disabled the login(1) TCC attribution wrapper for a daemon that survives app quits and updates for weeks — reintroducing the every-invocation AppData prompts #7003 fixed. Rejections now re-verify after 30 minutes; accepted verdicts still cache for the process lifetime. Refs #9756
* fix(terminal): re-verify cached macOS login-preflight rejections A conclusive PAM rejection was cached for the process lifetime, so one false verdict (the probe runs over pipes, not a PTY) disabled the login(1) TCC attribution wrapper for a daemon that survives app quits and updates for weeks — reintroducing the every-invocation AppData prompts #7003 fixed. Rejections now re-verify after 30 minutes; accepted verdicts still cache for the process lifetime. Refs #9756 * fix(daemon): replace hosts with stale login preflight cache Protocol 26 shipped the process-lifetime PAM rejection cache. Preserve its live sessions as a legacy generation, but route fresh terminals through protocol 27 so updating actually loads the expiring-cache fix. Refs #9756 * fix(terminal): validate rejected login probes under a PTY
…i#7003) Co-authored-by: Orca <[email protected]>
…guard gate validators (stablyai#7321) Quality pass on main-process/build PRs merged 2026-07-03: - ios-emulator-backend: resolve the serve-sim executable via a lazily-cached getter instead of eagerly in the constructor. The bridge is built before the main window is shown, so the one-time recursive copy + xattr subprocess (first launch after each version bump) no longer blocks macOS startup for a feature that may go unused (stablyai#7174). - index: collapse the two near-identical `{webContentsId, until}` reload flags (expectedRendererReload / recoveryReloadInFlight) into one `createWebContentsTimedFlag` primitive; behavior preserved, including consume-on-read for the recovery reload (stablyai#7290). - check-reliability-gates: coerce gate.commands/testFiles/platforms/providers with an `asArray` helper before `.includes`, so a hand-edited manifest with a missing/mistyped field reports a validation failure instead of throwing an uncaught TypeError; extract `hasCompleteRedGreenEvidence` for the duplicated status check (stablyai#7295). - claude-pty: derive FABLE_WEEKLY_LABEL_RE from WEEKLY_RE.source so a future weekly- wording change stays in one place and can't reopen the parsing gap it just closed. - macos-tcc-login-shell: trim the 30-line flag-by-flag JSDoc to the two non-obvious whys (TCC identity, env(1) SHELL re-assertion) per the repo comment guidance (stablyai#7003). Typecheck, oxlint, oxfmt, `check:reliability-gates`, and touched unit suites all pass.
…blyai#9973) * fix(terminal): re-verify cached macOS login-preflight rejections A conclusive PAM rejection was cached for the process lifetime, so one false verdict (the probe runs over pipes, not a PTY) disabled the login(1) TCC attribution wrapper for a daemon that survives app quits and updates for weeks — reintroducing the every-invocation AppData prompts stablyai#7003 fixed. Rejections now re-verify after 30 minutes; accepted verdicts still cache for the process lifetime. Refs stablyai#9756 * fix(daemon): replace hosts with stale login preflight cache Protocol 26 shipped the process-lifetime PAM rejection cache. Preserve its live sessions as a legacy generation, but route fresh terminals through protocol 27 so updating actually loads the expiring-cache fix. Refs stablyai#9756 * fix(terminal): validate rejected login probes under a PTY
Closes #6996
Summary
/usr/bin/loginso each terminal child carries its own TCC identity instead of collapsing into Orca's bundle identifier.node-ptypatch and no private Apple API.ORCA_DISABLE_MACOS_LOGIN_SHELLkill switch.The bug
On macOS, when Orca spawns a shell directly and that shell runs a separately signed CLI (e.g. the 1Password
opCLI), macOS attributes the CLI's "access other apps' data" request (kTCCServiceSystemPolicyAppData) tocom.stablyai.orcaand logsDB Action:None— it never persists the grant, so the prompt reappears on every invocation. The issue'stccdlog showsop's identity collapsed into Orca's (Sub:{com.stablyai.orca}withbinary_path=.../op).The fix
Wrap the macOS PTY shell spawn in
/usr/bin/login -flpq <user> /usr/bin/env SHELL=<shell> <shell> <args…>, the same spawn shape used by native macOS terminals. This letstccdresolve each terminal child's own code identity and persist the decision. Flags:-fskip auth (we are the logged-in user relaunching as ourselves)-lkeep the current cwd (node-pty already set it) and skip the login dash-argv0 marker-ppreserve Orca's environment, including its ZDOTDIR/rcfile shell integration-qsuppress the login banner so wrapped terminals look unchangedSHELL preservation: even under
-p,login(1)overwritesSHELLwith the account shell from the user database — verified empirically: spawning/bin/zshthrough plainlogin -flpqyieldsSHELL=<account shell>even when the spawn env carriesSHELL=/bin/zsh. Orca terminals deliberately export the shell they actually run (fallback shells, custom shells), so the wrapper interposes/usr/bin/env SHELL=<shell>between login and the shell. The interposition is a same-process exec chain (login→env→ shell, one pid after login's fork), so it does not disturb login's TCC attribution, and it also restores$0to the full shell path exactly as direct spawn did. It is skipped only if the shell path itself contains=(whichenv(1)would misparse) — plain login wrapping still applies there.The underlying shell keeps its own args (zsh's
-l, bash's--rcfile), so login-shell behavior is unchanged. Applied at both PTY spawn boundaries — the daemon (pty-subprocess.ts) and the in-processLocalPtyProvider(local-pty-utils.ts), including the fallback-shell chain. The short-lived daemon health probe is intentionally left unwrapped.Why not the previous approach
The earlier revision patched node-pty's native
posix_spawnto call the privateresponsibility_spawnattrs_setdisclaim(disclaim). That makes each PTY child its own TCC-responsible process — but Orca's default child is the login shell/bin/zsh, an Apple platform binary, and macOS silently denies protected-folder access to platform-binary responsible processes (no prompt; ungrantableEPERMin~/Documents,~/Desktop,~/Downloadsfor the session and its descendants). It also relied on a private API loaded viadlsym. Thelogin(1)approach avoids both: no private API, no native patch, and it does not strip the shell's inherited protected-folder access.Verification
wrapShellSpawnForMacosTccAttribution(platform gating, idempotency, missing-login/username fallbacks, env kill switch, SHELL interposition incl. the=-in-path and missing-envedge cases);spawnShellWithFallbackrouting primary and fallback shells through the wrapper with the fallback-corrected env; an IPC-level test asserting the full wrapped argv (login -flpq <user> /usr/bin/env SHELL=… <shell> -l) through the realpty:spawnhandler; the daemon macOS spawn test pinning the interposed argv.typecheck:node, oxlint, oxfmt.$0— including the divergent case (spawned shell ≠ account shell).Orca → /usr/bin/login -flpq <user> /usr/bin/env SHELL=<shell> <shell> --rcfile …; inside the terminalecho $SHELLprints the spawned shell,$PWDis the worktree (not$HOME), the prompt/rcfile chain loads, no "Last login" banner, and commands run normally.Not verifiable in CI / on an unaffected machine
TCC grant persistence depends on interactive, per-machine privacy state and only reproduces on an affected machine (this one does not exhibit the identity collapse). This PR is validated to spawn terminals correctly through
login; the symptom fix should be confirmed on a machine that reproduces #6996:/usr/bin/login -flpq …above the shell (ps -o pid,ppid,command -ax | grep 'login -flpq').op vault list(or the affected CLI) twice; the second run should not re-prompt.log stream --predicate 'subsystem == "com.apple.TCC"'should show the CLI's own identity (accessing={com.1password.op}) and a DB write instead ofSub:{com.stablyai.orca}withDB Action:None.ORCA_DISABLE_MACOS_LOGIN_SHELL=1restores the previous direct spawn.