Skip to content

fix(macos): verify Full Disk Access and re-arm notices - #11716

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-notification-permission-badge
Jul 31, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-notification-permission-badge

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

  • Verify effective Full Disk Access by opening the per-user TCC database read-only instead of checking whether a Safari path exists.
  • Report Granted only after a successful open, Denied for permission errors, and Unknown for missing or unexpected probe failures.
  • Version the one-shot TCC notice state so users who may have trusted the former false-positive badge are eligible again only after a fresh macOS prompt; preserve explicit permanent opt-outs.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Validated with:

  • pnpm vitest run --config config/vitest.config.ts src/main/macos-full-disk-access-status.test.ts src/main/ipc/developer-permissions.test.ts src/main/macos-tcc-prompt-notice.test.ts src/main/macos-tcc-prompt-watch.test.ts src/renderer/src/hooks/useMacosTccPromptNotice.test.tsx src/renderer/src/hooks/macos-tcc-prompt-notice-subscription.test.ts (56 tests)
  • pnpm run typecheck:node
  • pnpm run check:code-quality:changed
  • pnpm run check:max-lines-ratchet
  • git diff --check
  • Live macOS probe with Full Disk Access disabled returned Denied and emitted no AUTHREQ_PROMPTING log event.

AI Review Report

Reviewed the permission signal, persisted notice migration, renderer claim lifecycle, and helper-attributed TCC behavior. The former probe used fs.access() with its default existence-only mode; the replacement opens the protected database read-only and conservatively preserves Unknown for ambiguous failures. Migration coverage verifies that legacy acknowledged notices require a fresh TCC event, current acknowledgements remain silent, and legacy permanent opt-outs remain permanent.

Cross-platform behavior was checked explicitly: the probe is runtime-gated to macOS, returns Unsupported elsewhere, builds the home path with path.join, and changes no shortcuts, labels, shell commands, Git behavior, SSH routing, or workspace assumptions. The existing helper-attributed prompt watcher remains authoritative because the detached helper has an independent TCC identity.

Security Audit

The probe opens only the known per-user TCC database path in read-only mode and closes it immediately; it never reads or exposes database contents. It accepts no renderer-controlled path, adds no command execution or dependency, and keeps the existing typed IPC status contract. Permission errors are reduced to status enums without leaking filesystem details.

Notes

macOS does not expose a public Full Disk Access status API. This change uses effective read access as the practical signal while keeping actual TCC prompt observation as the stronger reason to show guidance.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR replaces the former Full Disk Access probe (checking read access on the Safari Bookmarks plist) with a more reliable and conservative probe that attempts to open the per-user TCC database (~/Library/Application Support/com.apple.TCC/TCC.db) in read-only mode, returning Granted, Denied, or Unknown based on the outcome. It also versions the one-shot TCC prompt notice state (noticeVersion: 2) so users who may have received a false-positive Granted badge under the old probe are re-armed to see guidance after a fresh macOS TCC event, while explicitly-dismissed ("never show again") opt-outs are unconditionally preserved.

  • New macos-full-disk-access-status.ts: extracts the probe into its own injectable module, uses fs/promises.open (async, non-blocking), and maps EACCES/EPERM to denied while treating other errors conservatively as unknown.
  • macos-tcc-prompt-notice.ts migration: adds a noticeVersion field to the persisted tally; on load, any tally without the current version 2 resets to empty (re-arms the watcher), except dismissed: true tallies which are always honoured as permanent opt-outs.
  • Test coverage: 56 tests exercised, including per-error-code probe behaviour, the migration paths, and IPC handler integration.

Confidence Score: 5/5

Safe to merge — the probe correctly uses async I/O, the migration logic handles all tally shapes including the dismissed edge case, and the version bump is a well-contained, tested change.

The new TCC database probe is straightforward: async open, error-code classification, and a conservative unknown fallback. The notice versioning migration is clean: dismissed is checked before the version gate, so permanent opt-outs are unconditionally honoured. All meaningful paths are covered by 56 tests. The only gap is a theoretical file-descriptor leak in openForRead if handle.close() fails, which is a best-practice suggestion rather than a current defect.

Files Needing Attention: No files require special attention. macos-full-disk-access-status.ts has one minor resource-cleanup pattern worth reviewing, but it does not affect correctness under normal conditions.

Important Files Changed

