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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
Last Week in AI
Last Week in AI
腾讯CDC
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
I
InfoQ
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
H
Help Net Security
T
Tailwind CSS Blog
美团技术团队
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed

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: improve mac pairing approval prompt · openclaw/openc...
steipete · 2026-05-17 · via Recent Commits to openclaw:main

@@ -33,7 +33,7 @@ final class DevicePairingApprovalPrompter {

3333

let remoteIp: String?

3434

}

353536-

private struct PendingRequest: Codable, Equatable, Identifiable {

36+

struct PendingRequest: Codable, Equatable, Identifiable {

3737

let requestId: String

3838

let deviceId: String

3939

let publicKey: String

@@ -115,14 +115,16 @@ final class DevicePairingApprovalPrompter {

115115

PairingAlertSupport.presentPairingAlert(

116116

request: req,

117117

requestId: req.requestId,

118-

messageText: "Allow device to connect?",

119-

informativeText: Self.describe(req),

118+

messageText: Self.alertTitle(for: req),

119+

informativeText: Self.alertSummary(for: req),

120+

buttonTitles: PairingAlertSupport.ButtonTitles(approve: Self.approveButtonTitle(for: req)),

121+

accessoryView: Self.buildAccessoryView(for: req),

120122

state: self.alertState,

121123

onResponse: self.handleAlertResponse)

122124

}

123125124126

private func handleAlertResponse(_ response: NSApplication.ModalResponse, request: PendingRequest) async {

125-

var shouldRemove = response != .alertFirstButtonReturn

127+

var shouldRemove = response != .alertSecondButtonReturn

126128

defer {

127129

if shouldRemove {

128130

if self.queue.first == request {

@@ -144,14 +146,14 @@ final class DevicePairingApprovalPrompter {

144146145147

switch response {

146148

case .alertFirstButtonReturn:

149+

_ = await self.approve(requestId: request.requestId)

150+

case .alertSecondButtonReturn:

147151

shouldRemove = false

148152

if let idx = self.queue.firstIndex(of: request) {

149153

self.queue.remove(at: idx)

150154

}

151155

self.queue.append(request)

152156

return

153-

case .alertSecondButtonReturn:

154-

_ = await self.approve(requestId: request.requestId)

155157

case .alertThirdButtonReturn:

156158

await self.reject(requestId: request.requestId)

157159

default:

@@ -233,24 +235,166 @@ final class DevicePairingApprovalPrompter {

233235

self.updatePendingCounts()

234236

}

235237236-

private static func describe(_ req: PendingRequest) -> String {

237-

var lines: [String] = []

238-

lines.append("Device: \(req.displayName ?? req.deviceId)")

239-

if let platform = req.platform {

240-

lines.append("Platform: \(platform)")

238+

static func alertTitle(for req: PendingRequest) -> String {

239+

self.isMac(req.platform) ? "New Mac wants to connect" : "New device wants to connect"

240+

}

241+242+

static func alertSummary(for req: PendingRequest) -> String {

243+

let subject = self.isMac(req.platform) ? "this Mac app" : "this device"

244+

return "Approve \(subject) to control OpenClaw. Only approve if this is yours; you can remove it later in Settings."

245+

}

246+247+

static func approveButtonTitle(for req: PendingRequest) -> String {

248+

self.isMac(req.platform) ? "Approve Mac" : "Approve Device"

249+

}

250+251+

static func buildAccessoryView(for req: PendingRequest) -> NSView {

252+

let stack = NSStackView()

253+

stack.orientation = .vertical

254+

stack.alignment = .leading

255+

stack.spacing = 8

256+

stack.edgeInsets = NSEdgeInsets(top: 2, left: 0, bottom: 0, right: 0)

257+258+

stack.addArrangedSubview(self.makeValueRow(label: "Device", value: self.deviceName(for: req)))

259+

if let platform = self.prettyPlatform(req.platform) {

260+

stack.addArrangedSubview(self.makeValueRow(label: "Platform", value: platform))

241261

}

242-

if let role = req.role {

243-

lines.append("Role: \(role)")

262+

if let role = self.prettyRole(req.role) {

263+

stack.addArrangedSubview(self.makeValueRow(label: "Role", value: role))

244264

}

245-

if let scopes = req.scopes, !scopes.isEmpty {

246-

lines.append("Scopes: \(scopes.joined(separator: ", "))")

265+

let accessItems = self.friendlyScopeNames(req.scopes)

266+

if !accessItems.isEmpty {

267+

stack.addArrangedSubview(self.makeSectionLabel("Access requested"))

268+

for item in accessItems {

269+

stack.addArrangedSubview(self.makeBullet(item))

270+

}

247271

}

248-

if let remoteIp = req.remoteIp {

249-

lines.append("IP: \(remoteIp)")

272+

stack.addArrangedSubview(self.makeDetailLine(req))

273+274+

let fitting = stack.fittingSize

275+

stack.frame = NSRect(x: 0, y: 0, width: 420, height: fitting.height)

276+

return stack

277+

}

278+279+

static func deviceName(for req: PendingRequest) -> String {

280+

let trimmedName = req.displayName?.trimmingCharacters(in: .whitespacesAndNewlines)

281+

if let trimmedName, !trimmedName.isEmpty, trimmedName != req.deviceId {

282+

return trimmedName

283+

}

284+

return self.isMac(req.platform) ? "OpenClaw Mac app" : "New device"

285+

}

286+287+

static func prettyPlatform(_ raw: String?) -> String? {

288+

let platform = raw?.trimmingCharacters(in: .whitespacesAndNewlines)

289+

guard let platform, !platform.isEmpty else { return nil }

290+

switch platform.lowercased() {

291+

case "macintel", "x86_64-apple-darwin":

292+

return "Mac (Intel)"

293+

case "macarm", "macarm64", "arm64-apple-darwin", "aarch64-apple-darwin":

294+

return "Mac (Apple silicon)"

295+

case "darwin":

296+

return "Mac"

297+

default:

298+

if platform.lowercased().contains("mac") {

299+

return "Mac"

300+

}

301+

return platform

302+

}

303+

}

304+305+

static func prettyRole(_ raw: String?) -> String? {

306+

let role = raw?.trimmingCharacters(in: .whitespacesAndNewlines)

307+

guard let role, !role.isEmpty else { return nil }

308+

return role == "operator" ? "Operator" : role

309+

}

310+311+

static func friendlyScopeNames(_ scopes: [String]?) -> [String] {

312+

guard let scopes else { return [] }

313+

var seen = Set<String>()

314+

return scopes.compactMap { scope in

315+

let normalized = scope.trimmingCharacters(in: .whitespacesAndNewlines)

316+

guard !normalized.isEmpty, seen.insert(normalized).inserted else { return nil }

317+

switch normalized {

318+

case "operator.admin":

319+

return "Admin access"

320+

case "operator.read":

321+

return "Read OpenClaw data"

322+

case "operator.write":

323+

return "Send messages and make changes"

324+

case "operator.approvals":

325+

return "Manage approvals"

326+

case "operator.pairing":

327+

return "Pair and repair devices"

328+

case "operator.talk.secrets":

329+

return "Use Talk credentials"

330+

default:

331+

return normalized

332+

}

333+

}

334+

}

335+336+

static func shortIdentifier(_ id: String) -> String {

337+

let trimmed = id.trimmingCharacters(in: .whitespacesAndNewlines)

338+

guard trimmed.count > 20 else { return trimmed }

339+

return "\(trimmed.prefix(8))...\(trimmed.suffix(7))"

340+

}

341+342+

private static func isMac(_ platform: String?) -> Bool {

343+

guard let platform else { return false }

344+

let lower = platform.lowercased()

345+

return lower.contains("mac") || lower.contains("darwin")

346+

}

347+348+

private static func makeValueRow(label: String, value: String) -> NSView {

349+

let row = NSStackView()

350+

row.orientation = .horizontal

351+

row.alignment = .firstBaseline

352+

row.spacing = 8

353+354+

let labelField = self.makeLabel("\(label):", font: .systemFont(ofSize: 12, weight: .semibold))

355+

labelField.textColor = .secondaryLabelColor

356+

labelField.setContentHuggingPriority(.required, for: .horizontal)

357+

let valueField = self.makeLabel(value, font: .systemFont(ofSize: 12, weight: .regular))

358+

valueField.maximumNumberOfLines = 2

359+360+

row.addArrangedSubview(labelField)

361+

row.addArrangedSubview(valueField)

362+

return row

363+

}

364+365+

private static func makeSectionLabel(_ text: String) -> NSTextField {

366+

let label = self.makeLabel(text, font: .systemFont(ofSize: 12, weight: .semibold))

367+

label.textColor = .secondaryLabelColor

368+

return label

369+

}

370+371+

private static func makeBullet(_ text: String) -> NSTextField {

372+

let label = self.makeLabel("\(text)", font: .systemFont(ofSize: 12, weight: .regular))

373+

label.maximumNumberOfLines = 2

374+

return label

375+

}

376+377+

private static func makeDetailLine(_ req: PendingRequest) -> NSTextField {

378+

var parts = ["ID \(self.shortIdentifier(req.deviceId))"]

379+

if let remoteIp = req.remoteIp?.trimmingCharacters(in: .whitespacesAndNewlines), !remoteIp.isEmpty {

380+

parts.append("IP \(remoteIp.replacingOccurrences(of: "::ffff:", with: ""))")

250381

}

251382

if req.isRepair == true {

252-

lines.append("Repair: yes")

383+

parts.append("repair request")

253384

}

254-

return lines.joined(separator: "\n")

385+

let label = self.makeLabel(

386+

parts.joined(separator: " · "),

387+

font: .monospacedSystemFont(ofSize: 11, weight: .regular))

388+

label.textColor = .tertiaryLabelColor

389+

label.maximumNumberOfLines = 2

390+

return label

391+

}

392+393+

private static func makeLabel(_ text: String, font: NSFont) -> NSTextField {

394+

let label = NSTextField(labelWithString: text)

395+

label.font = font

396+

label.lineBreakMode = .byWordWrapping

397+

label.textColor = .labelColor

398+

return label

255399

}

256400

}