diff --git a/VoiceAgent.xcodeproj/project.pbxproj b/VoiceAgent.xcodeproj/project.pbxproj index 69f4a2d..48c0ef8 100644 --- a/VoiceAgent.xcodeproj/project.pbxproj +++ b/VoiceAgent.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ ACAEBA5B2DE6EE970072E93E /* ReplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACAEBA5A2DE6EE970072E93E /* ReplayKit.framework */; }; ACAEBA622DE6EE970072E93E /* BroadcastExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = ACAEBA582DE6EE970072E93E /* BroadcastExtension.appex */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; ACAEBA692DE6EF4B0072E93E /* LiveKit in Frameworks */ = {isa = PBXBuildFile; productRef = ACAEBA682DE6EF4B0072E93E /* LiveKit */; }; - ACBC177A2D8C34B5007EE71F /* AsyncAlgorithms in Frameworks */ = {isa = PBXBuildFile; productRef = ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */; }; ACFBA1DB2D8D5CBE0021202B /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = ACFBA1DA2D8D5CBE0021202B /* Collections */; }; B5E1B90F2D14E9EC00A38CB6 /* LiveKitComponents in Frameworks */ = {isa = PBXBuildFile; productRef = B5E1B90E2D14E9EC00A38CB6 /* LiveKitComponents */; }; B5E1B9122D14E9F500A38CB6 /* LiveKit in Frameworks */ = {isa = PBXBuildFile; productRef = B5E1B9112D14E9F500A38CB6 /* LiveKit */; }; @@ -122,7 +121,6 @@ ACFBA1DB2D8D5CBE0021202B /* Collections in Frameworks */, B5E1B90F2D14E9EC00A38CB6 /* LiveKitComponents in Frameworks */, B5E1B9122D14E9F500A38CB6 /* LiveKit in Frameworks */, - ACBC177A2D8C34B5007EE71F /* AsyncAlgorithms in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -228,7 +226,6 @@ packageProductDependencies = ( B5E1B90E2D14E9EC00A38CB6 /* LiveKitComponents */, B5E1B9112D14E9F500A38CB6 /* LiveKit */, - ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */, ACFBA1DA2D8D5CBE0021202B /* Collections */, ); productName = VoiceAgent; @@ -269,7 +266,6 @@ packageReferences = ( B5E1B90D2D14E9EC00A38CB6 /* XCRemoteSwiftPackageReference "components-swift" */, B5E1B9102D14E9F500A38CB6 /* XCRemoteSwiftPackageReference "client-sdk-swift" */, - ACBC17782D8C34B5007EE71F /* XCRemoteSwiftPackageReference "swift-async-algorithms" */, ACFBA1D92D8D5CBE0021202B /* XCRemoteSwiftPackageReference "swift-collections" */, ); preferredProjectObjectVersion = 77; @@ -723,14 +719,6 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - ACBC17782D8C34B5007EE71F /* XCRemoteSwiftPackageReference "swift-async-algorithms" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/apple/swift-async-algorithms.git"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.0.3; - }; - }; ACFBA1D92D8D5CBE0021202B /* XCRemoteSwiftPackageReference "swift-collections" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/apple/swift-collections"; @@ -762,11 +750,6 @@ isa = XCSwiftPackageProductDependency; productName = LiveKit; }; - ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */ = { - isa = XCSwiftPackageProductDependency; - package = ACBC17782D8C34B5007EE71F /* XCRemoteSwiftPackageReference "swift-async-algorithms" */; - productName = AsyncAlgorithms; - }; ACFBA1DA2D8D5CBE0021202B /* Collections */ = { isa = XCSwiftPackageProductDependency; package = ACFBA1D92D8D5CBE0021202B /* XCRemoteSwiftPackageReference "swift-collections" */; diff --git a/VoiceAgent/App/AppViewModel.swift b/VoiceAgent/App/AppViewModel.swift index 1aa5641..93d6246 100644 --- a/VoiceAgent/App/AppViewModel.swift +++ b/VoiceAgent/App/AppViewModel.swift @@ -14,7 +14,7 @@ final class AppViewModel { // MARK: - Constants private enum Constants { - static let agentConnectionTimeout: TimeInterval = 10 + static let agentConnectionTimeout: TimeInterval = 20 } // MARK: - Errors diff --git a/VoiceAgent/Chat/ChatViewModel.swift b/VoiceAgent/Chat/ChatViewModel.swift index ed72170..bc32665 100644 --- a/VoiceAgent/Chat/ChatViewModel.swift +++ b/VoiceAgent/Chat/ChatViewModel.swift @@ -1,4 +1,3 @@ -import AsyncAlgorithms import Collections import Foundation import LiveKit @@ -11,12 +10,6 @@ import Observation @MainActor @Observable final class ChatViewModel { - // MARK: - Constants - - private enum Constants { - static let throttle: Duration = .milliseconds(100) - } - // MARK: - State private(set) var messages: OrderedDictionary = [:] @@ -45,10 +38,7 @@ final class ChatViewModel { for messageReceiver in messageReceivers { Task { [weak self] in do { - for await message in try await messageReceiver - .messages() - ._throttle(for: Constants.throttle) - { + for await message in try await messageReceiver.messages() { guard let self else { return } messages.updateValue(message, forKey: message.id) } diff --git a/VoiceAgent/Chat/View/ChatView.swift b/VoiceAgent/Chat/View/ChatView.swift index 1b53700..8a723b0 100644 --- a/VoiceAgent/Chat/View/ChatView.swift +++ b/VoiceAgent/Chat/View/ChatView.swift @@ -6,20 +6,19 @@ struct ChatView: View { var body: some View { ScrollViewReader { scrollView in - List { - ForEach(viewModel.messages.values.reversed(), content: message) + ScrollView { + LazyVStack { + ForEach(viewModel.messages.values.reversed(), content: message) + } } .onChange(of: viewModel.messages.count) { - withAnimation(.smooth) { - scrollView.scrollTo(viewModel.messages.keys.last) - } + scrollView.scrollTo(viewModel.messages.keys.last) } + .upsideDown() + .padding(.horizontal) + .scrollIndicators(.never) + .animation(.default, value: viewModel.messages) } - .upsideDown() - .listStyle(.plain) - .scrollIndicators(.never) - .scrollContentBackground(.hidden) - .animation(.default, value: viewModel.messages) } @ViewBuilder @@ -33,8 +32,6 @@ struct ChatView: View { } } .upsideDown() - .listRowBackground(EmptyView()) - .listRowSeparator(.hidden) .id(message.id) // for the ScrollViewReader to work }