From 7c51efe8f835c0bae86d604cb46453551fc2fc1c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 5 Jan 2026 05:54:41 +0000 Subject: [PATCH] fix: prefer gateway config in local mode --- CHANGELOG.md | 1 + apps/macos/Sources/Clawdbot/ConfigStore.swift | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73ef0f10..64bd5ea6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Fixes - Onboarding: resolve CLI entrypoint when running via `npx` so gateway daemon install works without a build step. - TUI: migrate key handling to the updated pi-tui Key matcher API. +- macOS: prefer gateway config reads/writes in local mode (fall back to disk if the gateway is unavailable). - macOS: local gateway now connects via tailnet IP when bind mode is `tailnet`/`auto`. - macOS: Connections removes the sidebar toggle from the Settings toolbar to avoid overflow. - macOS: drop deprecated `afterMs` from agent wait params to match gateway schema. diff --git a/apps/macos/Sources/Clawdbot/ConfigStore.swift b/apps/macos/Sources/Clawdbot/ConfigStore.swift index be05aec9f..9090dd1d8 100644 --- a/apps/macos/Sources/Clawdbot/ConfigStore.swift +++ b/apps/macos/Sources/Clawdbot/ConfigStore.swift @@ -34,11 +34,14 @@ enum ConfigStore { if let override = overrides.loadRemote { return await override() } - return await self.loadFromGateway() + return await self.loadFromGateway() ?? [:] } if let override = overrides.loadLocal { return override() } + if let gateway = await self.loadFromGateway() { + return gateway + } return ClawdbotConfigFile.loadDict() } @@ -55,13 +58,17 @@ enum ConfigStore { if let override = overrides.saveLocal { override(root) } else { - ClawdbotConfigFile.saveDict(root) + do { + try await self.saveToGateway(root) + } catch { + ClawdbotConfigFile.saveDict(root) + } } } } @MainActor - private static func loadFromGateway() async -> [String: Any] { + private static func loadFromGateway() async -> [String: Any]? { do { let snap: ConfigSnapshot = try await GatewayConnection.shared.requestDecoded( method: .configGet, @@ -69,7 +76,7 @@ enum ConfigStore { timeoutMs: 8000) return snap.config?.mapValues { $0.foundationValue } ?? [:] } catch { - return [:] + return nil } }