Skip to content

Commit b71a09f

Browse files
fix(macos): return paired-node Codex catalogs without native supervision (#126811)
* fix(macos): route Codex catalog to plugin worker * fix(macos): freeze Codex catalog ownership per invoke --------- Co-authored-by: Josh Lehman <[email protected]>
1 parent 9abfc1b commit b71a09f

2 files changed

Lines changed: 37 additions & 7 deletions

File tree

‎apps/macos/Sources/OpenClaw/NodeMode/MacNodeRuntime.swift‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,15 @@ actor MacNodeRuntime {
305305
}
306306

307307
private func handleCodexThreadInvoke(_ req: BridgeInvokeRequest) async throws -> BridgeInvokeResponse {
308-
guard self.codexThreadCatalogEnabled() else {
308+
// Freeze native ownership before awaiting worker support so one invocation cannot switch owners.
309+
let nativeCatalogEnabled = self.codexThreadCatalogEnabled()
310+
if !nativeCatalogEnabled,
311+
let nodeHostWorker,
312+
await nodeHostWorker.supports(req.command)
313+
{
314+
return await nodeHostWorker.invoke(req)
315+
}
316+
guard nativeCatalogEnabled else {
309317
return Self.errorResponse(
310318
req,
311319
code: .unavailable,

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

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Darwin
22
import Foundation
33
import OpenClawKit
44
import OpenClawProtocol
5+
import os
56
import Testing
67
@testable import OpenClaw
78

@@ -211,12 +212,33 @@ struct MacNodeHostWorkerTests {
211212
}
212213

213214
@Test(arguments: [
214-
(
215-
MacNodeCodexThreadCatalogContract.listCommand,
216-
"UNAVAILABLE: Codex session catalog is disabled"),
217-
(
218-
MacNodeCodexThreadCatalogContract.turnsCommand,
219-
"UNAVAILABLE: Codex session catalog is disabled"),
215+
MacNodeCodexThreadCatalogContract.listCommand,
216+
MacNodeCodexThreadCatalogContract.turnsCommand,
217+
])
218+
func `worker owns Codex catalog commands when native catalog is disabled`(command: String) async {
219+
let worker = StubMacNodeHostWorker(commands: [command])
220+
let nativeCatalogEnabledReads = OSAllocatedUnfairLock(initialState: 0)
221+
let runtime = MacNodeRuntime(
222+
nodeHostWorker: worker,
223+
codexThreadCatalogEnabled: {
224+
nativeCatalogEnabledReads.withLock {
225+
$0 += 1
226+
return false
227+
}
228+
})
229+
230+
let response = await runtime.handleInvoke(BridgeInvokeRequest(
231+
id: "worker-codex-catalog",
232+
command: command,
233+
paramsJSON: #"{"limit":1}"#))
234+
235+
#expect(response.ok)
236+
#expect(response.payloadJSON == #"{"owner":"cli"}"#)
237+
#expect(await worker.invokedCommands() == [command])
238+
#expect(nativeCatalogEnabledReads.withLock { $0 } == 1)
239+
}
240+
241+
@Test(arguments: [
220242
(
221243
MacNodeClaudeSessionCatalogContract.listCommand,
222244
"UNAVAILABLE: Claude session catalog is disabled"),

0 commit comments

Comments
 (0)