Repository navigation
feat(macos): show terminal-host Full Disk Access, tag stable-copy daemons, and give Helpers folder strings - #27354
Conversation
…ndpoint A copy, signature, plist or deadline failure before bootstrap, a bootstrap launchd refused with the job absent, a job whose daemon exited before answering, and a foreign endpoint all threw out of the launcher. The app then lost its persistent daemon and fell back to local PTYs, where main forks one. These now fall through to the existing fork path, which also adopts a foreign occupant normally instead of as a degraded endpoint. A timed-out bootstrap or a job still running/unreadable stays fatal, so no second daemon races it.
daemon_adopted, daemon_pty_cwd_denied and daemon_pty_cwd_readable gain a closed-enum launch_method (stable-copy / app-fork / unknown), read from the spawner path the daemon recorded, so the update fix is measurable per daemon even when an old forked daemon is adopted across updates. The reliability gate is a test manifest with no runtime switch, so there is no gate state to report; spawner_path_class reports the private copy as 'other' alongside other non-/Applications installs.
The separate launch_method property duplicated what the recorded spawner path already says. spawner_path_class gains `stable-copy`, classified from the same path under the private runtime root, and launch_method, its enum and classifier are removed from all three .strict() daemon origin events. A deleted copy still reports `missing`.
The permissions handler already asks for the terminal-host status only on macOS, so the status function's own platform check and the pane's 'unsupported' branch could never fire. The off-macOS guarantee is now tested at the handler.
The stable launch could run until 55 s after the launch started, so a late "unavailable" verdict left the fork fallback's own 10 s readiness wait to finish after the 60 s gate had already moved the app to local PTYs. The launcher now gives the stable attempt one handoff deadline: the gate minus the fork's readiness timeout and the 5 s lease/adapter allowance (45 s). Copy, signature check and plist conversion share one abort signal that ends early enough for bootstrap and the job's own readiness wait to meet that deadline; every command otherwise keeps a fixed timeout. An unavailable verdict past the deadline is reported instead of forking a daemon that cannot arrive in time. The per-step budget module is gone (its deletion landed in the previous commit by a staging slip). The launch body is now two blocks: preparation (plist, plutil, deadline check) fails as unavailable after removing the copy and job file, and bootstrap runs in its own try/finally that always deletes the job file. Retirement is simpler and claims more orphans: one in-flight collection per process instead of a per-root map and rotating 20-record scan, and the job record (written before copying) no longer carries a bundle name because lsof +D scans the whole runtime directory (measured equal cost, same result on a live copy). A never-submitted copy is retired once its producer has exited and its job is missing, so a bootstrap timeout or a crash mid-copy no longer leaves a copy forever; the open-file check still guards deletion. Collection now starts from the launcher after the attempt.
The signed investigation harness left the tree in the previous telemetry commit by a staging slip; its results and pinned link stay in the PR. This trims the reference doc to why the copy and launchd exist, the fallback states and the cleanup rule, trims the reliability gate to what its validator needs, and points AGENTS.md at the reference doc next to the Windows relocation entry.
A copied daemon refused at exec (for example by Gatekeeper) never answers, so every fresh start paid the full 10 s readiness wait before the fork fallback. The readiness loop now reads the job state every 500 ms and abandons as soon as the job is stopped or missing; a running or unreadable job is still waited out and never forked beside. Also drops the dead forkEntryPath the stable launch never read (its options type now omits it) and un-exports the handoff constant.
…d ones Each runtime copy is a full Orca.app, so Spotlight indexed it as an app and LaunchServices kept a record for it that outlived the copy. A registered copy claims orca: links and Markdown/CSV files, and becomes their default handler whenever /Applications/Orca.app is not registered. New copies go under runtime-*/app.noindex/, which Spotlight skips and which stops the record LaunchServices made while the bundle was being copied. Retirement now runs lsregister -u on every bundle in the copy (both the app.noindex layout and the earlier runtime-*/Orca.app layout) once lsof shows it unused, then deletes it. A running copy stays registered, because Local Network access may be resolved through that record. Collection and stable-copy telemetry match the runtime-* directory, so copies made before this change are still adopted, classified and retired.
The reference doc now explains why copies sit in a .noindex folder, why only retired copies are unregistered, and how to turn the copy launch off: make launchMacDaemonFromStableBundle return null, and keep the retirement code until no copy-launched daemon can remain, because the old code never deletes copies. A test pins that rollback: with the stable launcher returning null, the launcher forks and still runs the copy collection.
…e them The `.noindex` folder kept copies out of Spotlight and LaunchServices, but Local Network access is resolved from the signing identifier through LaunchServices to the executable's Mach-O UUID. After an update that changes Electron only the copy carries the running daemon's UUID, so an unregistered copy risks the same Local Network loss main has today. Copies go back to `runtime-*/Orca.app`; retirement still unregisters each copy before deleting it, so deleted copies leave no LaunchServices entry. The remaining trade-off: while `/Applications/Orca.app` is missing, a running registered copy can be picked for `orca:` links and documents.
Spotlight listed each runtime copy as a second Orca app. New copies go back under runtime-*/app.noindex/Orca.app, which Spotlight skips. Retirement and stable-copy telemetry match the runtime-* directory, so copies in the earlier runtime-*/Orca.app layout still retire and classify the same way. Local Network access identifies the daemon by its code signature and main-executable UUID, not by a LaunchServices record, so an unregistered copy keeps it. The launchd job now sets AssociatedBundleIdentifiers to com.stablyai.orca, which is how a job not installed through SMAppService names the app it belongs to. Copies are never registered explicitly; retirement still runs lsregister -u before deleting each one.
…on on the pinned Node Contents/Helpers/Orca Terminal Host.app carries the pinned Node, the daemon's out/main JS and this slice's node-pty, signed inside-out as com.stablyai.orca. afterPack boots it through one PTY round trip, then fails the build on layout, Info.plist, macOS floor (NODE_RUNTIME_DARWIN_MINIMUM_OS vs Node's minos), architecture or signature drift.
Packaging now fetches the darwin Node from nodejs.org, whose download has no retry. Each mac workflow caches it with the electron-builder downloads, keyed on the pin, and warms both darwin targets inside the existing retry wrapper.
…r, not the whole app The stable launch now clones Contents/Helpers/Orca Terminal Host.app (~124 MiB instead of ~628 MiB) and runs its Node on its daemon entry, without ELECTRON_RUN_AS_NODE. The copy must still match the running app's designated requirement. A missing helper falls back to the fork, and macOS below the helper's Node floor forks without copying.
…ways clean up A daemon that stayed silent hung packaging past the 20 s deadline; one that closed the connection left the hello unsettled so Node exited 0 without cleanup; a malformed line threw uncaught. Every connect, hello and PTY wait now races the deadline, close/error/parse failures reject, and the daemon and scratch dir are removed on every path.
…fallback Sharing the electron-builder cache let old Node archives accumulate through restore-keys. Also moves release-mac-build's Electron cache comment back onto its step.
…s name in one test packageMacTerminalHost turned an unknown arch into darwin-undefined; it now throws through the shared mac arch mapping. A test asserts the packager and the desktop agree on the helper bundle and executable names, replacing a Linux/Windows test that could not fail.
…minal-host # Conflicts: # AGENTS.md
…ection; keep only passing gate commands
…minal-host # Conflicts: # src/main/codex/codex-background-terminals.ts # src/main/daemon/daemon-out-of-process-launcher.ts
…bs start in the terminal host helper
…and boot it outside the build tree
The previous commit took the file from a newer main, which pulled unrelated strings into this PR.
…r a fixed launchd label Name the copy after the helper's CDHash, reuse it when present, and publish a new one by cloning into a staging dir, verifying it once against the app's designated requirement and renaming it into place. One launchd label per profile and protocol replaces per-launch labels, so job.json, producer pids and per-label collection go away. Retirement deletes any other copy lsof shows unused. The stable launcher returns null for every fork fallback and logs its reason.
…ves them A nested package's own dependencies were never walked, so a hoisted dependency of a nested package was left out of the helper. Resolve each dependency through the node_modules lookup Node performs from its parent and copy it to the same relative place, unless a copied package already carries it.
…minal-host slice An arm64 runner without Rosetta skipped the x64 helper's PTY boot check and shipped the slice untested. Release channels and CI now fail there; local cross-arch builds still skip with a log line.
… into jinwoo/macos-terminal-host-extras # Conflicts: # config/reliability-gates.jsonc # docs/reference/macos-daemon-tcc-attribution.md # src/main/daemon/macos-daemon-bundle.ts
… into jinwoo/macos-terminal-host-extras
… reusing its label
… into jinwoo/macos-terminal-host-extras
…minal-host # Conflicts: # src/main/daemon/daemon-launched-child-spawn.ts # src/main/daemon/daemon-out-of-process-launcher.ts
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to An empty probe file could produce a misleading access status, and the recovery wording could prompt an unnecessary daemon restart. These are bounded concerns; the differing test counts remain unexplained. Pre-merge checks |
|
… into jinwoo/macos-terminal-host-extras # Conflicts: # src/main/daemon/daemon-pty-adapter.ts # src/main/daemon/types.ts
…-host-extras # Conflicts: # config/electron-builder.config.cjs # config/reliability-gates.jsonc # config/scripts/macos-folder-usage-descriptions.cjs # config/scripts/macos-folder-usage-descriptions.test.mjs # docs/reference/macos-daemon-tcc-attribution.md
types.ts hit the line limit once the Full Disk Access status request joined the union.
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bcf826c1-5b95-44a7-a51a-da1a7fbffb01
📒 Files selected for processing (25)
config/electron-builder.config.cjsconfig/reliability-gates.jsoncconfig/scripts/macos-folder-usage-descriptions.cjsconfig/scripts/macos-folder-usage-descriptions.test.mjsdocs/reference/macos-daemon-tcc-attribution.mdsrc/main/daemon/daemon-adoption-telemetry-event.test.tssrc/main/daemon/daemon-adoption-telemetry-event.tssrc/main/daemon/daemon-full-disk-access-status.test.tssrc/main/daemon/daemon-full-disk-access-status.tssrc/main/daemon/daemon-health-requests.tssrc/main/daemon/daemon-pty-adapter-full-disk-access.test.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-request-router.tssrc/main/daemon/daemon-server.test.tssrc/main/daemon/types.tssrc/main/ipc/developer-permissions.test.tssrc/main/ipc/developer-permissions.tssrc/main/macos-full-disk-access-status.test.tssrc/main/macos-full-disk-access-status.tssrc/renderer/src/components/settings/DeveloperPermissionsPane.test.tsxsrc/renderer/src/components/settings/DeveloperPermissionsPane.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/shared/daemon-adoption-telemetry.test.tssrc/shared/daemon-adoption-telemetry.tssrc/shared/developer-permissions-types.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| "durationSeconds": 2.38, | ||
| "summary": "All 82 focused launch, fallback-deadline, per-build copy, retirement, status and packaging tests passed." |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
printf '%s\n' '--- current receipt ---'
nl -ba config/reliability-gates.jsonc | sed -n '20768,20784p'
printf '%s\n' '--- PR diff for receipt ---'
git diff --unified=12 1c4f16e21245001578388fbe3d26ae304554938e 80f6d7922082e4d583d9e946b529aee1187b5ff6 -- config/reliability-gates.jsonc | tail -n 100
printf '%s\n' '--- focused-count references in the changed file ---'
rg -n -F -- '82 focused' config/reliability-gates.jsonc || test "$?" -eq 1
rg -n -F -- '84' config/reliability-gates.jsonc || test "$?" -eq 1Repository: stablyai/orca
Length of output: 29218
🏁 Script executed:
nl -ba config/reliability-gates.jsonc | sed -n '20768,20784p'
git diff --unified=12 1c4f16e21245001578388fbe3d26ae304554938e 80f6d7922082e4d583d9e946b529aee1187b5ff6 -- config/reliability-gates.jsonc | tail -n 100Repository: stablyai/orca
Length of output: 7718
Reconcile the focused-test count.
The recorded command reports 82 tests, while the PR reports 84. Check the actual command output. Update the receipt only if the command produced 84; otherwise correct the PR report to 82.
| Running old daemons keep their terminals; a denied terminal is recovered by closing it or restarting | ||
| the daemon. | ||
| Running old daemons keep their terminals; settings reports app and terminal-host Full Disk Access | ||
| separately, and a denied terminal is recovered by closing it or restarting the daemon. The packaging |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reserve daemon restarts for terminals that remain affected.
Line 126 presents restarting the daemon as equivalent to closing one denied terminal. The PR guidance recommends a restart only when new terminals are also affected, and notes that restarting closes the daemon’s current terminals. Clarify that users should save work and close the affected session first.
The PR objective specifies this recovery sequence.
| const handle = await open(filePath, 'r') | ||
| await handle.close() | ||
| try { | ||
| await handle.read(Buffer.alloc(1), 0, 1, 0) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not report granted when the read returns no bytes.
If TCC.db exists but is empty, handle.read() can succeed with bytesRead: 0. The probe then reports granted without reading protected content. Check bytesRead and return unknown for a zero-byte read. Keep the handle closure in finally. Node.js documents zero bytes as EOF. (r2.nodejs.org)
Proposed change
--- "a/src/main/macos-full-disk-access-status.ts"
+++ "b/src/main/macos-full-disk-access-status.ts"
@@ -8,7 +8,10 @@
async function readProbeByte(filePath: string): Promise<void> {
const handle = await open(filePath, 'r')
try {
- await handle.read(Buffer.alloc(1), 0, 1, 0)
+ const { bytesRead } = await handle.read(Buffer.alloc(1), 0, 1, 0)
+ if (bytesRead !== 1) {
+ throw new Error('Full Disk Access probe read no data')
+ }
} finally {
await handle.close()
}📝 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.
| await handle.read(Buffer.alloc(1), 0, 1, 0) | |
| const { bytesRead } = await handle.read(Buffer.alloc(1), 0, 1, 0) | |
| if (bytesRead !== 1) { | |
| throw new Error('Full Disk Access probe read no data') | |
| } |
ELI5
Stacked on #27021, which keeps terminals' macOS permissions working across app updates. This PR adds three things around that fix that it does not need to work:
What Changed
Full Disk Access per terminal host in Settings
fullDiskAccessStatusdaemon request runs the existing Full Disk Access probe inside each running terminal service (current and older-protocol daemons). Any denied reply wins, and "granted" needs every one to be granted; anything else shows "unknown". If the daemon has degraded to local terminals, the app's own probe counts too. A daemon that predates the request, or one Orca can't reach, answers "unknown", never "granted". The probe now reads one byte instead of only opening the file, because opening alone can succeed while reading is denied.stable-copyin daemon adoption telemetryspawner_path_classfield gainsstable-copyfor a daemon whose spawner lives underuserData/daemon-host/macos/terminal-host-*. Before this, such a daemon would be reported asother.Folder descriptions in the app's Helper bundles
Orca Helperprocess. After packaging, the build now writes the Desktop, Documents and Downloads descriptions into every<App> Helper*.appInfo.plist, so the fallback asks for folder access with the same wording as the app.Why
These were part of #27021 and moved here so that PR stays limited to the fix itself. Each one is independent of how the daemon starts:
Mixed versions: an #27021 (protocol v45) daemon that lacks the new request answers it with an error, which Orca shows as "unknown". No protocol bump and no new stream opcode.
Linked Issue
Part of #13921, which #27021 fixes.
Visual Proof
Settings permission screen, rendered in a hidden test window with injected replies: app granted, terminal host denied.
Before:
After:
Testing
Run locally on macOS (arm64):
pnpm tcpasses.repro-13767-shell-ready-marker-lost-to-exec.test.ts, which also fails onmainon this Mac.pnpm run check:reliability-gatespasses; the gate's focused command runs 84 tests, all passing.oxlintis clean on the changed files.Tests cover: the daemon answering the new request; the adapter mapping old daemons and lost contact to "unknown"; denied/unknown precedence across current and older daemons; the Settings row and recovery text; the
stable-copyclassification; and writing the descriptions into Helper bundles while leaving other helpers alone.Review
Split from #27021, where this code was reviewed together with the launcher. The content matches #27021's head before the split (
7be6448a885), plus a refreshed reliability-gate evidence entry.Agent skill upstream boundary
Notes
macOS only. On Linux and Windows the Settings row is unchanged and no terminal-host status is requested. SSH and remote hosts are not queried; only local daemons are. Merge after #27021.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)