Skip to content

Commit 27861fd

Browse files
committed
fix(macos): avoid self-named defaults suite
1 parent 2f06ed3 commit 27861fd

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Docs: https://docs.openclaw.ai
5858

5959
### Fixes
6060

61+
- **macOS Nix defaults:** avoid asking Foundation for the app's own defaults domain as a suite while preserving the stable Nix lookup for renamed app bundles, eliminating the launch-time NSUserDefaults warning. Fixes #88909. Thanks @onlinejourno.
6162
- **Control UI archived session deletion:** send archive-gated delete requests from Sessions-page row and mixed-selection actions so write-scoped operators can remove archived threads while active-session deletion remains admin-only. Thanks @shakkernerd.
6263
- **Control UI command recovery:** keep delayed detached and immediate command failures scoped to their submitting session, preserving failed drafts and attachments for that pane without overwriting the active session. Fixes #116846. Thanks @shakkernerd.
6364
- **Microsoft Teams message-tool replies:** keep automatic live previews from duplicating a message already delivered to the current Teams conversation, while preserving distinct follow-up text and cross-conversation sends. Fixes #116397. (#116398) Thanks @a-tokyo.

‎apps/macos/Sources/OpenClaw/ProcessInfo+OpenClaw.swift‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ extension ProcessInfo {
1313
return String(cString: raw) == "1"
1414
}
1515

16+
static func resolveStableNixSuite(bundleIdentifier: String?, isAppBundle: Bool) -> UserDefaults? {
17+
// The app's own defaults domain is already represented by UserDefaults.standard.
18+
// Passing that same identifier to suiteName triggers Foundation's nonsensical-suite warning.
19+
guard isAppBundle, bundleIdentifier != launchdLabel else { return nil }
20+
return UserDefaults(suiteName: launchdLabel)
21+
}
22+
1623
/// Nix deployments may write defaults into a stable suite (`ai.openclaw.mac`) even if the shipped
1724
/// app bundle identifier changes (and therefore `UserDefaults.standard` domain changes).
1825
static func resolveNixMode(
@@ -33,7 +40,9 @@ extension ProcessInfo {
3340

3441
var isNixMode: Bool {
3542
let isAppBundle = Bundle.main.bundleURL.pathExtension == "app"
36-
let stableSuite = UserDefaults(suiteName: launchdLabel)
43+
let stableSuite = Self.resolveStableNixSuite(
44+
bundleIdentifier: Bundle.main.bundleIdentifier,
45+
isAppBundle: isAppBundle)
3746
return Self.resolveNixMode(
3847
environment: self.environment,
3948
standard: .standard,

‎apps/macos/Tests/OpenClawIPCTests/NixModeStableSuiteTests.swift‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,32 @@ import Testing
44

55
@Suite(.serialized)
66
struct NixModeStableSuiteTests {
7+
@Test func `does not create a stable suite for the app's own bundle identifier`() {
8+
#expect(ProcessInfo.resolveStableNixSuite(bundleIdentifier: launchdLabel, isAppBundle: true) == nil)
9+
}
10+
11+
@Test func `creates a stable suite for renamed app bundles`() {
12+
#expect(ProcessInfo.resolveStableNixSuite(
13+
bundleIdentifier: "ai.openclaw.mac.renamed",
14+
isAppBundle: true) != nil)
15+
}
16+
17+
@Test func `does not create a stable suite outside app bundles`() {
18+
#expect(ProcessInfo.resolveStableNixSuite(
19+
bundleIdentifier: "ai.openclaw.mac.renamed",
20+
isAppBundle: false) == nil)
21+
}
22+
723
@Test func `resolves from stable suite for app bundles`() throws {
824
let suite = try #require(UserDefaults(suiteName: launchdLabel))
925
let key = "openclaw.nixMode"
1026
let prev = suite.object(forKey: key)
1127
defer {
12-
if let prev { suite.set(prev, forKey: key) } else { suite.removeObject(forKey: key) }
28+
if let prev {
29+
suite.set(prev, forKey: key)
30+
} else {
31+
suite.removeObject(forKey: key)
32+
}
1333
}
1434

1535
suite.set(true, forKey: key)
@@ -65,7 +85,11 @@ struct NixModeStableSuiteTests {
6585
let key = "openclaw.nixMode"
6686
let prev = suite.object(forKey: key)
6787
defer {
68-
if let prev { suite.set(prev, forKey: key) } else { suite.removeObject(forKey: key) }
88+
if let prev {
89+
suite.set(prev, forKey: key)
90+
} else {
91+
suite.removeObject(forKey: key)
92+
}
6993
}
7094

7195
suite.set(true, forKey: key)

0 commit comments

Comments
 (0)