惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
博客园 - Franky
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
月光博客
月光博客
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
小众软件
小众软件
Microsoft Security Blog
Microsoft Security Blog
Last Week in AI
Last Week in AI
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
J
Java Code Geeks
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(mac): speed up channels settings · openclaw/openclaw@...
steipete · 2026-05-17 · via Recent Commits to openclaw:main

@@ -1,9 +1,27 @@

11

import SwiftUI

223+

enum ConfigSchemaFormMode {

4+

case full

5+

case channelQuick

6+

}

7+38

struct ConfigSchemaForm: View {

49

@Bindable var store: ChannelsStore

510

let schema: ConfigSchemaNode

611

let path: ConfigPath

12+

let mode: ConfigSchemaFormMode

13+14+

init(

15+

store: ChannelsStore,

16+

schema: ConfigSchemaNode,

17+

path: ConfigPath,

18+

mode: ConfigSchemaFormMode = .full)

19+

{

20+

self.store = store

21+

self.schema = schema

22+

self.path = path

23+

self.mode = mode

24+

}

725826

var body: some View {

927

self.renderNode(self.schema, path: self.path)

@@ -12,7 +30,7 @@ struct ConfigSchemaForm: View {

1230

private func renderNode(_ schema: ConfigSchemaNode, path: ConfigPath) -> AnyView {

1331

let storedValue = self.store.configValue(at: path)

1432

let value = storedValue ?? schema.explicitDefault

15-

let label = hintForPath(path, hints: store.configUiHints)?.label ?? schema.title

33+

let label = self.fieldLabel(for: schema, path: path)

1634

let help = hintForPath(path, hints: store.configUiHints)?.help ?? schema.description

1735

let variants = schema.anyOf.isEmpty ? schema.oneOf : schema.anyOf

1836

@@ -62,18 +80,16 @@ struct ConfigSchemaForm: View {

6280

.foregroundStyle(.secondary)

6381

}

6482

let properties = schema.properties

65-

let sortedKeys = properties.keys.sorted { lhs, rhs in

66-

let orderA = hintForPath(path + [.key(lhs)], hints: store.configUiHints)?.order ?? 0

67-

let orderB = hintForPath(path + [.key(rhs)], hints: store.configUiHints)?.order ?? 0

68-

if orderA != orderB { return orderA < orderB }

69-

return lhs < rhs

70-

}

83+

let sortedKeys = self.visibleObjectKeys(properties: properties, path: path)

7184

ForEach(sortedKeys, id: \ .self) { key in

7285

if let child = properties[key] {

7386

self.renderNode(child, path: path + [.key(key)])

7487

}

7588

}

76-

if schema.allowsAdditionalProperties {

89+

if sortedKeys.isEmpty, self.mode == .channelQuick, self.isChannelRoot(path) {

90+

self.renderChannelQuickEmptyState()

91+

}

92+

if self.shouldRenderAdditionalProperties(schema, path: path, value: value) {

7793

self.renderAdditionalProperties(schema, path: path, value: value)

7894

}

7995

})

@@ -100,6 +116,117 @@ struct ConfigSchemaForm: View {

100116

}

101117

}

102118119+

private func fieldLabel(for schema: ConfigSchemaNode, path: ConfigPath) -> String? {

120+

hintForPath(path, hints: self.store.configUiHints)?.label

121+

?? schema.title

122+

?? labelForConfigPath(path)

123+

}

124+125+

private func visibleObjectKeys(

126+

properties: [String: ConfigSchemaNode],

127+

path: ConfigPath) -> [String]

128+

{

129+

let sortedKeys = properties.keys.sorted { lhs, rhs in

130+

let orderA = hintForPath(path + [.key(lhs)], hints: store.configUiHints)?.order ?? 0

131+

let orderB = hintForPath(path + [.key(rhs)], hints: store.configUiHints)?.order ?? 0

132+

if orderA != orderB { return orderA < orderB }

133+

return lhs < rhs

134+

}

135+136+

guard self.mode == .channelQuick, self.isChannelRoot(path) else {

137+

return sortedKeys

138+

}

139+140+

return sortedKeys.filter { key in

141+

guard let child = properties[key] else { return false }

142+

return self.shouldRenderChannelQuickField(key: key, schema: child, path: path + [.key(key)])

143+

}

144+

}

145+146+

private func shouldRenderChannelQuickField(

147+

key: String,

148+

schema: ConfigSchemaNode,

149+

path: ConfigPath) -> Bool

150+

{

151+

if hintForPath(path, hints: self.store.configUiHints)?.advanced == true {

152+

return false

153+

}

154+

if Self.channelQuickKeys.contains(key) {

155+

return self.isSimpleField(schema)

156+

}

157+

return self.store.configValue(at: path) != nil && self.isSimpleField(schema)

158+

}

159+160+

private func isSimpleField(_ schema: ConfigSchemaNode) -> Bool {

161+

let variants = schema.anyOf.isEmpty ? schema.oneOf : schema.anyOf

162+

let nonNullVariants = variants.filter { !$0.isNullSchema }

163+

if !nonNullVariants.isEmpty {

164+

return nonNullVariants.allSatisfy(self.isSimpleField)

165+

}

166+

if let enumValues = schema.enumValues {

167+

return !enumValues.isEmpty

168+

}

169+

switch schema.schemaType {

170+

case "boolean", "integer", "number", "string":

171+

return true

172+

default:

173+

return false

174+

}

175+

}

176+177+

private func shouldRenderAdditionalProperties(

178+

_ schema: ConfigSchemaNode,

179+

path: ConfigPath,

180+

value: Any?) -> Bool

181+

{

182+

guard schema.allowsAdditionalProperties else { return false }

183+

if self.mode != .channelQuick { return true }

184+

guard let dict = value as? [String: Any] else { return false }

185+

let reserved = Set(schema.properties.keys)

186+

return dict.keys.contains { !reserved.contains($0) }

187+

}

188+189+

private func isChannelRoot(_ path: ConfigPath) -> Bool {

190+

guard path.count == 2 else { return false }

191+

guard case .key("channels") = path[0] else { return false }

192+

guard case .key = path[1] else { return false }

193+

return true

194+

}

195+196+

@ViewBuilder

197+

private func renderChannelQuickEmptyState() -> some View {

198+

VStack(alignment: .leading, spacing: 4) {

199+

Text("No quick settings for this channel.")

200+

.font(.callout.weight(.semibold))

201+

Text("Use Config for account, guild, action, and policy details.")

202+

.font(.caption)

203+

.foregroundStyle(.secondary)

204+

}

205+

}

206+207+

private static let channelQuickKeys: Set<String> = [

208+

"apiHash",

209+

"apiId",

210+

"appToken",

211+

"baseUrl",

212+

"botToken",

213+

"configWrites",

214+

"deviceName",

215+

"dmPolicy",

216+

"enabled",

217+

"groupPolicy",

218+

"historyLimit",

219+

"mode",

220+

"nativeCommands",

221+

"nativeSkillCommands",

222+

"phoneNumber",

223+

"signingSecret",

224+

"token",

225+

"url",

226+

"username",

227+

"webhookUrl",

228+

]

229+103230

@ViewBuilder

104231

private func renderStringField(

105232

_ schema: ConfigSchemaNode,

@@ -353,7 +480,11 @@ struct ChannelConfigForm: View {

353480

if self.store.configSchemaLoading {

354481

ProgressView().controlSize(.small)

355482

} else if let schema = store.channelConfigSchema(for: channelId) {

356-

ConfigSchemaForm(store: self.store, schema: schema, path: [.key("channels"), .key(self.channelId)])

483+

ConfigSchemaForm(

484+

store: self.store,

485+

schema: schema,

486+

path: [.key("channels"), .key(self.channelId)],

487+

mode: .channelQuick)

357488

} else {

358489

Text("Schema unavailable for this channel.")

359490

.font(.caption)