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
17 changes: 0 additions & 17 deletions VoiceAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -122,7 +121,6 @@
ACFBA1DB2D8D5CBE0021202B /* Collections in Frameworks */,
B5E1B90F2D14E9EC00A38CB6 /* LiveKitComponents in Frameworks */,
B5E1B9122D14E9F500A38CB6 /* LiveKit in Frameworks */,
ACBC177A2D8C34B5007EE71F /* AsyncAlgorithms in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -228,7 +226,6 @@
packageProductDependencies = (
B5E1B90E2D14E9EC00A38CB6 /* LiveKitComponents */,
B5E1B9112D14E9F500A38CB6 /* LiveKit */,
ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */,
ACFBA1DA2D8D5CBE0021202B /* Collections */,
);
productName = VoiceAgent;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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" */;
Expand Down
2 changes: 1 addition & 1 deletion VoiceAgent/App/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class AppViewModel {
// MARK: - Constants

private enum Constants {
static let agentConnectionTimeout: TimeInterval = 10
static let agentConnectionTimeout: TimeInterval = 20
}

// MARK: - Errors
Expand Down
12 changes: 1 addition & 11 deletions VoiceAgent/Chat/ChatViewModel.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import AsyncAlgorithms
import Collections
import Foundation
import LiveKit
Expand All @@ -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<ReceivedMessage.ID, ReceivedMessage> = [:]
Expand Down Expand Up @@ -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)
}
Expand Down
21 changes: 9 additions & 12 deletions VoiceAgent/Chat/View/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,8 +32,6 @@ struct ChatView: View {
}
}
.upsideDown()
.listRowBackground(EmptyView())
.listRowSeparator(.hidden)
.id(message.id) // for the ScrollViewReader to work
}

Expand Down
Loading