style(macos): swiftformat sources
This commit is contained in:
@@ -157,7 +157,10 @@ struct AnthropicAuthControls: View {
|
||||
}
|
||||
|
||||
do {
|
||||
let creds = try await AnthropicOAuth.exchangeCode(code: parsed.code, state: parsed.state, verifier: pkce.verifier)
|
||||
let creds = try await AnthropicOAuth.exchangeCode(
|
||||
code: parsed.code,
|
||||
state: parsed.state,
|
||||
verifier: pkce.verifier)
|
||||
try PiOAuthStore.saveAnthropicOAuth(creds)
|
||||
self.refresh()
|
||||
self.pkce = nil
|
||||
|
||||
@@ -57,4 +57,3 @@ enum AnthropicOAuthCodeState {
|
||||
return String(text[full])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ actor CameraCaptureService {
|
||||
|
||||
private nonisolated static func clampDurationMs(_ ms: Int?) -> Int {
|
||||
let v = ms ?? 3000
|
||||
return min(60_000, max(250, v))
|
||||
return min(60000, max(250, v))
|
||||
}
|
||||
|
||||
private nonisolated static func exportToMP4(inputURL: URL, outputURL: URL) async throws {
|
||||
|
||||
@@ -4,7 +4,6 @@ import Foundation
|
||||
import OSLog
|
||||
|
||||
enum ControlRequestHandler {
|
||||
|
||||
struct NodeListNode: Codable {
|
||||
var nodeId: String
|
||||
var displayName: String?
|
||||
@@ -559,7 +558,7 @@ enum ControlRequestHandler {
|
||||
let payload = try await self.invokeLocalNode(
|
||||
command: "screen.record",
|
||||
params: params,
|
||||
timeoutMs: 120000)
|
||||
timeoutMs: 120_000)
|
||||
guard let dict = payload as? [String: Any],
|
||||
let base64 = dict["base64"] as? String,
|
||||
let data = Data(base64Encoded: base64)
|
||||
|
||||
@@ -182,7 +182,9 @@ final class HoverHUDController {
|
||||
|
||||
private func targetFrame() -> NSRect {
|
||||
guard let anchor = self.anchorProvider?() else {
|
||||
return WindowPlacement.topRightFrame(size: NSSize(width: self.width, height: self.height), padding: self.padding)
|
||||
return WindowPlacement.topRightFrame(
|
||||
size: NSSize(width: self.width, height: self.height),
|
||||
padding: self.padding)
|
||||
}
|
||||
|
||||
let screen = NSScreen.screens.first { screen in
|
||||
@@ -213,7 +215,11 @@ final class HoverHUDController {
|
||||
|
||||
private func installDismissMonitor() {
|
||||
guard self.dismissMonitor == nil, let window else { return }
|
||||
self.dismissMonitor = NSEvent.addGlobalMonitorForEvents(matching: [.leftMouseDown, .rightMouseDown, .otherMouseDown]) { [weak self] _ in
|
||||
self.dismissMonitor = NSEvent.addGlobalMonitorForEvents(matching: [
|
||||
.leftMouseDown,
|
||||
.rightMouseDown,
|
||||
.otherMouseDown,
|
||||
]) { [weak self] _ in
|
||||
guard let self, self.model.isVisible else { return }
|
||||
let pt = NSEvent.mouseLocation
|
||||
if !window.frame.contains(pt) {
|
||||
|
||||
@@ -186,7 +186,7 @@ actor MacNodeBridgePairingClient {
|
||||
}
|
||||
defer { timeout.cancel() }
|
||||
return try await withTaskCancellationHandler(operation: {
|
||||
return try await task.value
|
||||
try await task.value
|
||||
}, onCancel: {
|
||||
timeout.cancel()
|
||||
})
|
||||
|
||||
@@ -271,8 +271,8 @@ actor MacNodeBridgeSession {
|
||||
}
|
||||
|
||||
private static func makeStateStream(
|
||||
for connection: NWConnection,
|
||||
) -> AsyncStream<NWConnection.State> {
|
||||
for connection: NWConnection) -> AsyncStream<NWConnection.State>
|
||||
{
|
||||
AsyncStream { continuation in
|
||||
connection.stateUpdateHandler = { state in
|
||||
continuation.yield(state)
|
||||
@@ -288,9 +288,9 @@ actor MacNodeBridgeSession {
|
||||
|
||||
private static func waitForReady(
|
||||
_ stream: AsyncStream<NWConnection.State>,
|
||||
timeoutSeconds: Double,
|
||||
) async throws {
|
||||
try await withTimeout(seconds: timeoutSeconds) {
|
||||
timeoutSeconds: Double) async throws
|
||||
{
|
||||
try await self.withTimeout(seconds: timeoutSeconds) {
|
||||
for await state in stream {
|
||||
switch state {
|
||||
case .ready:
|
||||
@@ -313,8 +313,8 @@ actor MacNodeBridgeSession {
|
||||
|
||||
private static func withTimeout<T: Sendable>(
|
||||
seconds: Double,
|
||||
operation: @escaping @Sendable () async throws -> T,
|
||||
) async throws -> T {
|
||||
operation: @escaping @Sendable () async throws -> T) async throws -> T
|
||||
{
|
||||
let task = Task { try await operation() }
|
||||
let timeout = Task {
|
||||
try await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))
|
||||
@@ -322,7 +322,7 @@ actor MacNodeBridgeSession {
|
||||
}
|
||||
defer { timeout.cancel() }
|
||||
return try await withTaskCancellationHandler(operation: {
|
||||
return try await task.value
|
||||
try await task.value
|
||||
}, onCancel: {
|
||||
timeout.cancel()
|
||||
})
|
||||
|
||||
@@ -185,15 +185,15 @@ final class MacNodeModeCoordinator {
|
||||
var continuation: CheckedContinuation<NWEndpoint?, Never>?
|
||||
|
||||
func finish(_ endpoint: NWEndpoint?) {
|
||||
lock.lock()
|
||||
self.lock.lock()
|
||||
defer { lock.unlock() }
|
||||
if resolved { return }
|
||||
resolved = true
|
||||
for browser in browsers {
|
||||
if self.resolved { return }
|
||||
self.resolved = true
|
||||
for browser in self.browsers {
|
||||
browser.cancel()
|
||||
}
|
||||
continuation?.resume(returning: endpoint)
|
||||
continuation = nil
|
||||
self.continuation?.resume(returning: endpoint)
|
||||
self.continuation = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,11 +239,11 @@ enum MacNodeTokenStore {
|
||||
}
|
||||
|
||||
static func loadToken() -> String? {
|
||||
let raw = defaults.string(forKey: tokenKey)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let raw = self.defaults.string(forKey: self.tokenKey)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return raw?.isEmpty == false ? raw : nil
|
||||
}
|
||||
|
||||
static func saveToken(_ token: String) {
|
||||
defaults.set(token, forKey: tokenKey)
|
||||
self.defaults.set(token, forKey: self.tokenKey)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ actor MacNodeRuntime {
|
||||
|
||||
func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse {
|
||||
let command = req.command
|
||||
if (command.hasPrefix("canvas.") || command.hasPrefix("canvas.a2ui.")) && !Self.canvasEnabled() {
|
||||
if command.hasPrefix("canvas.") || command.hasPrefix("canvas.a2ui."), !Self.canvasEnabled() {
|
||||
return BridgeInvokeResponse(
|
||||
id: req.id,
|
||||
ok: false,
|
||||
@@ -199,7 +199,7 @@ actor MacNodeRuntime {
|
||||
let ready = try await CanvasManager.shared.eval(sessionKey: "main", javaScript: """
|
||||
(() => Boolean(globalThis.clawdisA2UI))
|
||||
""")
|
||||
if ready != "true" && ready != "true\n" {
|
||||
if ready != "true", ready != "true\n" {
|
||||
return Self.errorResponse(req, code: .unavailable, message: "A2UI not ready")
|
||||
}
|
||||
|
||||
@@ -332,10 +332,11 @@ actor MacNodeRuntime {
|
||||
|
||||
let out = NSImage(size: target)
|
||||
out.lockFocus()
|
||||
image.draw(in: NSRect(origin: .zero, size: target),
|
||||
from: NSRect(origin: .zero, size: size),
|
||||
operation: .copy,
|
||||
fraction: 1.0)
|
||||
image.draw(
|
||||
in: NSRect(origin: .zero, size: target),
|
||||
from: NSRect(origin: .zero, size: size),
|
||||
operation: .copy,
|
||||
fraction: 1.0)
|
||||
out.unlockFocus()
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import Foundation
|
||||
import OSLog
|
||||
import UserNotifications
|
||||
|
||||
struct NodePairingReconcilePolicy {
|
||||
static let activeIntervalMs: UInt64 = 15_000
|
||||
enum NodePairingReconcilePolicy {
|
||||
static let activeIntervalMs: UInt64 = 15000
|
||||
static let resyncDelayMs: UInt64 = 250
|
||||
|
||||
static func shouldPoll(pendingCount: Int, isPresenting: Bool) -> Bool {
|
||||
@@ -522,7 +522,7 @@ final class NodePairingApprovalPrompter {
|
||||
defer { model.stop() }
|
||||
|
||||
let deadline = Date().addingTimeInterval(5.0)
|
||||
while model.masters.isEmpty && Date() < deadline {
|
||||
while model.masters.isEmpty, Date() < deadline {
|
||||
try? await Task.sleep(nanoseconds: 200_000_000)
|
||||
}
|
||||
|
||||
|
||||
@@ -488,7 +488,10 @@ struct OnboardingView: View {
|
||||
}
|
||||
|
||||
do {
|
||||
let creds = try await AnthropicOAuth.exchangeCode(code: parsed.code, state: parsed.state, verifier: pkce.verifier)
|
||||
let creds = try await AnthropicOAuth.exchangeCode(
|
||||
code: parsed.code,
|
||||
state: parsed.state,
|
||||
verifier: pkce.verifier)
|
||||
try PiOAuthStore.saveAnthropicOAuth(creds)
|
||||
self.refreshAnthropicOAuthStatus()
|
||||
self.anthropicAuthStatus = "Connected. Pi can now use Claude."
|
||||
|
||||
@@ -98,8 +98,8 @@ final class ScreenRecordService {
|
||||
}
|
||||
|
||||
private nonisolated static func clampDurationMs(_ ms: Int?) -> Int {
|
||||
let v = ms ?? 10_000
|
||||
return min(60_000, max(250, v))
|
||||
let v = ms ?? 10000
|
||||
return min(60000, max(250, v))
|
||||
}
|
||||
|
||||
private nonisolated static func clampFps(_ fps: Double?) -> Double {
|
||||
@@ -144,8 +144,8 @@ private final class StreamRecorder: NSObject, SCStreamOutput, SCStreamDelegate,
|
||||
let audioSettings: [String: Any] = [
|
||||
AVFormatIDKey: kAudioFormatMPEG4AAC,
|
||||
AVNumberOfChannelsKey: 1,
|
||||
AVSampleRateKey: 44_100,
|
||||
AVEncoderBitRateKey: 96_000,
|
||||
AVSampleRateKey: 44100,
|
||||
AVEncoderBitRateKey: 96000,
|
||||
]
|
||||
let audioInput = AVAssetWriterInput(mediaType: .audio, outputSettings: audioSettings)
|
||||
audioInput.expectsMediaDataInRealTime = true
|
||||
@@ -247,9 +247,13 @@ private final class StreamRecorder: NSObject, SCStreamOutput, SCStreamDelegate,
|
||||
self.audioInput?.markAsFinished()
|
||||
self.writer.finishWriting {
|
||||
if let err = self.writer.error {
|
||||
cont.resume(throwing: ScreenRecordService.ScreenRecordError.writeFailed(err.localizedDescription))
|
||||
cont
|
||||
.resume(throwing: ScreenRecordService.ScreenRecordError
|
||||
.writeFailed(err.localizedDescription))
|
||||
} else if self.writer.status != .completed {
|
||||
cont.resume(throwing: ScreenRecordService.ScreenRecordError.writeFailed("Failed to finalize video"))
|
||||
cont
|
||||
.resume(throwing: ScreenRecordService.ScreenRecordError
|
||||
.writeFailed("Failed to finalize video"))
|
||||
} else {
|
||||
cont.resume()
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ struct ClawdisCLI {
|
||||
let multiplier: Double = switch unit {
|
||||
case "ms": 1
|
||||
case "s": 1000
|
||||
case "m": 60_000
|
||||
case "m": 60000
|
||||
default: 1
|
||||
}
|
||||
|
||||
@@ -1009,7 +1009,7 @@ struct ClawdisCLI {
|
||||
let ms = durationMs ?? 3000
|
||||
return min(180, max(10, TimeInterval(ms) / 1000.0 + 10))
|
||||
case let .screenRecord(_, durationMs, _, _, _):
|
||||
let ms = durationMs ?? 10_000
|
||||
let ms = durationMs ?? 10000
|
||||
return min(180, max(10, TimeInterval(ms) / 1000.0 + 10))
|
||||
default:
|
||||
// Fail-fast so callers (incl. SSH tool calls) don't hang forever.
|
||||
|
||||
Reference in New Issue
Block a user