Skip to content

fix: preserve OpenClaw profile env in macOS launch-at-login plist - #99752

Merged
steipete merged 3 commits into
openclaw:mainfrom
arkyu2077:fix/issue-98594
Jul 28, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
arkyu2077:fix/issue-98594

Conversation

@arkyu2077

@arkyu2077 arkyu2077 commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #98594.

What Problem This Solves

The macOS app reads OPENCLAW_CONFIG_PATH and OPENCLAW_STATE_DIR to select its active profile, but its launch-at-login plist preserved only PATH. After login, the relaunched app could therefore fall back to the default config and state directory.

Why This Change Was Made

  • Preserve the two existing non-empty profile path overrides alongside PATH.
  • Reuse OpenClawEnv.path so foreground and login-launched processes share whitespace and empty-value normalization.
  • Keep the existing plist renderer and lifecycle behavior instead of replacing the whole output path.
  • XML-escape PATH and profile values, and test raw key uniqueness, special-character round trips, and blank omission under the shared Swift env lock.

Apple's current launchd.plist(5) contract defines EnvironmentVariables as a dictionary of string values. The real-behavior proof below uses the documented launchctl bootstrap/bootout path.

User Impact

Enabling Launch at login from an app process started with explicit config/state paths now preserves that same profile on the next login. Users without those overrides keep the existing PATH-only behavior.

Evidence

Exact head: 085fe7532ed3c6c75d879fa55f2148e34304ad23

  • Xcode 27 / Swift 6.4 isolated LaunchAgent suite: 3/3 passed.
  • Synthetic current-main merge: LaunchAgent and Gateway LaunchAgent suites, 11/11 passed.
  • After hosted parallel CI exposed process-wide PATH test pollution, the test now injects preferred paths directly. The four previously failing parallel suites plus both LaunchAgent suites pass together, 147/147.
  • plutil -lint: generated populated and blank plists passed.
  • Parsed populated plist preserved normalized PATH, OPENCLAW_CONFIG_PATH, and OPENCLAW_STATE_DIR; every raw key appeared exactly once. Blank/unset profile values produced only PATH.
  • Real per-user launchd proof: a temporary redacted LaunchAgent bootstrapped successfully, remained running, and its spawned process received the exact normalized special-character PATH, config path, and state directory. The temporary service was booted out after inspection.
  • SwiftFormat and git diff --check passed. Codex autoreview accepted and fixed one PATH-escaping regression, then confirmed both the final bundle at 0.96 confidence and the test-isolation repair at 0.98 confidence.

The contributor branch's old standalone dependency graph no longer builds under this machine's current Swift actor checks. Proof therefore runs against the synthetic merge users would actually receive, which carries current main dependency pins; exact-head hosted macOS CI remains the landing authority.

@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 4, 2026
@clawsweeper

clawsweeper Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 11:14 AM ET / 15:14 UTC.

ClawSweeper review

What this changes

The PR adds non-empty OPENCLAW_CONFIG_PATH and OPENCLAW_STATE_DIR to the macOS launch-at-login plist, XML-escapes emitted environment values, and tests populated and blank profile environments.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open: current main still writes only PATH into the macOS LaunchAgent environment, while this branch supplies the narrow profile-continuity fix. The branch is mergeable and carries sufficient real-behavior proof, but it is behind main and its exact-head macos-swift check is still running, so it needs ordinary maintainer review rather than cleanup closure.

Priority: P2
Reviewed head: 085fe7532ed3c6c75d879fa55f2148e34304ad23

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-tested macOS fix with credible live launchd proof; final readiness depends on the active exact-head macOS Swift gate and normal maintainer review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR documents an after-fix per-user launchd bootstrap run that verified the spawned process received the normalized profile paths, alongside plist parsing and lint checks; redact any private paths if this evidence is refreshed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR documents an after-fix per-user launchd bootstrap run that verified the spawned process received the normalized profile paths, alongside plist parsing and lint checks; redact any private paths if this evidence is refreshed.
Evidence reviewed 4 items Current-main behavior remains unfixed: Current main renders the LaunchAgent EnvironmentVariables dictionary with only PATH; it does not retain the two profile path variables described by the linked report.
Proposed fix and regression coverage: The PR head adds profile environment entries using the existing normalized environment-path helper and adds parsing-based tests for populated values, XML-special characters, and blank omission.
Real behavior proof and current gate: The PR body records a per-user launchctl bootstrap/bootout run that observed the normalized profile variables in the spawned process; the PR is labeled proof: sufficient. The exact-head macos-swift check is still in progress and GitHub reports the branch as mergeable but behind main.
Findings None None.
Security None None.

How this fits together

The macOS app writes a per-user LaunchAgent plist when a user enables Launch at Login. That plist starts the app after login, so its environment determines which OpenClaw config and state profile the relaunched app uses.

flowchart LR
  A[Foreground macOS app] --> B[Profile environment paths]
  B --> C[Launch at Login enabled]
  C --> D[LaunchAgent plist renderer]
  D --> E[macOS launchd]
  E --> F[Login-launched OpenClaw app]
  F --> G[Selected config and state profile]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; the remaining exact-head macOS Swift validation should finish successfully after any required refresh before merge.
  • Complete next step (P2) - No discrete automated repair remains; this needs the active exact-head macOS validation and ordinary maintainer merge review.
Agent review details

Security

None.

PR surface

