Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion App/Controllers/ServerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ final class ServerController: ObservableObject {
}

init() {
Task {
Task { [self] in
// Initialize bindings from AppStorage before the server starts.
await networkManager.updateServiceBindings(self.currentServiceBindings)
await networkManager.updateDisabledTools(self.disabledTools, generation: 0)
Expand Down
18 changes: 12 additions & 6 deletions App/Services/Capture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,14 @@ final class CaptureService: NSObject, Service {
captureSession.startRunning()

Task { @MainActor in
if delay > 0 {
try await Task.sleep(for: .seconds(delay))
do {
if delay > 0 { try await Task.sleep(for: .seconds(delay)) }
} catch {
timeoutTask.cancel()
captureSession.stopRunning()
self.currentPhotoDelegate = nil
await resumeOnce(.failure(error), nil)
return
}

let settings = AVCapturePhotoSettings()
Expand All @@ -291,7 +297,7 @@ final class CaptureService: NSObject, Service {
let delegate = PhotoCaptureDelegate(
format: format,
quality: quality,
completion: { [weak self] result in
completion: { [weak self = self] result in
Task { @MainActor in
timeoutTask.cancel()
captureSession.stopRunning()
Expand Down Expand Up @@ -384,10 +390,10 @@ final class CaptureService: NSObject, Service {

return try await withCheckedThrowingContinuation { continuation in
Task {
try await Task.sleep(for: .seconds(duration + 0.5))
recorder.stop()

defer { recorder.stop() }
do {
try await Task.sleep(for: .seconds(duration + 0.5))
recorder.stop()
let audioData = try Data(contentsOf: tempURL)
try FileManager.default.removeItem(at: tempURL)
let audioValue = Value.data(mimeType: format.mimeType, audioData)
Expand Down
4 changes: 2 additions & 2 deletions CLI/StdioProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ actor StdioProxy {

connection.start(queue: .main)

connection.stateUpdateHandler = { state in
connection.stateUpdateHandler = { [weak self] state in
Task { [weak self] in
await self?.handleConnectionState(state, continuation: nil, connectionState: nil)
}
Expand All @@ -55,7 +55,7 @@ actor StdioProxy {
try await withCheckedThrowingContinuation {
(continuation: CheckedContinuation<Void, Swift.Error>) in
let connectionState = ConnectionState()
connection.stateUpdateHandler = { state in
connection.stateUpdateHandler = { [weak self] state in
Task { [weak self] in
await self?.handleConnectionState(
state,
Expand Down