Skip to content

fix(desktop): credit smd-submitted Start at Login job on macOS (#7019) - #7033

Merged
lidge-jun merged 1 commit into
devfrom
fix/7019-login-item-status
Oct 13, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/7019-login-item-status

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

On macOS 13+, Background Task Management can take over the OpenCodex LaunchAgent and resubmit it through smd. launchctl print gui/<uid>/OpenCodex then reports path = (submitted by smd.<pid>), type = Submitted and managed_by = com.apple.xpc.ServiceManagement in place of the plist path. Startup Safety (src/service/desktop-startup.ts) and the tray's Start at Login item (desktop/src-tauri/src/login_registration.rs) both ran realpath on that path value. It failed, so a registered, enabled, current-copy login item was treated as unverified. The result was Restart safety: AT RISK ... desktop startup could not be verified in ocx status / ocx doctor, as reported in #7019.

Both judgments now accept that loaded shape only when all of these hold:

  • path is exactly (submitted by smd.<digits>)
  • managed_by is com.apple.xpc.ServiceManagement
  • the loaded program is this app copy (another copy still reads as other-copy)
  • the whole registration (plist shape, identities, print-disabled override) re-reads unchanged

The last condition is the same rule already applied when launchd reports the job as not found. Such a job is credited as loaded. Every other submitter, a missing or different managed_by, or a malformed pid stays unverified.

The submitted-job output shape was confirmed against real smd-managed jobs on macOS 27.0 (path = (submitted by smd.104), managed_by = com.apple.xpc.ServiceManagement).

2.84.1 hotfix candidate.

Fixes #7019

Verification

  • Eight new cases in the shared fixture tests/fixtures/desktop-login-registration-cases.json, run by both implementations. The [Bug][macOS] Startup Safety remains AT RISK on 2.84.0 with enabled current-app login item #7019 case fails on unpatched code on both sides: TS gives loginEnabled: false, Rust gives unknown. It passes after the fix.
  • bun test on the 6 desktop-startup service test files: 215 pass, 0 fail.
  • cargo test --lib login_registration (5 pass, fixture 66 cases), cargo fmt --check, cargo clippy --all-targets -- -D warnings: clean.
  • bun run typecheck, bun run structure:check: clean.
  • Live check on this Mac (job not loaded this session): macLoginFactsFor still reports registered-not-loaded, so the existing path is unchanged. I could not force an smd resubmission of the OpenCodex job locally, so the loaded-and-submitted path is covered by the fixture rather than live.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (structure/desktop-start-at-login.md)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes
    • Improved macOS login-at-startup detection for LaunchAgents resubmitted by Background Task Management. Startup is credited only when the registered app is confirmed and its registration remains unchanged; otherwise, the status is reported as unknown.
  • Documentation
    • Clarified how macOS 13 and later determines whether a resubmitted LaunchAgent qualifies as the app’s registered startup item.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 13, 2026 07:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T07:22:11.231297Z b821781 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1e912b02-e4b3-4f3f-a3ae-82d8bc7b7681
📥 Commits

Reviewing files that changed from the base of the PR and between 0291050 and 44e678e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 680808a2-18c0-4683-9d97-01bcd3067edb
📥 Commits

Reviewing files that changed from the base of the PR and between e6d7e56 and b821781.

📒 Files selected for processing (4)
  • desktop/src-tauri/src/login_registration.rs
  • src/service/desktop-startup.ts
  • structure/desktop-start-at-login.md
  • tests/fixtures/desktop-login-registration-cases.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

macOS login-item diagnosis now recognizes LaunchAgents resubmitted through Background Task Management. It accepts a job only when its submitted path and manager match the expected values, its program identifies the registered app, and a fresh registration check matches the initial evidence.

Changes: macOS login-item verification

Layer / File(s) Summary
Recognize and revalidate smd-submitted jobs
desktop/src-tauri/src/login_registration.rs, src/service/desktop-startup.ts, tests/fixtures/desktop-login-registration-cases.json, structure/desktop-start-at-login.md
The Rust classifier and desktop startup diagnosis recognize jobs with an smd.<digits> submitted path and the Service Management manager. They check that the program resolves to the registered app and re-read registration evidence before accepting the job. Fixtures cover missing or mismatched metadata, invalid submitter values, another app, and changed registration evidence. The documentation describes this behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b8217

The reported checks and fixtures cover the qualifying and rejected registration shapes. No actionable merge-blocking issue is established; the smd resubmission path was fixture-tested but not reproduced live.

Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: crediting macOS Start at Login jobs submitted by smd. It matches the affected desktop behavior and issue context.
Linked Issues check Passed #7019 requires Startup Safety to credit an enabled, current-copy macOS login registration or report it as unverified when evidence is inconclusive. src/service/desktop-startup.ts (`macLoginRegistrat…
Out of Scope Changes check Passed The reviewed changes are limited to the two #7019 judgment implementations, their shared parity fixture, and structure/desktop-start-at-login.md. The fixture and documentation support the registrati…
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. (2 skipped: 2 u…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 13, 2026
@lidge-jun
lidge-jun force-pushed the fix/7019-login-item-status branch 3 times, most recently from 32aaeaf to 0291050 Compare October 13, 2026 12:37
macOS Background Task Management resubmits the OpenCodex LaunchAgent through
smd, so launchctl print reports path = (submitted by smd.<pid>) with
managed_by = com.apple.xpc.ServiceManagement. Startup Safety and the tray
realpath'd that value, failed, and marked a valid login item unverified.
Credit that shape only for this copy's program and an unchanged registration
re-read, in both implementations, with shared fixture cases.
@lidge-jun
lidge-jun force-pushed the fix/7019-login-item-status branch from 0291050 to 44e678e Compare October 13, 2026 13:02
@lidge-jun
lidge-jun merged commit 31cd723 into dev Oct 13, 2026
83 of 86 checks passed
@lidge-jun
lidge-jun deleted the fix/7019-login-item-status branch October 13, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant