Repository navigation
fix(macos): tell the user when Orca's terminal service can't read their folder, and walk them through the fix - #21923
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. 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:
📝 WalkthroughWalkthroughThe change replaces cwd permission checks with directory enumeration and separates daemon divergence detection from event emission. It records folder-access mismatch evidence by daemon identity, probes fresh-daemon folder access, and exposes results through IPC and preload APIs. The renderer adds localized notices, a fix dialog, settings navigation, reset and restart handling, and action telemetry. It also registers and tests the expanded Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to The folder-permission recovery flow can hide a real warning, show stale remediation status, or incorrectly report reset outcomes. Resolve these issues before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 38.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 75 functions across 37 files. (1 skipped: 1 unsupported.) ✨ 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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 30bcf50e-ef14-4b77-aa96-b9bf342a4036
📒 Files selected for processing (20)
src/main/daemon/daemon-adoption-telemetry-event.test.tssrc/main/daemon/daemon-adoption-telemetry-event.tssrc/main/daemon/daemon-folder-access-mismatch.test.tssrc/main/daemon/daemon-folder-access-mismatch.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-pty-session-spawn.tssrc/main/daemon/directory-enumeration-probe.tssrc/main/daemon/terminal-host-cwd-readability.test.tssrc/main/daemon/terminal-host-session-create.tssrc/main/ipc/pty-management.test.tssrc/main/ipc/pty-management.tssrc/preload/api-types.tssrc/preload/api/pty-management-api.tssrc/renderer/src/hooks/useMacTccAttributionSeveredNotice.test.tsxsrc/renderer/src/hooks/useMacTccAttributionSeveredNotice.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/preload-api/web-terminal-api.tssrc/shared/daemon-adoption-telemetry.test.tssrc/shared/telemetry-daemon-event-schemas.tssrc/shared/telemetry-event-registry.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
Important
The notice is only checked on hook mount and window focus. The app mounts that hook before workspace hydration and PTY creation is deferred to pane mount, so a spawn that records the mismatch happens while the window is already focused — no focus event follows, and the toast stays hidden until the user alt-tabs away and back.
Reviewed changes
- Daemon cwd probe:
isCwdReadableByThisProcessnow usesenumerateDirectoryOnce(opendirSync+ onereadSync) instead ofaccessSync(R_OK|X_OK), so a TCC denial that letsaccess()pass is still caught while ENOENT/ENOTDIR/unexpected errors stay "readable". - Mismatch evidence store (
daemon-folder-access-mismatch.ts): one entry keyed by daemon identity, exposing only{daemonScope, cwdClass}; clears only when the same daemon reads back a folder of the same class. - Spawn-path oracle:
reportDaemonPtyCwdVerdictperforms one app-side enumeration that feeds bothdaemon_pty_cwd_deniedand the notice;pty-managementcarries the evidence on the existingmacTccAttributionreply. - Renderer: a second toast in
useMacTccAttributionSeveredNotice, latched per daemon scope per session. - Telemetry:
daemon_folder_access_notice(shownfrom main;dismissed/open_manage_sessionsfrom the renderer) with schema and registry entries.
⚠️ A spawn-recorded denial is not surfaced until the next window focus
Technical details
# Folder-access evidence has no poll trigger after it is recorded
## Affected sites
- `src/renderer/src/hooks/useMacTccAttributionSeveredNotice.ts:204-209` — the only `maybeToast()` calls are mount and the `window` `focus` listener; the effect deps contain nothing tied to spawn/daemon activity.
- `src/main/daemon/daemon-pty-session-spawn.ts:254-262` — evidence is recorded on a new spawn (`isNew && !attachOnly`), which occurs after hydration and pane mount, i.e. after the hook's mount poll.
- `src/main/ipc/pty-management.ts:74-76` — the comment itself calls this a focus-time poll.
## Required outcome
- Evidence recorded while the window stays focused must reach the toast without requiring a later focus/blur, otherwise the primary scenario (a new terminal opened into a denied folder) shows the user an unexplained "Operation not permitted" until they switch away and back.
## Suggested approach (optional)
- Notify the renderer / re-run the poll when `recordDaemonFolderAccessMismatch` stores new evidence, or re-poll on terminal-spawn failure, or add a bounded interval while a mismatch is pending.
## Open questions for the human (optional)
- Is the focus-only trigger deliberate, or is the spawn-after-mount ordering unaccounted for?ℹ️ Nitpicks
StoredMismatch.canonicalPathandobservedAtMs(src/main/daemon/daemon-folder-access-mismatch.ts:51-52) are written but never read, andcanonicalPathisn't canonicalized. Either use them (e.g.observedAtMsfor staleness) or drop them.PtyManagementDaemonCwdClass(src/preload/api/pty-management-api.ts:21-26) re-declaresDAEMON_PTY_CWD_CLASSESas a literal union, so adding a class to the shared enum would not fail the renderer's exhaustivefolderAccessFolderNameswitch. The comment acknowledges the constraint; a compile-time tie (or a test comparing the two) would keep them from drifting.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: a884a166-1c7a-4544-b4af-d24803598a73
📒 Files selected for processing (26)
src/main/daemon/daemon-folder-access-mismatch.test.tssrc/main/daemon/daemon-folder-access-mismatch.tssrc/main/daemon/daemon-folder-access-probe.test.tssrc/main/daemon/daemon-folder-access-probe.tssrc/main/ipc/developer-permissions.tssrc/main/ipc/pty-management.test.tssrc/main/ipc/pty-management.tssrc/preload/api/pty-management-api.tssrc/renderer/src/components/shared/MacFolderAccessFixDialog.test.tsxsrc/renderer/src/components/shared/MacFolderAccessFixDialog.tsxsrc/renderer/src/components/shared/mac-folder-access-folder-name.tssrc/renderer/src/components/shared/useDaemonActions.test.tsxsrc/renderer/src/components/shared/useDaemonActions.tsxsrc/renderer/src/hooks/MacosTccPromptNoticeHost.tsxsrc/renderer/src/hooks/useMacTccAttributionSeveredNotice.test.tsxsrc/renderer/src/hooks/useMacTccAttributionSeveredNotice.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/mac-folder-access-fix.tssrc/shared/daemon-adoption-telemetry.test.tssrc/shared/developer-permissions-types.tssrc/shared/telemetry-daemon-event-schemas.ts
💤 Files with no reviewable changes (5)
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/i18n/locales/en.json
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
Important
The new fix dialog can reopen into a stale "Done." state after a denial recurs, hiding the Restart button for exactly the case where the restart was not enough. One inline comment.
Reviewed changes
- Restart-viability probe: a scrubbed-env child (
ELECTRON_RUN_AS_NODE=1, 3s deadline) now answers whether a freshly forked daemon could list the denied folder, surfaced asrestartWillHelpand re-run from the existing focus poll behind a 5s interval;trueis final. - Fix dialog: the folder toast now raises a two-step
MacFolderAccessFixDialog(Allow Orca under Files and Folders → Restart), with Restart blocked when the probe says a restart alone would not help, plus a new shared store andmac-folder-access-folder-namehelper. - Files-and-Folders permission: added
files-and-foldersas an open-the-pane-onlyDeveloperPermissionId, wired to the Privacy Files-and-Folders pane. - Restart-outcome telemetry: the first spawn by a different daemon into the same folder class emits
restart_outcome_fixed/restart_outcome_still_denied;daemon_folder_access_noticegainsfix_opened,settings_opened, andrestart_clicked. - Manage Sessions copy: "Restart the terminal daemon?" and the old "Process exited / legacy sessions" description are rewritten to "Restart the terminal service?" / "Open terminals and agents will restart. Terminals on remote hosts are not affected."
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in these commits. Not approving yet because the previously flagged dialog-state and focus-trigger items are unaffected by this delta.
Reviewed changes
- Notice can return after a transient null poll: a
folderAccessMismatch: nullresult now deletes the visible scope fromfolderScopesShownbefore dismissing, so a reconnect blip that briefly reads no daemon no longer latches the scope forever; a user dismiss still keeps it latched. - Toast reduced to one action: the folder toast drops the
Not nowbutton and recordsdismissedthrough Sonner'sonDismiss, which is also fired by programmatictoast.dismiss()and guarded so a scope already cleared is not counted as a user dismissal. - Restart retirement moves into the store: on a successful restart the dialog now calls
markRestarted(scope), and the notice hook retires the toast viarestartedScopeinstead of the dialog dismissing it directly. - Dialog restructured to a checklist: steps no longer carry buttons; a new
FixFooterholds the single active action (Open System Settingswhen a restart alone cannot help,Restart, orCloseonce done), and an unanswered probe now gets an explanatory step-1 helper. - Copy: the toast now states the cost ("commands run there may fail until it's fixed") and the done line reads "Terminal service restarted…".
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
- Rendered the post-restart state as a checklist: a successful restart now checks off both steps and offers a
Donebutton instead of the previous "Terminal service restarted…" sentence. - Added a step-1 helper for the denied case (
restartWillHelp === false) telling the user to turn the folder toggle off and on again, kept "Couldn't verify. Skip if already allowed." for the unverified case, and shortened that copy. - Dropped the fix dialog's now-unused
closekey and repointed the footer's done-state button at thedonekey.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: eb638740-7342-439b-ae51-14787c09d9f4
📒 Files selected for processing (18)
src/main/computer/macos-computer-use-permissions.test.tssrc/main/computer/macos-computer-use-permissions.tssrc/main/daemon/daemon-folder-access-mismatch.test.tssrc/main/daemon/daemon-folder-access-mismatch.tssrc/main/daemon/daemon-folder-access-reset.test.tssrc/main/daemon/daemon-folder-access-reset.tssrc/main/ipc/pty-management.test.tssrc/main/ipc/pty-management.tssrc/main/macos-tcc-reset.test.tssrc/main/macos-tcc-reset.tssrc/preload/api/pty-bridge-stream-and-serialization.tssrc/preload/api/pty-management-api.tssrc/renderer/src/components/shared/MacFolderAccessFixDialog.test.tsxsrc/renderer/src/components/shared/MacFolderAccessFixDialog.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/preload-api/web-terminal-api.tssrc/shared/daemon-adoption-telemetry.test.tssrc/shared/telemetry-daemon-event-schemas.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline, plus a design question about what happens when the user declines the re-prompt.
Reviewed changes
- Shared the macOS TCC reset: extracted
readMacosBundleIdandresetMacosTccPermissionintosrc/main/macos-tcc-reset.tsand re-pointed the computer-use reset at them, so both remedies issue the sametccutil resetthrough therunProcessSyncchokepoint (10s bound, failure returned as data). - Added the folder-access reset remedy:
resetFolderAccessForDaemonclears Orca's TCC row for the denied folder class, has the app read the folder to raise the macOS prompt, then forces a fresh-daemon re-probe and emitsreset_outcome_{allowed,still_denied,unknown}from main. - Extended the mismatch store:
getDaemonFolderAccessTargethands the remedy the stored path/class without emittingshown, andrefreshDaemonFolderAccessProbegainedforce— it waits out an older in-flight probe, then probes the entry left behind. - Wired the side-effecting IPC: a new
pty:management:resetFolderAccesschannel (user-click only) plus preload and web stubs, where the web client returnsunsupported. - Renderer: the fix dialog gained a
Reset permissionaction withbusy/probed/failedstates, a "Still blocked after the reset." line, and thereset_*telemetry actions.
ℹ️ A denied re-prompt after the reset silently leaves Orca with less access than before
The reset is the one action in this flow that removes a working grant. Clearing Orca's TCC row is what makes macOS ask again, but the only thing that re-establishes the grant is the user choosing Allow on the prompt promptByReadingFolder raises — and nothing detects or surfaces the Don't Allow outcome.
Technical details
# The reset can revoke Orca's own folder access with no recovery path
## Affected sites
- `src/main/daemon/daemon-folder-access-reset.ts:106-109` — after `resetMacosTccPermission` returns ok, the flow relies on the user allowing the prompt; a denial is indistinguishable from success at this point.
- `src/main/daemon/daemon-adoption-telemetry-event.ts:117-121` — if the app itself ends up denied, `hasDaemonPtyCwdDenialDiverged` is false, so the spawn path neither records new evidence nor clears the existing `stored` entry.
- `src/renderer/src/components/shared/MacFolderAccessFixDialog.tsx:116` — the dialog can therefore keep offering a `Reset permission` whose prompt is already denied, alongside a stale "Still blocked after the reset." line.
## Required outcome
- Declining the re-prompt must not leave the user strictly worse off, quietly. Either the reset flow detects the post-prompt denial and says so (e.g. "Orca is now denied this folder — enable it in System Settings"), or the copy warns that declining revokes Orca's own access and the button carries a confirmation.
## Open questions for the human (optional)
- Is the reset intentionally offered on a known-good app grant, given that a denied re-prompt is worse than not resetting? Is the checkbox-free flow acceptable because `reset_outcome_still_denied` is expected to catch it in the field?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in this delta. Not approving yet because the
restartState/ step-1 /resetStatethreads from the preceding reviews are still open on this PR.
Reviewed changes
- Rewrote the denied case's step 1: the label is now "Re-allow Orca for your {{folder}}" and the helper states what Reset does and to click Allow when macOS prompts.
- Demoted System Settings to a fallback: with
restartWillHelp === falsethe footer starts as Cancel + Reset, and only swaps Cancel for Open System Settings oncesettingsIsFallbackreports a reset that failed or came back still blocked. - Updated the dialog tests to the new footer states (the Files and Folders opener test moves to the unverified branch).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in these commits. Not approving yet because the prior step-1 checklist thread is still open (an unanswered probe plus a successful restart checks the row while its helper still reads "Couldn't verify"), and the focus-trigger and reset-revokes-grant concerns from earlier reviews are unaffected by this delta.
Reviewed changes
- Renamed the probe verdict:
restartWillHelp: boolean | nullbecamefreshDaemonAccess: 'allowed' | 'denied' | 'unknown'across the evidence store, the IPC reply, the dialog, and the reset-outcome telemetry map. - Removed the spawn-path probe:
recordDaemonFolderAccessMismatchno longer forks a child, so the PTY spawn path is free of the probe; the focus-time poll'srefreshDaemonFolderAccessProbeis now the only prober. - Fixed the restart-outcome latch: the module-level
priorDenialwas replaced bystored.outcomeReported, so a denial the same daemon later read back no longer produces a falserestart_outcome_still_deniedfor the next daemon. - Made the shared TCC helpers async:
readMacosBundleIdandresetMacosTccPermissionnow run throughrunProcess, and the computer-use reset awaits them instead of blocking main onspawnSync. - Moved the notice latch into the store: one
visibleScope/dismissedScopespair withshowNotice/retireNotice/dismissNotice, and theshownevent is now emitted by the renderer when the toast is actually raised. - Keyed the fix dialog by daemon scope: extracted
FolderAccessFixand mounted it withkey={mismatch.daemonScope}, so a replacement daemon starts a fresh checklist instead of inheritingrestartState/resetState(addresses the two open dialog-state threads). - Added a real-path probe-script test:
daemon-folder-access-probe-script.test.tsexecutes the inlined child script against real directories (ok, missing, file-as-missing, chmod-denied) instead of mocking the spawn.
Verified locally: 143 main-side and 47 renderer tests pass across the 12 touched files, and pnpm run check:code-quality:changed reports 0 new findings.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Made a forced probe always re-probe:
refreshDaemonFolderAccessProbe(identity, { force: true })now skips the settled-allowedshortcut in addition to the 5s interval, so a reset is always judged by a probe that ran after it; the old "settled true stays final under force" test became "probes again on a forced refresh even after a settled allowed". - Decoupled the poll's two answers: a rejected
getCurrentDaemonMacTccAttributionHealth()now yieldshealth: 'unknown'without nullingfolderAccessMismatch, and a rejected re-probe is swallowed so the re-read folder evidence is still returned. - Suppressed the step-1 unverified helper once the restart is done, so a checked row no longer contradicts its "Couldn't verify" copy (resolves the prior inline thread).
- Closed the fix dialog when the reset's re-read returns
mismatch: null(daemon replaced mid-reset) instead of showing "Still blocked after the reset.", with the dialog tests updated.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline. Not approving because the earlier focus-trigger concern (a spawn-recorded denial only surfaces on the next window
focus) is unchanged by this delta.
Reviewed changes
- Scoped the folder-access notice per folder class:
daemonScopenow digestsdaemonKey + cwdClass, so one daemon denied a second class mints a new scope (a new notice and remedy) instead of retitling the first one. - Derived the fix dialog from the latest verdict: the store dropped
open/applyPollVerdictforopenScopeplus an unconditionalapplyVerdict; the dialog renders only whileopenScope === mismatch.daemonScope, so evidence that moves to another scope closes it rather than retargeting the title, checklist, and reset mid-remedy. - Restricted the permission reset to TCC-backed classes: added the shared
MAC_TCC_FOLDER_CLASSES/isMacTccFolderClass, and a deniedother-home/outside-homeworkspace now gets Cancel + Open System Settings instead of a reset that has no row to act on. - Bounded the permission prompt's read:
promptByReadingFolderraces the folder read against a 60s deadline, and skips the post-reset probe (emittingreset_outcome_unknown) when the macOS sheet is still up.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in these commits. Not approving because the
probed-state note from the prior review is unchanged.
Reviewed changes
- Reworked the notice latch into a per-scope phase map:
visibleScope+dismissedScopesbecamenoticePhaseByScope: Map<scope, 'visible' | 'retired' | 'dismissed'>with avisibleNoticeScopehelper;showNoticeretires any other visible scope (Sonner keeps one toast per id), so a reconnect-blip re-show reads as the same notice rather than a new one. - Counted
shownonce per scope: the hook emitsshownonly when the scope was absent from the map, so a re-show after a transient null poll no longer inflates the denominator the affected-user rate is read against. - Dropped step 2's restart warning once the restart completes: the
restartConsequencehelper is suppressed whenrestartState === 'done', matching step 1.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in these commits. Not approving because the
probed-state inline from the previous review is unchanged by this delta.
Reviewed changes
- Closed the fix dialog once its evidence is gone —
applyVerdict(null)now clearsopenScopealongside the verdict, andFolderAccessFixno longer carrieskey={mismatch.daemonScope}: the dialog already unmounts wheneveropenScope !== mismatch.daemonScope, so a replacement daemon still opens with an unticked checklist. Tests cover both the cleared-evidence and same-scope-reopen paths. - Tied the preload cwd class to the shared enum —
PtyManagementDaemonCwdClassis now an alias ofDaemonPtyCwdClassrather than a copied literal union, so adding a class toDAEMON_PTY_CWD_CLASSESfails the folder-name switch at compile time. This closes the drift risk flagged in an earlier review. - Kept the folder-access toast up when the dialog opens — the
Fixaction callsevent.preventDefault(); Sonner 2.0.7 runs the handler and then returns beforedeleteToast()when the click is prevented, so cancelling the dialog leaves the still-true notice on screen instead of latching its scope with nothing to show.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in these commits. Not approving because the
probed-state inline from the previous review is still open and untouched by this delta.
Reviewed changes
- Ended the folder-access remedy with its evidence —
applyVerdictnow clearsopenScopewhenever the incoming verdict belongs to a different scope and retires the visible notice on a null verdict, so a remedy that movement or clearing ended can no longer reopen when the original scope comes back, and the toast no longer lingers when a reset finds the evidence gone. The dialog guard collapses to!openScopeand the hook drops its own retire step. - Cleared the reset failure once the grant lands — the
reset_failederror line is suppressed whilefreshDaemonAccess === 'allowed', so a reset that failed before the user granted the folder in System Settings no longer reads as a live failure, and the checklist can show the one tick it earned. - Let each fix-dialog button report its own work — the footer's spinner and label now come from
resetState/restartStaterather than the sharedbusy, so the restart button no longer reads "Restarting…" while a reset is what is actually running.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — the prior
probed-state inline is addressed; one residual doc nit inline. Not approving because the focus-trigger concern from the initial review and the reset-revokes-grant design question are unchanged by this delta.
Reviewed changes
- Moved the app-side folder read off main's spawn path —
enumerateDirectoryOnceis now async (fs.promises.opendir) with a sync twin for the daemon process, andreportDaemonPtyCwdVerdictis fire-and-forget (void), so an unanswered macOS prompt no longer holds main's event loop for the life of a spawn. - Stopped the reset from presenting a verdict it never measured — when the 60s prompt deadline passes,
resetFolderAccessForDaemonnow returnsfreshDaemonAccess: 'unknown'(emittingreset_outcome_unknown), and the dialog gates the "Still blocked after the reset." line on adeniedverdict. This resolves the open inline thread. - Let the refresh own its skip policy — the focus-time poll now always calls
refreshDaemonFolderAccessProbe; the settled-allowedand 5s-interval shortcuts live entirely inside the refresh, and the handler reports whatever evidence the refresh leaves behind.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const FILES_AND_FOLDERS_PANE = { id: 'files-and-folders' } as const | ||
|
|
||
| type RestartState = 'idle' | 'busy' | 'done' | 'failed' | ||
| /** 'probed': the reset ran and a fresh probe answered; the verdict itself is on the mismatch. */ |
There was a problem hiding this comment.
ResetState documents 'probed' as "the reset ran and a fresh probe answered", but the new deadline path returns 'probed' with freshDaemonAccess: 'unknown' without ever probing (main emits reset_outcome_unknown). The dialog no longer misreads it, so this is the last piece of the prior concern. Update the doc — e.g. "the reset ran; the verdict it left is on the mismatch, unknown when the prompt went unanswered" — so the type contract matches what the code now guarantees.
There was a problem hiding this comment.
✅ No new issues found in this delta. Not approving because the
ResetStatedoc nit from the prior review is still open, and the focus-trigger / reset-revokes-grant concerns are unchanged.
Reviewed changes
- Removed the synchronous enumeration twin —
enumerateDirectoryOnceSyncis gone; the daemon'sisCwdReadableByThisProcessnow awaits the asyncenumerateDirectoryOncebefore forking, so a folder read that blocks can no longer stall the daemon's event loop for every terminal it serves. - Re-pointed the readability test at
node:fs/promises(opendir/closeasync, synchronous throw still covered), socwdReadableByDaemonis exercised through the same helper the daemon now runs.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ir folder On macOS, a terminal daemon that survived an app update can be refused access to a workspace under Documents, Desktop, or Downloads while the Orca app itself can still read it. Terminals opened there die with "Operation not permitted" and nothing on screen explains why. The daemon has reported `cwdReadableByDaemon` on every create since #18043 and main has emitted `daemon_pty_cwd_denied` on proven divergence since then; the field data says 1,438 users hit it in 21 days. What was missing was the notice. The verdict itself moves off `access()`. A grant-less probe on an affected machine showed a TCC mode where `access(R_OK|X_OK)` passes on `~/Documents` and `opendir` still fails, so the check now does what a shell listing its cwd does: `opendirSync`, one `readSync`, `closeSync`. Only EPERM/EACCES reads as denial — a missing path, a non-directory, or an unexpected error still reads as readable, so a non-permission failure can never masquerade as one. The same probe is what the app side compares with, through one oracle shared by the telemetry emitter and the notice, so the spawn path reads the directory once. Proven divergence now also records evidence in main: one entry, keyed by the daemon's pid, start time and launch nonce, carrying an opaque digest of that identity and the folder class. No path leaves main. The existing focus-time `macTccAttribution` poll carries it to the renderer, which raises a second toast latched per daemon scope: dismissed stays dismissed, and a restart mints a new identity so the poll returns null and the toast clears with no post-restart probe. If the replacement daemon is denied too, about 31% of cases, the next spawn re-records under the new scope and the notice returns, now with the re-allow sentence doing the work. No new IPC channel, no daemon protocol field, no polling change, and nothing new on the spawn path beyond one `opendir`. `daemon_folder_access_notice` counts shown, dismissed and open_manage_sessions against `daemon_pty_cwd_denied` as the denominator; `shown` is emitted from main the first time a scope leaves the IPC handler, so the renderer carries no telemetry plumbing for it.
…ass reads back A readable spawn in ~/code said nothing about a Documents denial but was hiding the notice; retire the evidence only when the daemon reads a folder of the class it was denied on.
The Manage Sessions restart confirmation still described the product as it was before agents resumed themselves: it promised panes showing "Process exited" that the user reopens by hand, and mentioned legacy-protocol sessions nobody outside the daemon code can act on. Open terminals and agents come back on their own now, so the old copy made a routine remedy sound like data loss. It also called the thing a "daemon". The same restart is about to be offered from a user-facing fix dialog, so both surfaces now say "terminal service", and the confirm button is just "Restart". The new body adds the one fact the old one never stated: terminals on remote hosts are not affected. Translations of the two changed strings are dropped so the five non-English locales fall back to English rather than keep showing copy that is now wrong.
The folder-access toast told the user their terminal service could not read Documents and then handed them a paragraph: restart from Manage Sessions, and if that does not work, re-allow Orca in System Settings. Both halves were guesses. Roughly a third of restarts do not fix it, and the user had no way to know which case they were in before spending every open terminal on finding out. Main can now answer that. `daemon-folder-access-probe.ts` forks a short-lived child of the app binary the same way the daemon itself is forked, runs one opendir/readdir/closedir against the denied path, and prints a single JSON line. macOS attributes a TCC grant to the process that forked the child, so a child of the app running now answers exactly the question the running daemon cannot: would a replacement daemon get in? The child goes through the shared child-process wrapper, never a shell, with a 3s deadline, a 1KB output cap and an environment scrubbed to PATH/HOME/TMPDIR. Every failure — timeout, bad output, spawn error — reads as `unknown`, never as a verdict. That answer rides out as `restartWillHelp` on the evidence the existing focus-time poll already carries, and the toast becomes a title and two buttons: Fix… and Not now. Fix opens a dialog with the two real steps. When the grant is already in place, step one is shown as done and Restart is live. When it is not, step one is open and Restart is disabled until it completes — which it does by itself, because the poll re-probes while the answer is still no, and returning from System Settings is the moment that lands. An unanswered probe never accuses the user of a missing grant; it leaves both steps open. Restart calls the management API directly rather than stacking the Manage Sessions confirmation on top, since the dialog already states the consequence. Success replaces the steps with a done line and takes the toast down; failure says so inline and leaves the button usable. System Settings opens through the existing developer-permissions pane opener, which takes an id rather than a URL, with Files and Folders added to it. The event's action enum now also counts fix_opened, settings_opened, restart_clicked and — emitted from main when a replacement daemon's first spawn lands in the folder class the previous one was denied on — whether the restart actually worked.
…d no daemon A daemon identity reads as null during any reconnect blip, and the poll reports that as "no mismatch". The notice dismissed itself and then never showed again for that daemon, because the once-per-daemon latch still held its scope. Only "Not now" should latch.
One line read like a stray warning. The toast now says who is blocked and what fails, and still leaves the steps to the fix dialog.
…very other toast "Fix" is the only button; the X dismisses. Sonner fires onDismiss for programmatic dismissals too, so the post-restart takedown now goes through the store and the hook, and only a user's X is counted as dismissed.
…ction in the footer Buttons inside each step made the list look like a form, and a footer Close duplicated the X. The footer now carries the active step's action, with a ghost Cancel; a probe that could not answer says so under step 1 instead of showing a check.
A hedged sentence addressed to the user read like chat. On success both steps check off and the footer offers Done; the unanswered-probe helper is a status, not advice.
…ngs as the fallback Step 1 was labelled like a Settings task while the button did something else, with two routes in the footer for one step. The denied state now names the step for what the reset does, explains it under the step, and shows System Settings only after a reset fails or leaves things blocked.
…survived The stored denial is the prior denial, so a second copy of it outlived the one event that retires it: a daemon that read its own folder back cleared the entry but left the copy, and the next daemon's first denial was then reported as a restart that had never happened. Track the outcome on the entry itself, drop the spawn-path probe (ten denied terminals forked ten probe children the focus-time poll re-runs anyway), and stop emitting `shown` from a getter the reset path calls for data. The renderer's toast latch is what decides a scope is shown, so it emits it. Both accessors now read one identity-matched entry.
…t as a tri-state `restartWillHelp: boolean | null` re-encoded a verdict the probe already returns as a named union, so every reader had to remember that `false` meant "Orca itself must be re-allowed" and `null` meant "no answer". `freshDaemonAccess: 'allowed' | 'denied' | 'unknown'` says it, end to end through main, the IPC payload, the preload mirror and the dialog. The reset's outcome event becomes a lookup. No user-visible string changes.
…hree Two refs in the hook and a field in the store tracked the same fact, and the dialog reached the hook through a store field plus an effect just to take its own toast down before sonner echoed the dismissal back. The store now holds the visible scope and the scopes the user closed, and exposes the three things that happen to a notice: it is shown, someone else retires it, or the user dismisses it. The dialog calls retire directly and the effect is gone. `settingsIsFallback` loses an argument that was always true at its only call site, so it becomes the local it always was.
Two spawnSync calls with a ten-second timeout sat inside an async IPC handler, so clearing a TCC row held main's event loop for as long as either binary took. Both now run through runProcess. The computer-use caller that shared them was already async, so it awaits them.
Every other test mocks the spawn away, so the minified child script — the one piece that duplicates enumerateDirectoryOnce's errno mapping — had no oracle. It now runs against a temp directory, an absent path, a file, and a directory whose mode withholds it, which is skipped for root and on Windows.
All four callers that ask "is this evidence still this daemon's?" now go through the same private accessor, so the rule the canonical path depends on lives in one place.
…ke a forced re-probe always probe A rejected attribution-health read nulled the folder evidence on the same poll, which the renderer read as "cleared". A forced refresh after a reset returned early on an older settled verdict. The dialog also closes when a reset finds the evidence gone, and stops showing the unverified helper once the restart is done.
One daemon denied two protected folders kept one scope, so the toast, the fix dialog, and the tccutil reset could each be about a different folder.
The store held an `open` flag and a mismatch frozen at the moment the toast was raised, so the dialog could open on a stale verdict and its remedy state could survive a close. It now keeps the latest verdict and the scope the user opened, and the dialog is shown only while the two agree.
…eset A workspace symlinked out of Documents or on an external volume can be denied too, and the dialog offered a reset that main refuses. One shared list of the TCC-backed folder classes now decides both.
An unanswered macOS sheet blocks the app's folder read for as long as the user ignores it, and the fix dialog is modal and busy until that read returns. The wait now ends after a minute and reports an unknown outcome rather than probing under the sheet.
A reconnect blip reports no daemon, which takes the toast down and lets the same scope raise it again. Both raises counted as separate notices, inflating the denominator behind the affected-user rate. The two latches are now one map from scope to phase, and the count follows first insertion.
Step two ticked green while its helper still warned that open terminals and agents would restart, which had already happened.
Sonner deletes a toast after its action button runs unless the handler prevents the event, and it does so without calling onDismiss. Clicking Fix therefore took the notice off screen while the scope stayed latched as visible, so cancelling the dialog left no way back to it.
…ng it The five folder classes were hand-mirrored in preload behind a comment saying preload cannot depend on main-only modules. The enum lives in src/shared, which preload already imports from elsewhere, so the copy could drift.
A null verdict left the opened scope set, so the same scope coming back remounted a checklist nobody had opened. Clearing it on a null verdict also makes the dialog's scope key redundant, so it goes.
The footer swaps the reset for a restart as soon as a poll says the grant landed, which can happen while the reset is still running. Both buttons read their label off the dialog being busy at all, so the restart button appeared spinning as "Restarting…" for a restart nobody had started.
"Couldn't reset the permission" stayed on screen after the user granted it in System Settings and the probe read allowed, contradicting the ticked step above it. Its sibling line was already gated on the same verdict.
Two ways out were missing. A reset that cleared the evidence closed the dialog but left the toast on screen, because only the poll retired it; the store now retires the notice whenever a verdict comes back null, so both callers get it and the hook's own branch goes. And the opened scope survived a verdict for a different scope, so the original one returning later reopened the dialog with nobody having asked for it.
The app-side readability check moved from accessSync to opendir when the notice was added. TCC lets accessSync through but gates opendir, so on a machine that has never granted Orca the folder, spawning a terminal there raised the macOS sheet and froze main until the user answered it. The read is async now and the spawn no longer waits for it. The blocking variant keeps a name that says so, and the reset module's own copy of the read is gone.
Two paths reached "Still blocked after the reset." with no verdict behind it: an unanswered prompt, where the reset returns the verdict stored before it ran, and a re-probe that could not answer. The reset now returns the same access it reports to telemetry, and the line waits for a real denial.
…self The poll handler re-implemented the refresh's own two guards, a null entry and a settled allowed verdict, so each had to be kept in step by hand.
The daemon reads the requested cwd before forking a shell to report whether it can list it. That read is the one macOS gates, so on a folder the daemon is refused it could hold the daemon's event loop behind a prompt. It is awaited now, which leaves the blocking enumerator with no callers.
fb51d56 to
3b288f4
Compare

