fix(desktop): trigger macOS Local Network permission on startup#3551
Conversation
requestLocalNetworkAccess was defined in local-network-permission.ts but never called, so the Info.plist keys (NSLocalNetworkUsageDescription, NSBonjourServices) wired up in electron-builder never had a trigger to prompt the user. On macOS 15+ this causes outbound connections to local-network IPs from the app and its spawned child processes (node, python in the terminal) to be silently blocked, while system binaries like curl escape the same TCC attribution. Call it alongside requestAppleEventsAccess in app ready. Refs #3474
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded a local network access permission request to the macOS app initialization sequence. During startup, after ready and Apple Events access, the app now requests local network permissions to enable spawned processes to communicate with local network resources. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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. Comment |
Greptile SummaryThis PR fixes a macOS local network permission issue in the Electron desktop app by calling the already-implemented Changes:
Confidence Score: 5/5Safe to merge — minimal, targeted fix with no risk of regression on non-macOS platforms and correct socket lifecycle management. Single call-site addition. The helper was already correct and tested in isolation; the only missing piece was invoking it. Platform guard, error handling, and socket cleanup were all in place. No logic changes, no new dependencies, no state mutation. No files require special attention. End-to-end verification requires a signed/packaged canary build on macOS 15+ as noted in the test plan, which is outside the scope of code review.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/index.ts | Adds requestLocalNetworkAccess() call in the app.whenReady() block; import was already present. Change is minimal and correctly placed before main window creation. |
| apps/desktop/src/main/lib/local-network-permission.ts | Pre-existing helper; unchanged in this PR. Uses standard mDNS multicast send to trigger TCC permission dialog; platform-gated to darwin; socket lifecycle correctly cleaned up in all paths. |
Sequence Diagram
sequenceDiagram
participant E as Electron main
participant AE as requestAppleEventsAccess()
participant LN as requestLocalNetworkAccess()
participant OS as macOS TCC
participant UI as Main Window
E->>E: app.whenReady()
E->>AE: call (existing)
AE-->>OS: AppleEvents permission check
E->>LN: call (NEW - this PR)
LN->>LN: dgram.createSocket(udp4)
LN->>LN: socket.bind()
LN->>OS: send 1-byte packet to 224.0.0.251:5353
OS-->>E: Show "Local Network" permission dialog
LN->>LN: socket.close()
E->>UI: makeAppSetup() → MainWindow()
Reviews (1): Last reviewed commit: "fix(desktop): trigger macOS Local Networ..." | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
requestLocalNetworkAccessexisted inapps/desktop/src/main/lib/local-network-permission.tsbut was never called, so theNSLocalNetworkUsageDescription/NSBonjourServiceskeys wired up inelectron-builder.tsnever had a trigger.curlescape the same TCC attribution path, which matches the reporter's symptom.requestAppleEventsAccessin theapp.whenReadyblock.Fixes #3474.
Test plan
Dev can exercise the code path but not the production grant (bundle id, signing identity, and Info.plist keys all differ). For end-to-end verification:
node -e 'require(\"http\").get(\"http://<local-ip>\", r=>console.log(r.statusCode))') — expect success.If granting permission doesn't resolve the repro, the next investigation areas are PTY subprocess TCC attribution and the
agent-setup/shell-wrapperspath.Summary by cubic
Trigger the macOS Local Network permission on app startup to stop silent blocking of LAN connections on macOS 15+ for the app and its terminal child processes. Adds a call to
requestLocalNetworkAccess()alongsiderequestAppleEventsAccess()inapp.whenReady(fixes #3474).Written for commit 9c2f4f0. Summary will update on new commits.
Summary by CodeRabbit