mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-07 05:45:59 +08:00
* fix(ios): defer QR pairing after scanner dismissal * fix(ios): process QR pairing after scanner dismissal * fix(ios): harden QR scanner handoff * fix(ios): give QR scanner dismissal more time * fix(ios): keep onboarding open for QR trust prompt * fix(ios): keep QR trust prompt owned by onboarding * fix(ios): recover operator pairing after QR bootstrap * fix(ios): cancel stale QR scanner handoffs Co-authored-by: PollyBot13 <pollybot13@gmail.com> * fix(ios): defer QR setup until onboarding closes * fix(ios): keep QR setup links with visible settings * fix(ios): consume setup links during onboarding * fix(ios): handle setup links during onboarding launch * fix(ios): route setup links through active onboarding * fix(ios): harden QR gateway handoff * fix(ios): cancel superseded gateway attempts * fix(ios): serialize scanner result delivery * fix(ios): prevent stale gateway reconnects * fix(ios): serialize gateway target handoff * fix(ios): disable stale gateway relaunch route * fix(ios): await staged bootstrap reset * test(ios): bound gateway reset handoff * fix(ios): preserve explicit gateway handoff * fix(ios): harden gateway lifecycle ownership * chore(ios): sync native i18n inventory * test(ios): align gateway ownership assertions * refactor(ios): remove superseded gateway helpers * fix(ios): keep gateway auth route scoped * fix(ios): restore gateway target review state * fix(protocol): refresh Swift plugin approval model * test(ios): isolate state directory overrides * fix(ios): preserve watch alerts across gateway switches * fix(ios): bind deferred work to gateway ownership * docs(changelog): credit iOS gateway handoff fix * chore(i18n): sync native app inventory * test(ios): remove unused Watch approval hooks --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
105 lines
3.9 KiB
Swift
105 lines
3.9 KiB
Swift
import Foundation
|
|
import OpenClawKit
|
|
|
|
extension NodeAppModel {
|
|
static func normalizeWatchNotifyParams(_ params: OpenClawWatchNotifyParams) -> OpenClawWatchNotifyParams {
|
|
var normalized = params
|
|
normalized.title = params.title.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
normalized.body = params.body.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
normalized.promptId = self.trimmedOrNil(params.promptId)
|
|
normalized.sessionKey = self.trimmedOrNil(params.sessionKey)
|
|
normalized.gatewayStableID = self.trimmedOrNil(params.gatewayStableID)
|
|
normalized.kind = self.trimmedOrNil(params.kind)
|
|
normalized.details = self.trimmedOrNil(params.details)
|
|
normalized.priority = self.normalizedWatchPriority(params.priority, risk: params.risk)
|
|
normalized.risk = self.normalizedWatchRisk(params.risk, priority: normalized.priority)
|
|
|
|
let normalizedActions = self.normalizeWatchActions(
|
|
params.actions,
|
|
kind: normalized.kind,
|
|
promptId: normalized.promptId)
|
|
normalized.actions = normalizedActions.isEmpty ? nil : normalizedActions
|
|
return normalized
|
|
}
|
|
|
|
static func normalizeWatchActions(
|
|
_ actions: [OpenClawWatchAction]?,
|
|
kind: String?,
|
|
promptId: String?) -> [OpenClawWatchAction]
|
|
{
|
|
let provided = (actions ?? []).compactMap { action -> OpenClawWatchAction? in
|
|
let id = action.id.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
let label = action.label.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
guard !id.isEmpty, !label.isEmpty else { return nil }
|
|
return OpenClawWatchAction(
|
|
id: id,
|
|
label: label,
|
|
style: self.trimmedOrNil(action.style))
|
|
}
|
|
if !provided.isEmpty {
|
|
return Array(provided.prefix(4))
|
|
}
|
|
|
|
// Only auto-insert quick actions when this is a prompt/decision flow.
|
|
guard promptId?.isEmpty == false else {
|
|
return []
|
|
}
|
|
|
|
let normalizedKind = kind?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() ?? ""
|
|
if normalizedKind.contains("approval") || normalizedKind.contains("approve") {
|
|
return [
|
|
OpenClawWatchAction(id: "approve", label: "Approve"),
|
|
OpenClawWatchAction(id: "decline", label: "Decline", style: "destructive"),
|
|
OpenClawWatchAction(id: "open_phone", label: "Open iPhone"),
|
|
OpenClawWatchAction(id: "escalate", label: "Escalate"),
|
|
]
|
|
}
|
|
|
|
return [
|
|
OpenClawWatchAction(id: "done", label: "Done"),
|
|
OpenClawWatchAction(id: "snooze_10m", label: "Snooze 10m"),
|
|
OpenClawWatchAction(id: "open_phone", label: "Open iPhone"),
|
|
OpenClawWatchAction(id: "escalate", label: "Escalate"),
|
|
]
|
|
}
|
|
|
|
static func normalizedWatchRisk(
|
|
_ risk: OpenClawWatchRisk?,
|
|
priority: OpenClawNotificationPriority?) -> OpenClawWatchRisk?
|
|
{
|
|
if let risk { return risk }
|
|
switch priority {
|
|
case .passive:
|
|
return .low
|
|
case .active:
|
|
return .medium
|
|
case .timeSensitive:
|
|
return .high
|
|
case nil:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
static func normalizedWatchPriority(
|
|
_ priority: OpenClawNotificationPriority?,
|
|
risk: OpenClawWatchRisk?) -> OpenClawNotificationPriority?
|
|
{
|
|
if let priority { return priority }
|
|
switch risk {
|
|
case .low:
|
|
return .passive
|
|
case .medium:
|
|
return .active
|
|
case .high:
|
|
return .timeSensitive
|
|
case nil:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
static func trimmedOrNil(_ value: String?) -> String? {
|
|
let trimmed = value?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
return trimmed.isEmpty ? nil : trimmed
|
|
}
|
|
}
|