fix: prefer gateway config in local mode

This commit is contained in:
Peter Steinberger
2026-01-05 05:54:41 +00:00
parent 1119f2003e
commit 7c51efe8f8
2 changed files with 12 additions and 4 deletions

View File

@@ -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
}
}