fix: keep Launch at Login off until approval is granted #1173
<!-- clawsweeper-pr-ack:opened item=1173 -->
🦞👀
ClawSweeper picked this up.
Pull request received. I will update this pull request when review starts.
<!-- clawsweeper-review-progress:start -->
ClawSweeper review complete
ClawSweeper finished reviewing this revision. The review result is being finalized.
View the workflow run.
<!-- clawsweeper-review-progress:end -->
PR Summary
<!-- CURSOR_SUMMARY -->
Medium Risk
Touches launch-at-login registration and persistent preferences against Service Management; wrong status handling could leave the toggle out of sync with macOS, but scope stays in settings UI—not auth or sensitive data.
Overview
Launch at Login now tracks Service Management status instead of blindly registering.
PeekabooSettings.launchAtLogin consults LaunchAtLoginRegistration.action: only calls register() when appropriate, opens System Settings Login Items when approval is pending (without duplicating register()), unregisters when turning off unless already unregistered, and reverts the persisted toggle when registration does not reach .enabled. New helpers refreshLaunchAtLoginFromService, applyLaunchAtLoginServiceStatus, and setLaunchAtLogin keep the toggle in sync without recursive saves.
General settings keeps the switch updated while the user approves in System Settings. GeneralSettingsView refreshes on appear, when the scene becomes active, when the app becomes active, and via a background poll (watchLoginItemsApproval) while LaunchAtLoginApprovalWatch says approval may still be pending.
Unit tests cover the registration action matrix and approval-watch behavior; CHANGELOG notes the user-facing fix.
<sup>Reviewed by Cursor Bugbot for commit ea81282395fe8d4f9440eb9da4f8f385d35b85e9. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
<!-- /CURSOR_SUMMARY -->
Retry enable reverts registered login item
Medium Severity
<!-- DESCRIPTION START -->
After register() returns .requiresApproval, launchAtLogin is forced off while the login item stays registered. Turning the switch on again calls register() on that already registered service, which fails with kSMErrorAlreadyRegistered or kSMErrorLaunchDeniedByUser. The catch path then snaps the toggle back off and does not open Login Items, so the same-session enable flow cannot complete.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: ccd650bd-6af3-4cfc-b120-d8f7c91f153d -->
<!-- LOCATIONS START
Apps/Mac/Peekaboo/Core/Settings.swift#L172-L184
Apps/Mac/Peekaboo/Core/Settings.swift#L187-L193
LOCATIONS END -->
<details>
<summary>Additional Locations (1)</summary>
Apps/Mac/Peekaboo/Core/Settings.swift#L187-L193</details>
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjgzNGZhNjhkLTAxMDEtNGQ5OC1hYTdmLTRjYmYzZjEyMzI3NyIsImVuY3J5cHRpb25LZXkiOiJoeGxzOG0yMDJCNDVGaDRpSGpwNkVrcGd6NUFib0RONm9faDB3NHhxR1pzIiwiYnJhbmNoIjoiZml4L2xhdW5jaC1hdC1sb2dpbi1hcHByb3ZhbCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjgzNGZhNjhkLTAxMDEtNGQ5OC1hYTdmLTRjYmYzZjEyMzI3NyIsImVuY3J5cHRpb25LZXkiOiJoeGxzOG0yMDJCNDVGaDRpSGpwNkVrcGd6NUFib0RONm9faDB3NHhxR1pzIiwiYnJhbmNoIjoiZml4L2xhdW5jaC1hdC1sb2dpbi1hcHByb3ZhbCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByTnVtYmVyIjoxMTczLCJjb21taXRTaGEiOiIxM2I5Y2I2MzJiNDA0NGNjMTg5N2EzODAzNDgzNzY0MjI1MGVkMTNmIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit 13b9cb632b4044cc1897a38034837642250ed13f. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
<!-- BUGBOT_REVIEW_STALE -->
Stale Bugbot comment from a previous run.
Codex review: needs real behavior proof before merge.
What this changes
The PR makes Launch at Login reflect macOS approval status and refreshes the switch when Settings becomes active.
Example: Peekaboo's login registration has status requiresApproval.
Review scores
| Measure | Result | What it means |
|---|---|---|
| Overall readiness | 🧂 unranked krab (1/6) | The focused implementation addresses the earlier findings, but helper-only output does not satisfy the required real-app proof. |
| Proof confidence | 🧂 unranked krab (1/6) | Real behavior proof is necessary before merge. See [Before merge](#before-merge). |
| Patch quality | 🐚 platinum hermit (4/6) | No actionable review findings were identified. |
Product
Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The switch can imply startup is enabled while approval is pending and can fail to guide the user back to Login Items.
Reason: The repair makes the existing control match the same Service Management state already used when settings load.
Merge readiness
⛔ Blocked before merge - 1 item remains
This PR addresses a current-main settings bug and resolves both earlier source findings; no new concrete correctness defect was found.
Priority: P2
Reviewed head: cc4325f22f6432dd36eb5073b2bed335d1f7dff5
Before merge
@clawsweeper re-review. The PR author or someone with repository write access can request it.Findings
None.
Tests
Apps/Mac/PeekabooTests/Services/SettingsServiceTests.swift: The added test asserts helper mappings without exercising the settings setter, registration effects, or activation refresh; replace it with coverage through the production settings owner.<details>
<summary><strong>Agent review details</strong></summary>
How this fits together
The Mac app's General settings sends switch changes to PeekabooSettings, which calls Service Management and persists the displayed state in UserDefaults.
flowchart LR
A[General settings switch] --> B[PeekabooSettings]
B --> C[Status action mapping]
C --> D[macOS Service Management]
D --> E[Login Items approval]
E --> F[Settings activation refresh]
F --> B
B --> G[UserDefaults]
Technical review
Best possible solution:
Keep Service Management authoritative and validate the complete approval flow through the Mac app before merging.
Do we have a high-confidence way to reproduce the issue?
Current-main source shows unconditional registration and no post-registration approval check; no app reproduction was run during this read-only review.
Is this the best way to solve the issue?
The change repairs the existing settings owner and preserves the established enabled-status contract without adding a preference or alternate registration path.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning medium; reviewed against 85368531db7d.
Provenance checked
Launch at Login setter and loading guard keeps the original intent (026add4b8fcee3c00b8fdc7f51ef1d9384cc4fd3: Prevent recursive saves and startup crashes while loading or reverting the setting.)General settings lifecycle keeps the original intent (https://github.com/openclaw/Peekaboo/pull/261: Restructure Settings while retaining persisted preference keys and existing controls.)Testing
Proof path: unit tests only.
Security
None.
Evidence
What I checked:
Apps/Mac/Peekaboo/Core/Settings.swift:163, 85368531db7d)Apps/Mac/Peekaboo/Core/Settings.swift:201, cc4325f22f64)Apps/Mac/Peekaboo/Core/Settings.swift:492, cc4325f22f64)Apps/Mac/Peekaboo/Core/Settings.swift:195, 026add4b8fce)AGENTS.md:1, cc4325f22f64)Preflight source
Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.
Labels
Label changes:
No label changes.
Label justifications:
P2: The bug affects an optional startup preference and its approval handoff, with limited impact on the rest of the app.rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.Rank-up moves
Optional improvements that raise the rating; they are not merge blockers.
Rating scale
6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.
Workflow
ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.
History
<details>
<summary>Review history (1 earlier review cycle)</summary>
<!-- clawsweeper-review-history v=1 total=1 -->
</details>
</details>
_Reviewed November 6, 2026, 5:49 PM ET / 22:49 UTC (Revision 2)._
<!-- clawsweeper-verdict:needs-human item=1173 sha=cc4325f22f6432dd36eb5073b2bed335d1f7dff5 confidence=high updated_at=2026-11-06T22:48:01Z reviewed_at=2026-11-06T22:49:37.418Z lease_owner=github-run-42307283552-1 lease_comment_id=6697714143 source_revision=dc875861edf43665a8576261523b602be1dae8bb02cd9753ab8b1203030b6e39 hold=proof findings=0 -->
<!-- clawsweeper-review-state:blocked item=1173 sha=cc4325f22f6432dd36eb5073b2bed335d1f7dff5 v=1 -->
<!-- clawsweeper-review-version item=1173 reviewed_at=2026-11-06T22:49:37.418Z sha=cc4325f22f6432dd36eb5073b2bed335d1f7dff5 source_revision=dc875861edf43665a8576261523b602be1dae8bb02cd9753ab8b1203030b6e39 lease_owner=github-run-42307283552-1 lease_comment_id=6697714143 v=1 -->
<!-- clawsweeper-review item=1173 -->
@clawsweeper re-review
A status that already requires approval opens Login Items without calling register again, and Settings rereads the service status when the window becomes active.
<!-- clawsweeper-command-ack:6697712253 -->
<!-- clawsweeper-command-status:1173:re_review:command-6697712253-mw5kdueo-ff24232217550e6d18252d09878e7b3fa41df5e4e894e39afef134954b49c6e5 -->
🦞👀
Exact review queued.
<!-- clawsweeper-command-progress:start -->
Re-review progress:
<!-- clawsweeper-command-progress:end -->
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpiODM1YjU3Ni0wYmYzLTRjMTMtYjhjMy04N2ZlZWE1OTdiOTYiLCJlbmNyeXB0aW9uS2V5IjoiYzZxbkxleWl3NjJsYkpKZ09meG56TFRjMURqcXpjT1ZaV2NTMmRoLWVuMCIsImJyYW5jaCI6ImZpeC9sYXVuY2gtYXQtbG9naW4tYXBwcm92YWwiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by Cursor Bugbot for commit cc4325f22f6432dd36eb5073b2bed335d1f7dff5. Configure here.</sup>
Switch stays off after login approval
Medium Severity
<!-- DESCRIPTION START -->
On macOS, scenePhase typically stays .active when switching to System Settings and back, so onChange never calls refreshLaunchAtLoginFromService while General settings remains open. After Login Items approval the switch stays off until the view appears again, which is the original stale-switch failure.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: c08a9513-8bad-4ccf-9b8e-b5ac938094c8 -->
<!-- LOCATIONS START
Apps/Mac/Peekaboo/Features/Settings/SettingsWindow.swift#L171-L176
Apps/Mac/Peekaboo/Features/Settings/SettingsWindow.swift#L101-L102
LOCATIONS END -->
<details>
<summary>Additional Locations (1)</summary>
Apps/Mac/Peekaboo/Features/Settings/SettingsWindow.swift#L101-L102</details>
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjRiYjYwNDYwLWVjYjAtNDYxMS1iMGRjLWEwMmVjMmM5MjU5MSIsImVuY3J5cHRpb25LZXkiOiJtX3dQMmM2SFVMTlFDNExNZUhSTEpsUVZjTjBiOGsxbGwxOFJTS25WYnUwIiwiYnJhbmNoIjoiZml4L2xhdW5jaC1hdC1sb2dpbi1hcHByb3ZhbCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjRiYjYwNDYwLWVjYjAtNDYxMS1iMGRjLWEwMmVjMmM5MjU5MSIsImVuY3J5cHRpb25LZXkiOiJtX3dQMmM2SFVMTlFDNExNZUhSTEpsUVZjTjBiOGsxbGwxOFJTS25WYnUwIiwiYnJhbmNoIjoiZml4L2xhdW5jaC1hdC1sb2dpbi1hcHByb3ZhbCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByTnVtYmVyIjoxMTczLCJjb21taXRTaGEiOiJjYzQzMjVmMjJmNjQzMmRkMzZlYjUwNzNiMmJlZDMzNWQxZjdkZmY1IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit cc4325f22f6432dd36eb5073b2bed335d1f7dff5. Configure here.</sup>
@cursor
On macOS,scenePhasetypically stays.activewhen switching to System Settings and back, soonChangenever callsrefreshLaunchAtLoginFromServicewhile General settings remains open.
Yes. While approval is pending, General rereads Service Management, and it rereads again when the app becomes active. An enabled status turns the switch on without another register(). The Login Items approval test covers that on ea8128239. The Login Items pane was not opened.
Thanks! This fix landed as part of #1171, which merged with your credit. Closing this one as folded in.
SebTardif
What Problem This Solves
Turning on Launch at Login called
register()and left the switch on even when macOS still required approval. Turning it on again then calledregister()on a service that was already pending, so the Login Items handoff could fail. After the user approved Peekaboo, the switch stayed off until settings were loaded again.Evidence
The switch now reads the current Service Management status before it registers.
.notRegisteredregisters..requiresApprovalopens Login Items and does not callregister()again..enabledleaves the registration alone. Turning the switch off unregisters an enabled or pending service. When General settings appears or becomes active, the switch is set from the current status, so an approval turns it on.Real behavior proof
LaunchAtLoginRegistration.actionandGeneralSettingsViewatcc4325f22f6432dd36eb5073b2bed335d1f7dff5. The menu bar switch was not toggled. System Settings was not opened.actionfor turning the switch on and off against.notRegistered,.requiresApproval, and.enabled.register(). An enabled service is not registered again. Turning the switch off unregisters it.