macOS: fix swiftlint param count

This commit is contained in:
Shadow 2026-01-02 12:25:47 -06:00
parent 729a545173
commit 5e36390a27
No known key found for this signature in database

View file

@ -37,6 +37,20 @@ struct ConfigSettings: View {
@State private var talkApiKey: String = "" @State private var talkApiKey: String = ""
@State private var gatewayApiKeyFound = false @State private var gatewayApiKeyFound = false
private struct ConfigDraft {
let configModel: String
let customModel: String
let heartbeatMinutes: Int?
let heartbeatBody: String
let browserEnabled: Bool
let browserControlUrl: String
let browserColorHex: String
let browserAttachOnly: Bool
let talkVoiceId: String
let talkApiKey: String
let talkInterruptOnSpeech: Bool
}
var body: some View { var body: some View {
ScrollView { self.content } ScrollView { self.content }
.onChange(of: self.modelCatalogPath) { _, _ in .onChange(of: self.modelCatalogPath) { _, _ in
@ -443,7 +457,7 @@ struct ConfigSettings: View {
let talkApiKey = self.talkApiKey let talkApiKey = self.talkApiKey
let talkInterruptOnSpeech = self.talkInterruptOnSpeech let talkInterruptOnSpeech = self.talkInterruptOnSpeech
let errorMessage = await ConfigSettings.buildAndSaveConfig( let draft = ConfigDraft(
configModel: configModel, configModel: configModel,
customModel: customModel, customModel: customModel,
heartbeatMinutes: heartbeatMinutes, heartbeatMinutes: heartbeatMinutes,
@ -457,67 +471,57 @@ struct ConfigSettings: View {
talkInterruptOnSpeech: talkInterruptOnSpeech talkInterruptOnSpeech: talkInterruptOnSpeech
) )
let errorMessage = await ConfigSettings.buildAndSaveConfig(draft)
if let errorMessage { if let errorMessage {
self.modelError = errorMessage self.modelError = errorMessage
} }
} }
@MainActor @MainActor
private static func buildAndSaveConfig( private static func buildAndSaveConfig(_ draft: ConfigDraft) async -> String? {
configModel: String,
customModel: String,
heartbeatMinutes: Int?,
heartbeatBody: String,
browserEnabled: Bool,
browserControlUrl: String,
browserColorHex: String,
browserAttachOnly: Bool,
talkVoiceId: String,
talkApiKey: String,
talkInterruptOnSpeech: Bool
) async -> String? {
var root = await ConfigStore.load() var root = await ConfigStore.load()
var agent = root["agent"] as? [String: Any] ?? [:] var agent = root["agent"] as? [String: Any] ?? [:]
var browser = root["browser"] as? [String: Any] ?? [:] var browser = root["browser"] as? [String: Any] ?? [:]
var talk = root["talk"] as? [String: Any] ?? [:] var talk = root["talk"] as? [String: Any] ?? [:]
let chosenModel = (configModel == "__custom__" ? customModel : configModel) let chosenModel = (draft.configModel == "__custom__" ? draft.customModel : draft.configModel)
.trimmingCharacters(in: .whitespacesAndNewlines) .trimmingCharacters(in: .whitespacesAndNewlines)
let trimmedModel = chosenModel let trimmedModel = chosenModel
if !trimmedModel.isEmpty { agent["model"] = trimmedModel } if !trimmedModel.isEmpty { agent["model"] = trimmedModel }
if let heartbeatMinutes { if let heartbeatMinutes = draft.heartbeatMinutes {
agent["heartbeatMinutes"] = heartbeatMinutes agent["heartbeatMinutes"] = heartbeatMinutes
} }
let trimmedBody = heartbeatBody.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedBody = draft.heartbeatBody.trimmingCharacters(in: .whitespacesAndNewlines)
if !trimmedBody.isEmpty { if !trimmedBody.isEmpty {
agent["heartbeatBody"] = trimmedBody agent["heartbeatBody"] = trimmedBody
} }
root["agent"] = agent root["agent"] = agent
browser["enabled"] = browserEnabled browser["enabled"] = draft.browserEnabled
let trimmedUrl = browserControlUrl.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedUrl = draft.browserControlUrl.trimmingCharacters(in: .whitespacesAndNewlines)
if !trimmedUrl.isEmpty { browser["controlUrl"] = trimmedUrl } if !trimmedUrl.isEmpty { browser["controlUrl"] = trimmedUrl }
let trimmedColor = browserColorHex.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedColor = draft.browserColorHex.trimmingCharacters(in: .whitespacesAndNewlines)
if !trimmedColor.isEmpty { browser["color"] = trimmedColor } if !trimmedColor.isEmpty { browser["color"] = trimmedColor }
browser["attachOnly"] = browserAttachOnly browser["attachOnly"] = draft.browserAttachOnly
root["browser"] = browser root["browser"] = browser
let trimmedVoice = talkVoiceId.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedVoice = draft.talkVoiceId.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmedVoice.isEmpty { if trimmedVoice.isEmpty {
talk.removeValue(forKey: "voiceId") talk.removeValue(forKey: "voiceId")
} else { } else {
talk["voiceId"] = trimmedVoice talk["voiceId"] = trimmedVoice
} }
let trimmedApiKey = talkApiKey.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedApiKey = draft.talkApiKey.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmedApiKey.isEmpty { if trimmedApiKey.isEmpty {
talk.removeValue(forKey: "apiKey") talk.removeValue(forKey: "apiKey")
} else { } else {
talk["apiKey"] = trimmedApiKey talk["apiKey"] = trimmedApiKey
} }
talk["interruptOnSpeech"] = talkInterruptOnSpeech talk["interruptOnSpeech"] = draft.talkInterruptOnSpeech
root["talk"] = talk root["talk"] = talk
do { do {