Other +65. Total +65 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 68 3 +65
Total 2 68 3 +65

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Refresh the branch against current main if needed, confirm the exact-head macOS Swift gate, then merge this focused LaunchAgent fix so the linked profile-continuity issue can close.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Refresh the branch against current main if needed, confirm the exact-head macOS Swift gate, then merge this focused LaunchAgent fix so the linked profile-continuity issue can close.

Do we have a high-confidence way to reproduce the issue?

Yes, source inspection provides a high-confidence path: launch the macOS app with both profile variables set, enable Launch at Login, and inspect the generated plist; current main emits only PATH.

Is this the best way to solve the issue?

Yes. Preserving the existing normalized profile variables in the already-used LaunchAgent environment is narrower and more maintainable than introducing a parallel profile-selection mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 206f989069fb.

Labels

Label justifications:

  • P2: This is a bounded macOS profile-continuity bug that affects users who explicitly launch the app with a non-default profile.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR documents an after-fix per-user launchd bootstrap run that verified the spawned process received the normalized profile paths, alongside plist parsing and lint checks; redact any private paths if this evidence is refreshed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR documents an after-fix per-user launchd bootstrap run that verified the spawned process received the normalized profile paths, alongside plist parsing and lint checks; redact any private paths if this evidence is refreshed.

Evidence

What I checked:

  • Current-main behavior remains unfixed: Current main renders the LaunchAgent EnvironmentVariables dictionary with only PATH; it does not retain the two profile path variables described by the linked report. (apps/macos/Sources/OpenClaw/LaunchAgentManager.swift:81, 206f989069fb)
  • Proposed fix and regression coverage: The PR head adds profile environment entries using the existing normalized environment-path helper and adds parsing-based tests for populated values, XML-special characters, and blank omission. (apps/macos/Sources/OpenClaw/LaunchAgentManager.swift:35, 085fe7532ed3)
  • Real behavior proof and current gate: The PR body records a per-user launchctl bootstrap/bootout run that observed the normalized profile variables in the spawned process; the PR is labeled proof: sufficient. The exact-head macos-swift check is still in progress and GitHub reports the branch as mergeable but behind main. (085fe7532ed3)
  • Feature-history routing: The branch’s substantive implementation commit and its follow-up test-isolation commit are authored by steipete, who is also assigned to the PR; this is the strongest available current ownership signal. (apps/macos/Tests/OpenClawIPCTests/LaunchAgentManagerTests.swift:18, 085fe7532ed3)

Likely related people:

  • steipete: Authored the implementation and follow-up test-isolation commits on this PR and is assigned to its current review. (role: recent area contributor and assigned reviewer; confidence: high; commits: 2d653a1d5911, 085fe7532ed3; files: apps/macos/Sources/OpenClaw/LaunchAgentManager.swift, apps/macos/Tests/OpenClawIPCTests/LaunchAgentManagerTests.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the current macos-swift check complete successfully on the exact reviewed head, refreshing the branch first if main drift requires it.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-04T02:04:44.313Z sha 8fc7db9 :: needs real behavior proof before merge. :: [P2] Restore profile env through TestIsolation
  • reviewed 2026-07-28T14:23:53.491Z sha 2d653a1 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 4, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 4, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 23, 2026
@steipete steipete self-assigned this Jul 28, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 28, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 28, 2026
@steipete
steipete merged commit 8455593 into openclaw:main Jul 28, 2026
78 of 80 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
* origin/main:
  test(codex): de-flake attempt turn-watch timing tests (#115258)
  fix: preserve retryable ACPX lease ownership (#115247)
  fix: serialize ACPX lease ownership transitions
  fix: retain ACPX leases across wrapper reconnects
  refactor: parse ACPX lease command identity
  fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752)
  refactor(config): retire compaction truncateAfterCompaction gate (#115206)
  improve(ui): reduce duplicate chat startup work (#114743)
  fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221)
  perf(pr): cache complete small file lists (#115199)
  perf(sqlite): skip no-op automatic schema repair (#115193)
  docs(browser): correct Docker sandbox setup (#115254)
  fix(ui): avoid duplicate session refreshes during startup (#114764)

# Conflicts:
#	ui/src/pages/agents/panels-tools-skills.browser.test.ts
vincentkoc added a commit that referenced this pull request Jul 28, 2026
* origin/main:
  test(codex): de-flake attempt turn-watch timing tests (#115258)
  fix: preserve retryable ACPX lease ownership (#115247)
  fix: serialize ACPX lease ownership transitions
  fix: retain ACPX leases across wrapper reconnects
  refactor: parse ACPX lease command identity
  fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752)
  refactor(config): retire compaction truncateAfterCompaction gate (#115206)
  improve(ui): reduce duplicate chat startup work (#114743)
  fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221)
  perf(pr): cache complete small file lists (#115199)
  perf(sqlite): skip no-op automatic schema repair (#115193)
  docs(browser): correct Docker sandbox setup (#115254)
  fix(ui): avoid duplicate session refreshes during startup (#114764)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…enclaw#99752)

* fix(macos): preserve profile env in launch-at-login plist

* fix(macos): preserve login profile environment

Co-authored-by: Jasmine Zhang <[email protected]>

* test(macos): isolate launch agent PATH coverage

Co-authored-by: Jasmine Zhang <[email protected]>

---------

Co-authored-by: Jasmine Zhang <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS launch-at-login drops OpenClaw profile environment

2 participants