Skip to content

Commit f61ae11

Browse files
authored
fix(macos): surface node service recovery commands (#129874)
1 parent 58bb40c commit f61ae11

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎apps/macos/Sources/OpenClaw/NodeServiceManager.swift‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,11 @@ extension NodeServiceManager {
148148

149149
private static func errorMessage(from result: CommandResult, treatNotLoadedAsError: Bool) -> String? {
150150
if !result.success {
151-
return result.message ?? "Node service command failed"
151+
return result.parsed.flatMap {
152+
self.mergeHints(message: $0.error ?? $0.message, hints: $0.hints)
153+
} ?? result.message ?? "Node service command failed"
152154
}
153155
guard let parsed = result.parsed else { return nil }
154-
if parsed.ok == false {
155-
return self.mergeHints(message: parsed.error ?? parsed.message, hints: parsed.hints)
156-
}
157156
if treatNotLoadedAsError, parsed.result == "not-loaded" {
158157
let base = parsed.message ?? "Node service not loaded."
159158
return self.mergeHints(message: base, hints: parsed.hints)

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ import Testing
9999

100100
@Test(arguments: [
101101
"failed-start", "failed-stop", "failed-restart", "json-success", "plain-success", "json-failure",
102+
"json-failure-with-hints", "json-failure-with-hints-and-exit", "json-failure-hints-only",
103+
"not-loaded-start", "not-loaded-stop",
102104
])
103105
func `node lifecycle respects process exit and optional JSON status`(_ scenario: String) async throws {
104106
let root = try makeTempDirForTests()
@@ -116,20 +118,37 @@ import Testing
116118
case "$OPENCLAW_NODE_SERVICE_TEST_CASE" in
117119
failed-*) printf '{"ok":true}'; printf 'cleanup failed' >&2; exit 23 ;;
118120
json-failure) printf '{"ok":false,"error":"reported failure"}' ;;
121+
json-failure-with-hints*)
122+
printf '{"ok":false,"error":"Node service not installed.",'
123+
printf '"hints":["openclaw node install","openclaw node start","third hint"]}'
124+
if [ "$OPENCLAW_NODE_SERVICE_TEST_CASE" = "json-failure-with-hints-and-exit" ]; then exit 1; fi
125+
;;
126+
json-failure-hints-only)
127+
printf '{"ok":false,"hints":["openclaw node install","openclaw node start"]}'
128+
;;
129+
not-loaded-*)
130+
printf '{"ok":true,"result":"not-loaded","message":"Node service not loaded.",'
131+
printf '"hints":["openclaw node install","openclaw node start"]}'
132+
;;
119133
plain-success) printf 'service started' ;;
120134
*) printf '{"ok":true}' ;;
121135
esac
122136
"""
123137
try script.write(to: executable, atomically: false, encoding: .utf8)
124138

125139
let action = switch scenario {
126-
case "failed-stop": "stop"
140+
case "failed-stop", "not-loaded-stop": "stop"
127141
case "failed-restart": "restart"
128142
default: "start"
129143
}
130144
let expectedError: String? = switch scenario {
131145
case "failed-start", "failed-stop", "failed-restart": "cleanup failed"
132146
case "json-failure": "reported failure"
147+
case "json-failure-with-hints", "json-failure-with-hints-and-exit":
148+
"Node service not installed. (openclaw node install · openclaw node start)"
149+
case "json-failure-hints-only": "openclaw node install · openclaw node start"
150+
case "not-loaded-start":
151+
"Node service not loaded. (openclaw node install · openclaw node start)"
133152
default: nil
134153
}
135154

0 commit comments

Comments
 (0)