From 5e07400cd15c501fb91fbc74bc1cbd04b516aa95 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 23 Dec 2025 23:45:27 +0000 Subject: [PATCH] refactor: update macOS config paths --- .../Sources/Clawdis/ClawdisConfigFile.swift | 16 ++++++------- .../Sources/Clawdis/ConfigSettings.swift | 23 +++++++------------ apps/macos/Sources/Clawdis/DebugActions.swift | 3 +-- .../macos/Sources/Clawdis/DebugSettings.swift | 9 +++----- apps/macos/Sources/Clawdis/Onboarding.swift | 10 ++++---- 5 files changed, 25 insertions(+), 36 deletions(-) diff --git a/apps/macos/Sources/Clawdis/ClawdisConfigFile.swift b/apps/macos/Sources/Clawdis/ClawdisConfigFile.swift index 6c3f4c2ec..4675badfa 100644 --- a/apps/macos/Sources/Clawdis/ClawdisConfigFile.swift +++ b/apps/macos/Sources/Clawdis/ClawdisConfigFile.swift @@ -61,22 +61,22 @@ enum ClawdisConfigFile { self.saveDict(root) } - static func inboundWorkspace() -> String? { + static func agentWorkspace() -> String? { let root = self.loadDict() - let inbound = root["inbound"] as? [String: Any] - return inbound?["workspace"] as? String + let agent = root["agent"] as? [String: Any] + return agent?["workspace"] as? String } - static func setInboundWorkspace(_ workspace: String?) { + static func setAgentWorkspace(_ workspace: String?) { var root = self.loadDict() - var inbound = root["inbound"] as? [String: Any] ?? [:] + var agent = root["agent"] as? [String: Any] ?? [:] let trimmed = workspace?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "" if trimmed.isEmpty { - inbound.removeValue(forKey: "workspace") + agent.removeValue(forKey: "workspace") } else { - inbound["workspace"] = trimmed + agent["workspace"] = trimmed } - root["inbound"] = inbound + root["agent"] = agent self.saveDict(root) } } diff --git a/apps/macos/Sources/Clawdis/ConfigSettings.swift b/apps/macos/Sources/Clawdis/ConfigSettings.swift index fdc92d745..b3e6f6728 100644 --- a/apps/macos/Sources/Clawdis/ConfigSettings.swift +++ b/apps/macos/Sources/Clawdis/ConfigSettings.swift @@ -66,7 +66,7 @@ struct ConfigSettings: View { private var header: some View { Text("Clawdis CLI config") .font(.title3.weight(.semibold)) - Text("Edit ~/.clawdis/clawdis.json (inbound.agent / inbound.session).") + Text("Edit ~/.clawdis/clawdis.json (agent / inbound.session).") .font(.callout) .foregroundStyle(.secondary) } @@ -274,11 +274,9 @@ struct ConfigSettings: View { private func loadConfig() { let parsed = self.loadConfigDict() - let inbound = parsed["inbound"] as? [String: Any] - let reply = inbound?["reply"] as? [String: Any] - let agent = reply?["agent"] as? [String: Any] - let heartbeatMinutes = reply?["heartbeatMinutes"] as? Int - let heartbeatBody = reply?["heartbeatBody"] as? String + let agent = parsed["agent"] as? [String: Any] + let heartbeatMinutes = agent?["heartbeatMinutes"] as? Int + let heartbeatBody = agent?["heartbeatBody"] as? String let browser = parsed["browser"] as? [String: Any] let loadedModel = (agent?["model"] as? String) ?? "" @@ -312,9 +310,7 @@ struct ConfigSettings: View { defer { self.configSaving = false } var root = self.loadConfigDict() - var inbound = root["inbound"] as? [String: Any] ?? [:] - var reply = inbound["reply"] as? [String: Any] ?? [:] - var agent = reply["agent"] as? [String: Any] ?? [:] + var agent = root["agent"] as? [String: Any] ?? [:] var browser = root["browser"] as? [String: Any] ?? [:] let chosenModel = (self.configModel == "__custom__" ? self.customModel : self.configModel) @@ -322,19 +318,16 @@ struct ConfigSettings: View { let trimmedModel = chosenModel if !trimmedModel.isEmpty { agent["model"] = trimmedModel } - reply["agent"] = agent - if let heartbeatMinutes { - reply["heartbeatMinutes"] = heartbeatMinutes + agent["heartbeatMinutes"] = heartbeatMinutes } let trimmedBody = self.heartbeatBody.trimmingCharacters(in: .whitespacesAndNewlines) if !trimmedBody.isEmpty { - reply["heartbeatBody"] = trimmedBody + agent["heartbeatBody"] = trimmedBody } - inbound["reply"] = reply - root["inbound"] = inbound + root["agent"] = agent browser["enabled"] = self.browserEnabled let trimmedUrl = self.browserControlUrl.trimmingCharacters(in: .whitespacesAndNewlines) diff --git a/apps/macos/Sources/Clawdis/DebugActions.swift b/apps/macos/Sources/Clawdis/DebugActions.swift index 7517ee653..aa2f2fddf 100644 --- a/apps/macos/Sources/Clawdis/DebugActions.swift +++ b/apps/macos/Sources/Clawdis/DebugActions.swift @@ -164,8 +164,7 @@ enum DebugActions { let data = try? Data(contentsOf: configURL), let parsed = try? JSONSerialization.jsonObject(with: data) as? [String: Any], let inbound = parsed["inbound"] as? [String: Any], - let reply = inbound["reply"] as? [String: Any], - let session = reply["session"] as? [String: Any], + let session = inbound["session"] as? [String: Any], let path = session["store"] as? String, !path.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { diff --git a/apps/macos/Sources/Clawdis/DebugSettings.swift b/apps/macos/Sources/Clawdis/DebugSettings.swift index 5e0df03e1..1afc1ad89 100644 --- a/apps/macos/Sources/Clawdis/DebugSettings.swift +++ b/apps/macos/Sources/Clawdis/DebugSettings.swift @@ -682,8 +682,7 @@ struct DebugSettings: View { let data = try? Data(contentsOf: url), let parsed = try? JSONSerialization.jsonObject(with: data) as? [String: Any], let inbound = parsed["inbound"] as? [String: Any], - let reply = inbound["reply"] as? [String: Any], - let session = reply["session"] as? [String: Any], + let session = inbound["session"] as? [String: Any], let path = session["store"] as? String else { self.sessionStorePath = SessionLoader.defaultStorePath @@ -703,11 +702,9 @@ struct DebugSettings: View { } var inbound = root["inbound"] as? [String: Any] ?? [:] - var reply = inbound["reply"] as? [String: Any] ?? [:] - var session = reply["session"] as? [String: Any] ?? [:] + var session = inbound["session"] as? [String: Any] ?? [:] session["store"] = trimmed.isEmpty ? SessionLoader.defaultStorePath : trimmed - reply["session"] = session - inbound["reply"] = reply + inbound["session"] = session root["inbound"] = inbound do { diff --git a/apps/macos/Sources/Clawdis/Onboarding.swift b/apps/macos/Sources/Clawdis/Onboarding.swift index 2044f2713..5150f90f0 100644 --- a/apps/macos/Sources/Clawdis/Onboarding.swift +++ b/apps/macos/Sources/Clawdis/Onboarding.swift @@ -881,8 +881,8 @@ struct OnboardingView: View { Button("Save in config") { let url = AgentWorkspace.resolveWorkspaceURL(from: self.workspacePath) - ClawdisConfigFile.setInboundWorkspace(AgentWorkspace.displayPath(for: url)) - self.workspaceStatus = "Saved to ~/.clawdis/clawdis.json (inbound.workspace)" + ClawdisConfigFile.setAgentWorkspace(AgentWorkspace.displayPath(for: url)) + self.workspaceStatus = "Saved to ~/.clawdis/clawdis.json (agent.workspace)" } .buttonStyle(.bordered) .disabled(self.workspaceApplying) @@ -1268,7 +1268,7 @@ struct OnboardingView: View { private func loadWorkspaceDefaults() { guard self.workspacePath.isEmpty else { return } - let configured = ClawdisConfigFile.inboundWorkspace() + let configured = ClawdisConfigFile.agentWorkspace() let url = AgentWorkspace.resolveWorkspaceURL(from: configured) self.workspacePath = AgentWorkspace.displayPath(for: url) self.refreshBootstrapStatus() @@ -1276,14 +1276,14 @@ struct OnboardingView: View { private func ensureDefaultWorkspace() { guard self.state.connectionMode == .local else { return } - let configured = ClawdisConfigFile.inboundWorkspace() + let configured = ClawdisConfigFile.agentWorkspace() let url = AgentWorkspace.resolveWorkspaceURL(from: configured) switch AgentWorkspace.bootstrapSafety(for: url) { case .safe: do { _ = try AgentWorkspace.bootstrap(workspaceURL: url) if (configured ?? "").trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { - ClawdisConfigFile.setInboundWorkspace(AgentWorkspace.displayPath(for: url)) + ClawdisConfigFile.setAgentWorkspace(AgentWorkspace.displayPath(for: url)) } } catch { self.workspaceStatus = "Failed to create workspace: \(error.localizedDescription)"