ELI5
On macOS, Orca's terminal service can lose access to Documents, Desktop, or Downloads while Orca itself still reads them. Terminals opened there fail with "Operation not permitted" and agents die. About 1,400 users hit it over three weeks and nothing told them. This PR notices it, tells the user once, and walks them through the fix in one dialog, with each step decided by evidence rather than guesswork.
What Changed
Before: terminals in a protected folder fail silently. The only remedy is a daemon restart buried in Manage Sessions, and nobody knows whether it will help.
After:
opendir+ one read) instead ofaccess(), which macOS lets through on protected folders even when listing fails. Main records a mismatch only when the daemon says denied and the app itself can read the same folder. Both reads are async and the app's is never awaited on the spawn path: on macOS the read is what raises the folder prompt, and a sync one would freeze the app for as long as the sheet is up.process.execPath,ELECTRON_RUN_AS_NODE) and has it list the folder. That child carries the attribution a restarted daemon would get, so its verdict answers "will a restart help" per user. Bounded at 3 s, argv only, scrubbed env, single JSON line; anything else reads as unknown.tccutil resetfor that folder class and Orca's bundle id, reads the folder itself (async, so the blocking macOS sheet cannot stall the event loop) so macOS prompts from the app, then forces a re-probe. Allowed turns step 1 green; still denied says so and surfaces Open System Settings as the fallback. Reset is offered only for Documents, Desktop, and Downloads, the folders macOS keeps a per-app permission row for; a denial anywhere else goes to Open System Settings. If the macOS sheet sits unanswered for 60 s the read is no longer awaited and the reset reports unknown to both the dialog and telemetry, so "still blocked" only ever shows on a measured denial.restartDaemon()directly. Success is shown by the checklist (both green, footer Done), not a sentence. Open terminals and agents come back through the existing cold-restore resume path.daemon_folder_access_noticewithaction∈ shown, fix_opened, dismissed, settings_opened, reset_clicked, restart_clicked, reset_outcome_{allowed,still_denied,unknown}, restart_outcome_{fixed,still_denied}, pluscwd_class. Outcomes are emitted from main, from the re-probe or the replacement daemon's first spawn, so they measure what happened rather than what was clicked.daemon_pty_cwd_deniedstays as the denominator.Mechanics worth knowing: evidence is keyed by daemon identity (pid, start time, launch nonce) plus folder class and held in one main-process entry, so one daemon denied a second folder is a new notice rather than a retitled one; a restart mints a new identity so the next poll returns null and the toast clears itself. The dialog is derived from that evidence: it renders the latest verdict for the scope the user opened, and any verdict for another scope or for no scope ends the open remedy, so no remedy state can outlive its evidence. A null verdict, whether from a poll or from the reset's re-probe, also retires the toast from inside the store, so no caller has to remember to. Sonner fires
onDismissfor programmatic dismissals too, so the hook clears its scope before any programmatic takedown and only a user's X counts as dismissed. Thetccutilreset and bundle-id read were extracted from the computer-use permissions code into one shared module rather than duplicated.Why
PostHog (21 days): 1,438 users emitted
daemon_pty_cwd_denied, 96% on Documents/Desktop/Downloads, 96% with a daemon from a different app version. Every one of them already had the folder enabled for Orca; that is the trigger condition. Of 255 later observed with a same-version daemon, 30 were denied again by that same-version daemon in the same folder class (another 45 were denied by yet another different-version daemon, i.e. the bug recurring after a further update, which a restart fixes). So "restart" is right for most and wrong for roughly one in eight, and no Settings action has ever been verified for that group. The design follows from that:tccutil reset+ re-allow) and the one lever we can measure. It ships gated behind the probe so the majority never see it, with its own outcome telemetry so a few weeks of data decide whether it stays. Nothing in the dialog claims a remedy that has not been observed to work.Linked Issue
Linear STA-7948. Related to #17696. Design: #21740.
Visual Proof
Before: nothing. Terminals in the folder fail with "Operation not permitted" and no UI mentions it.
After, toast:
Fix dialog when a fresh daemon is still denied (reset offered):
Fix dialog once a fresh daemon can read (restart offered):
Testing
macOS only by construction; every new path is behind
process.platform === 'darwin'or the macOS-only poll. Linux/Windows: the web fallback returns null/unsupported and nothing renders. SSH: remote hosts never reach this code (local daemon adapter only) and the restart copy says so.Manual, dev build with an uncommitted debug switch forcing the mismatch: toast, Fix, both dialog branches, reset, restart, Done, toast clearing on the new daemon identity; Fix → Cancel → refocus keeps exactly one toast, X → refocus keeps it gone.
Manual, ad hoc packaged build under a test bundle id launched via
open(so macOS holds it responsible for itself): Reset permission ran the realtccutil reset, macOS showed its Documents sheet, Allow wrote a fresh TCC row for the test bundle id, the re-probe passed, step 1 turned green, Restart completed.Not verifiable here: that the reset fixes an actually broken grant. No machine in the team has the state and it cannot be reproduced on demand. The outcome telemetry is the test.
Automated: 193 tests across 9 files for the probe, evidence store (record/clear/identity/scope per folder class/force re-probe race), reset flow (class gate, prompt deadline), IPC shapes, toast hook (once per scope, dismiss latch, a replaced toast's dismissal ignored, re-show after a null poll), dialog states (derivation from the latest verdict, close on moved or cleared evidence, no self-reopen when a scope returns, Fix leaves the toast up, per-button busy labels, reset error cleared by a later grant), and telemetry enum.
pnpm tc:node,pnpm tc:web,check:code-quality:changed, and the fourverify:localization-*scripts pass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: the probe child runs argv only with a scrubbed env and a 3 s deadline; the reset runs
tccutilwith a fixed service name from a closed map and the app's own bundle id, never user input. Telemetry carries a folder class and an action, never a path. Performance: nothing new on the PTY spawn path beyond oneopendir; the probe runs only from the focus-time poll, which awaits it (3 s deadline) and reuses a result younger than 5 s. Wire: thecwdReadableByDaemonfield keeps its name and type; daemons that omit it produce no evidence.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)