Filename Overview
src/main/macos-full-disk-access-status.ts New module implementing the TCC database read probe; async I/O, clean error classification, injectable readProbe for testability. Minor: openForRead lacks try/finally around handle.close(), a theoretical FD leak on rare close failure.
src/main/macos-tcc-prompt-notice.ts Adds noticeVersion: 2 versioning to the persisted tally; loadTally() correctly prioritises dismissed: true before version checks, re-arms all non-dismissed legacy tallies, and normalises malformed states to EMPTY_TALLY.
src/main/ipc/developer-permissions.ts Delegates the full-disk-access case to getMacosFullDiskAccessStatus(); removes the old inline Safari-bookmarks probe and its node:os/path/fs imports. Clean refactor.
src/main/macos-full-disk-access-status.test.ts New test file; covers granted, EACCES/EPERM→denied, ENOENT/ENOTDIR/EBUSY→unknown, and unsupported-platform path.
src/main/macos-tcc-prompt-notice.test.ts Updated tests verify re-arming of both legacy tally shapes, permanent opt-out preservation, and both replay paths for versioned tallies.
src/main/ipc/developer-permissions.test.ts Adds mock for getMacosFullDiskAccessStatus and a new integration test asserting the IPC handler surfaces the probe result correctly.

Reviews (2): Last reviewed commit: "perf(macos): keep full disk probe off ma..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds macOS Full Disk Access detection through a TCC database probe. It maps successful reads, permission errors, other failures, and non-macOS platforms to distinct statuses. Developer permission IPC now uses this helper. TCC prompt notice tallies now persist a version and normalize acknowledgment state. Tests cover detection outcomes, IPC delegation, legacy tally handling, dismissal preservation, and versioned replay fixtures.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary, screenshots, testing, and notes sections; however, it lacks the AI Review Report and Security Audit sections required by the template. Add dedicated AI Review Report and Security Audit sections. These sections are present in the PR description but should follow the template format more closely with explicit section headings and structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: verifying Full Disk Access and re-arming TCC notices, which aligns with the primary objectives of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/macos-full-disk-access-status.ts (1)

8-11: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Edge case: close() failure after successful open() is misclassified.

In openForRead, if open() succeeds but handle.close() throws, the thrown error propagates into the catch block in probeMacosFullDiskAccess at Line 36. The function then reports denied or unknown even though the read access itself succeeded. This is unlikely in practice, but it conflates a close failure with a permission failure.

Consider closing the handle in a finally block so a close error does not affect the granted-status determination, or ignore close errors explicitly.

Proposed fix
 async function openForRead(filePath: string): Promise<void> {
   const handle = await open(filePath, 'r')
-  await handle.close()
+  try {
+    // Read succeeded once open() resolves; a close failure should not affect the result.
+  } finally {
+    await handle.close().catch(() => {})
+  }
 }

Also applies to: 33-39


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 93cd8899-7251-41c8-85ed-e6ed526e9461

📥 Commits

Reviewing files that changed from the base of the PR and between 12c9e74 and 12e0d37.

📒 Files selected for processing (4)
  • src/main/ipc/developer-permissions.test.ts
  • src/main/ipc/developer-permissions.ts
  • src/main/macos-full-disk-access-status.test.ts
  • src/main/macos-full-disk-access-status.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/ipc/developer-permissions.test.ts
  • src/main/macos-full-disk-access-status.test.ts

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron validation (commit 12e0d371ef)

  • Launched the isolated Orca dev build from the PR worktree and verified app identity: sponge @ brennanb2025/fix-notification-permission-badge.
  • Exercised the real Settings → macOS Permissions surface and clicked Refresh.
  • Visible result: Full Disk Access remained Denied after refresh.
  • Backing IPC result: {"id":"full-disk-access","status":"denied"}.
  • Refresh completed in approximately 200 ms with no renderer console errors.
  • Automated coverage: 56 focused tests and Node typecheck passed on the latest commit.

Full macOS Permissions settings surface showing Full Disk Access denied

The versioned one-shot notice migration was covered by focused tests; a fresh OS-level TCC prompt was not forced during this run.

@brennanb2025
brennanb2025 merged commit 48e5254 into main Jul 31, 2026
42 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up: exact reported toast path

Reproduced the user action on commit 12e0d371ef with Full Disk Access disabled:

  • Before the click, the Full Disk Access row and backing IPC status were both denied.
  • Clicked the row-specific Open Settings button through the real Settings surface.
  • Orca opened the macOS Privacy & Security pane and showed Opened macOS Privacy & Security.
  • The incorrect Permission granted toast did not appear.

This confirms the screenshot in the report was another visible symptom of the same false-positive probe, and this PR fixes it.

Full macOS Permissions surface showing Denied and the Opened macOS Privacy and Security toast

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(macos): verify full disk access status

* perf(macos): keep full disk probe off main thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant