Skip to content

fix(cli): clear conflicting OPENCLAW_LAUNCHD_LABEL when --profile is provided#2442

Open
BingqingLyu wants to merge 5 commits into
mainfrom
fork-pr-66000-fix-issue-65643-profile-launchd-label
Open

fix(cli): clear conflicting OPENCLAW_LAUNCHD_LABEL when --profile is provided#2442
BingqingLyu wants to merge 5 commits into
mainfrom
fork-pr-66000-fix-issue-65643-profile-launchd-label

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes openclaw#65643

When running CLI commands from within a gateway process that has OPENCLAW_LAUNCHD_LABEL set (e.g. ai.openclaw.batch), using --profile interactive gateway status would still resolve the wrong plist because resolveLaunchAgentLabel() short-circuits on the inherited env label.

Changes

  • src/cli/profile.ts: applyCliProfileEnv() now clears OPENCLAW_LAUNCHD_LABEL only when it conflicts with the profile-derived label. Matching labels are preserved to respect explicit operator overrides.
  • src/cli/profile.test.ts: Added 4 test cases covering conflict clearing, label preservation, custom label clearing, and no-op behavior.

Behavior

Scenario Result
OPENCLAW_LAUNCHD_LABEL=ai.openclaw.batch + --profile interactive Cleared (conflict)
OPENCLAW_LAUNCHD_LABEL=ai.openclaw.work + --profile work Preserved (matches)
OPENCLAW_LAUNCHD_LABEL=com.custom.openclaw + --profile ops Cleared (custom differs)
No label + --profile ops No-op

Test plan

  • 4 new unit tests covering all label clearing scenarios
  • Verify multi-profile gateway status resolves correct plist

…provided

When --profile is explicitly passed, applyCliProfileEnv() now clears
OPENCLAW_LAUNCHD_LABEL only when it conflicts with the profile-derived
label. This allows resolveLaunchAgentLabel() to derive the correct
label from OPENCLAW_PROFILE instead of short-circuiting on a stale
inherited value from a parent gateway process.

Matching labels are preserved to respect explicit operator overrides.

Fixes openclaw#65643
@BingqingLyu BingqingLyu added the independent-review Non-trivial PR with no function-level conflict with other open PRs label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

independent-review Non-trivial PR with no function-level conflict with other open PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--profile flag does not clear OPENCLAW_LAUNCHD_LABEL, causing gateway status to resolve wrong plist

2 participants