Files
openclaw/apps/macos/Sources/OpenClaw/QuickChatController+Testing.swift
Peter Steinberger 45f6543c9a feat(macos): Quick Chat power features — voice dictation, paste-to-app, model/reasoning control (#110994)
* feat(macos): add Quick Chat power features

* docs(macos): document Quick Chat power features

* chore(i18n): refresh native locale artifacts for Quick Chat power features

* fix(macos): update DEBUG test helper sendProvider to the reasoning-threaded arity
2026-07-18 17:21:03 -07:00

65 lines
2.3 KiB
Swift

import Foundation
import OpenClawProtocol
#if DEBUG
@MainActor
extension QuickChatController {
struct TestingSnapshot: Equatable {
let isVisible: Bool
let hasGlobalMonitor: Bool
let hasLocalMonitor: Bool
let hotkeyRegistered: Bool
let isEnabled: Bool
}
static func exerciseForTesting() -> [TestingSnapshot] {
let model = QuickChatModel(
sessionKeyProvider: { "main" },
agentsProvider: {
AgentsListResult(
defaultid: "main",
mainkey: "main",
scope: AnyCodable("per-agent"),
agents: [])
},
agentIdentityProvider: { _ in .placeholder },
sendProvider: { _, _, _, _, _, _ in "started" },
permissionStatusProvider: { capabilities in
Dictionary(uniqueKeysWithValues: capabilities.map { ($0, true) })
},
permissionGrantProvider: { capabilities in
Dictionary(uniqueKeysWithValues: capabilities.map { ($0, true) })
},
connectionGateProvider: { .available })
let controller = QuickChatController(
enableUI: false,
model: model,
monitoringEnabled: true,
globalMonitorInstaller: { _, _ in NSObject() },
localMonitorInstaller: { _, _ in NSObject() },
monitorClearer: { $0 = nil },
hotkeyRegistrar: { _ in },
hotkeyRemover: {},
allowsHotkeyRegistrationInTests: true)
controller.start()
controller.setEnabled(true)
let started = controller.testingSnapshot
controller.present()
let presented = controller.testingSnapshot
controller.setEnabled(false)
let disabled = controller.testingSnapshot
controller.stop()
return [started, presented, disabled, controller.testingSnapshot]
}
var testingSnapshot: TestingSnapshot {
TestingSnapshot(
isVisible: self.isVisible,
hasGlobalMonitor: self.hasGlobalMonitorForTesting,
hasLocalMonitor: self.hasLocalMonitorForTesting,
hotkeyRegistered: self.hotkeyRegisteredForTesting,
isEnabled: self.isEnabled)
}
}
#endif