fix(desktop): stop looping macOS TCC permission prompts #2745
main fromrefs/pull/2745/head·merged by juliusmarminge View on GitHubSummary#
Fixes pingdotgg/t3code#2254 Fixes pingdotgg/t3code#2737 Fixes pingdotgg/t3code#2088
Three issues with the same shape: macOS TCC permission prompts ("Other apps", "Music", "Documents", "Downloads", etc.) re-fire repeatedly because three different code paths trigger fresh file access on every render or panel mount, with no caching or enable-gate.
Repro / root causes:
- Tailscale, "Other apps" category (issues 2254, 2737).
DesktopServerExposure.getAdvertisedEndpointsunconditionally spawnedtailscale statuswhenever the Connections settings panel mounted, even when the user had not opted into any network exposure. On Mac App Store Tailscale the CLI lives inside Tailscale's sandbox container, so each spawn re-fires the "T3 Code would like to access data from other apps" TCC prompt. Issue 2737's reproduction (enable Network Access → prompt loops every few seconds) maps directly to the Settings panel re-firing this effect. - Path-autocomplete, Music / Documents / Downloads / Desktop categories (issues 2254, 2088).
CommandPaletteprefetched the highlighted browse child on every render (useEffectkeyed onhighlightedBrowseEntry). Each prefetch sentpartialPath: "~/Music/"(with trailing separator fromappendBrowsePathSegment) toWorkspaceEntries.browse, whichreaddir'd the gated dir server-side. Arrow-keying pastMusic,Documents,Downloads,Desktop,Movies,Picturesin the home folder fired one TCC prompt per highlight change. - Denied TCC prompt re-fires.
WorkspaceEntries.browsesurfacedEACCES/EPERMfromreaddiras aWorkspaceEntriesBrowseError, which the renderer's React Query then re-attempted on retry — re-firing the prompt.
Changes#
apps/desktop/src/backend/DesktopServerExposure.ts— early-return fromgetAdvertisedEndpointswith only the core endpoints whenmode !== "network-accessible"andtailscaleServeEnabled === false. WrapreadTailscaleStatusinEffect.cachedWithTTL(60s) so even when the gate passes, panel remounts don't re-spawn the CLI.apps/desktop/src/backend/tailscaleEndpointProvider.ts— accept an optionalreadMagicDnsNameEffect so the caller can inject the cached reader. Default path is unchanged.apps/web/src/components/CommandPalette.tsx— drop the highlighted-child prefetch; keep the parent prefetch for back-navigation. The user pays onereaddirwhen they actually navigate into a directory instead of one per arrow-key press.apps/server/src/workspace/Layers/WorkspaceEntries.ts— catchEACCES/EPERMfromreaddirinbrowseand return an empty listing so a denied prompt stops re-firing on retry.
Tests#
DesktopServerExposure.test.ts: new test using a "die on spawn"ChildProcessSpawnerlayer asserts thatgetAdvertisedEndpointsdoes not invoke the spawner while the server is inlocal-onlymode with Tailscale Serve off.tailscaleEndpointProvider.test.ts: new test verifies thereadMagicDnsNameinjection bypassesreadTailscaleStatusand produces the magic-DNS endpoint as expected.WorkspaceEntries.test.ts: new test mocksfsPromises.readdirto reject withEACCESand assertsbrowsereturns{ parentPath, entries: [] }instead of erroring.
Test plan#
-
bun typecheckclean -
bun lintclean (no new warnings) -
bun fmtclean -
bun run test— 1023 passed, 4 skipped (matches main), including the three new tests - On macOS with Mac App Store Tailscale installed: open Settings → Connections without enabling Network Access, confirm no "Other apps" prompt appears
- With Network Access enabled, confirm the prompt fires at most once per 60s instead of on every panel mount
- In the command palette browse mode, arrow-key past
Music/Documents/Downloadsand confirm no TCC prompts fire until you press/to navigate into one
Note: I do not have a Mac App Store Tailscale install to verify the macOS prompt behavior end-to-end; the fix targets the code paths identified in the issues and is covered by unit tests for the gating, caching, and EACCES handling.
Note
Stop looping macOS TCC permission prompts by skipping tailscale CLI spawns in local-only mode#
- In DesktopServerExposure.ts, adds an early return in
getAdvertisedEndpointsthat skips all tailscale CLI invocations when the server is not in network-accessible mode and Tailscale Serve is disabled. - Tailscale status lookups are now cached for 60 seconds via
Effect.cachedWithTTLto reduce spawn frequency when tailscale resolution is needed. resolveTailscaleAdvertisedEndpointsin tailscaleEndpointProvider.ts now accepts an optional injectedreadMagicDnsNameeffect, allowing callers to share the cached reader.- In WorkspaceEntries.ts,
browsenow catchesEACCES/EPERMerrors and returns an empty listing instead of propagating a browse error, preventing repeated TCC permission dialogs on macOS. - Child directory prefetching in CommandPalette.tsx is removed; only the parent directory is prefetched during browse navigation.
Note
Medium Risk Changes advertised-endpoint and filesystem browse behavior on macOS (empty listings on deny, deferred directory reads); logic is guarded by exposure settings and covered by new tests, but UX when access is denied differs from surfacing errors.
Overview Stops repeated macOS TCC permission prompts by gating and caching sensitive file/process access instead of hitting them on every UI refresh.
Desktop server exposure — getAdvertisedEndpoints now returns only core endpoints when exposure is local-only and Tailscale Serve is off, so the Tailscale CLI is not spawned (avoiding repeated “Other apps” prompts). When Tailscale resolution runs, MagicDNS reads go through a 60s TTL cache via injectable readMagicDnsName.
Command palette browse — Removes prefetch of the highlighted child directory on arrow-key navigation; only the parent path is prefetched for back navigation, so gated home folders are not readdir'd until the user actually navigates in.
Workspace browse API — browse treats EACCES/EPERM from readdir as an empty listing instead of an error, so React Query retries do not re-trigger denied TCC prompts.
Tests cover local-only Tailscale spawn gating, injected MagicDNS reader, and EACCES browse behavior.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 180835f2562447aaf9d9ce6d261d1f593a5f1893. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Needs human review
This bug fix modifies runtime behavior around Tailscale CLI spawning and error handling. An unresolved review comment identifies a potential regression where Tailscale IP endpoints may be dropped for users with Tailnet interfaces in local-only mode.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 180835f2562447aaf9d9ce6d261d1f593a5f1893. Configure [here](https://www.cursor.com/dashboard/bugbot).
@@ -516,3 +532,10 @@516532 exposure: toResolvedExposure(state),517533 customHttpsEndpointUrls: config.desktopHttpsEndpointUrls,518534 });535+536+ // Don't spawn the Tailscale CLI when the user hasn't opted into any537+ // network exposure. The spawn itself triggers a macOS "Other apps"538+ // TCC prompt on Mac App Store Tailscale builds.539+ if (state.mode !== "network-accessible" && !state.tailscaleServeEnabled) {540+ return coreEndpoints;541+ }Gate drops Tailscale IP endpoints#
Medium Severity
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 180835f2562447aaf9d9ce6d261d1f593a5f1893. Configure [here](https://www.cursor.com/dashboard/bugbot).getAdvertisedEndpointsreturns only core endpoints when effective mode islocal-onlyand Tailscale Serve is off, skipping all ofresolveTailscaleAdvertisedEndpoints. That path still adds Tailscale IP URLs fromnetworkInterfaceswithout spawning the CLI, so users with a Tailnet interface (ornetwork-accessiblepreference but LAN-unavailable fallback) no longer see those endpoints in Connections.juliusmarminge approved these changes
Thank you!
juliusmarminge merged thisb76f161
juliusmarminge closed this
Sign in to join this conversation.

Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
418443b5-bd8d-4050-af7d-a54e1668f472You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
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