Skip to content

Commit a7d531e

Browse files
authored
Transcription fixes (#28)
- Timeout to 20s - Fixes the last segment missing thing - the root cause is probably timing vs `throttle` which is not strictly necessary and may break in SwiftUI environment anyway - (Optional) Changes `List` → `LazyVStack` - nicer animations, the performance penalty should be negligible - fixes macOS "overlapping bubbles" issue ![Screenshot 2025-08-22 at 09 00 22 Small](https://github.com/user-attachments/assets/2ba755f1-5da6-4069-b5d0-2402e7d3eaae)
1 parent c8acf55 commit a7d531e

File tree

4 files changed

+11
-41
lines changed

4 files changed

+11
-41
lines changed

VoiceAgent.xcodeproj/project.pbxproj

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
ACAEBA5B2DE6EE970072E93E /* ReplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ACAEBA5A2DE6EE970072E93E /* ReplayKit.framework */; };
1111
ACAEBA622DE6EE970072E93E /* BroadcastExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = ACAEBA582DE6EE970072E93E /* BroadcastExtension.appex */; platformFilters = (ios, xros, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
1212
ACAEBA692DE6EF4B0072E93E /* LiveKit in Frameworks */ = {isa = PBXBuildFile; productRef = ACAEBA682DE6EF4B0072E93E /* LiveKit */; };
13-
ACBC177A2D8C34B5007EE71F /* AsyncAlgorithms in Frameworks */ = {isa = PBXBuildFile; productRef = ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */; };
1413
ACFBA1DB2D8D5CBE0021202B /* Collections in Frameworks */ = {isa = PBXBuildFile; productRef = ACFBA1DA2D8D5CBE0021202B /* Collections */; };
1514
B5E1B90F2D14E9EC00A38CB6 /* LiveKitComponents in Frameworks */ = {isa = PBXBuildFile; productRef = B5E1B90E2D14E9EC00A38CB6 /* LiveKitComponents */; };
1615
B5E1B9122D14E9F500A38CB6 /* LiveKit in Frameworks */ = {isa = PBXBuildFile; productRef = B5E1B9112D14E9F500A38CB6 /* LiveKit */; };
@@ -122,7 +121,6 @@
122121
ACFBA1DB2D8D5CBE0021202B /* Collections in Frameworks */,
123122
B5E1B90F2D14E9EC00A38CB6 /* LiveKitComponents in Frameworks */,
124123
B5E1B9122D14E9F500A38CB6 /* LiveKit in Frameworks */,
125-
ACBC177A2D8C34B5007EE71F /* AsyncAlgorithms in Frameworks */,
126124
);
127125
runOnlyForDeploymentPostprocessing = 0;
128126
};
@@ -228,7 +226,6 @@
228226
packageProductDependencies = (
229227
B5E1B90E2D14E9EC00A38CB6 /* LiveKitComponents */,
230228
B5E1B9112D14E9F500A38CB6 /* LiveKit */,
231-
ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */,
232229
ACFBA1DA2D8D5CBE0021202B /* Collections */,
233230
);
234231
productName = VoiceAgent;
@@ -269,7 +266,6 @@
269266
packageReferences = (
270267
B5E1B90D2D14E9EC00A38CB6 /* XCRemoteSwiftPackageReference "components-swift" */,
271268
B5E1B9102D14E9F500A38CB6 /* XCRemoteSwiftPackageReference "client-sdk-swift" */,
272-
ACBC17782D8C34B5007EE71F /* XCRemoteSwiftPackageReference "swift-async-algorithms" */,
273269
ACFBA1D92D8D5CBE0021202B /* XCRemoteSwiftPackageReference "swift-collections" */,
274270
);
275271
preferredProjectObjectVersion = 77;
@@ -723,14 +719,6 @@
723719
/* End XCConfigurationList section */
724720

725721
/* Begin XCRemoteSwiftPackageReference section */
726-
ACBC17782D8C34B5007EE71F /* XCRemoteSwiftPackageReference "swift-async-algorithms" */ = {
727-
isa = XCRemoteSwiftPackageReference;
728-
repositoryURL = "https://github.com/apple/swift-async-algorithms.git";
729-
requirement = {
730-
kind = upToNextMajorVersion;
731-
minimumVersion = 1.0.3;
732-
};
733-
};
734722
ACFBA1D92D8D5CBE0021202B /* XCRemoteSwiftPackageReference "swift-collections" */ = {
735723
isa = XCRemoteSwiftPackageReference;
736724
repositoryURL = "https://github.com/apple/swift-collections";
@@ -762,11 +750,6 @@
762750
isa = XCSwiftPackageProductDependency;
763751
productName = LiveKit;
764752
};
765-
ACBC17792D8C34B5007EE71F /* AsyncAlgorithms */ = {
766-
isa = XCSwiftPackageProductDependency;
767-
package = ACBC17782D8C34B5007EE71F /* XCRemoteSwiftPackageReference "swift-async-algorithms" */;
768-
productName = AsyncAlgorithms;
769-
};
770753
ACFBA1DA2D8D5CBE0021202B /* Collections */ = {
771754
isa = XCSwiftPackageProductDependency;
772755
package = ACFBA1D92D8D5CBE0021202B /* XCRemoteSwiftPackageReference "swift-collections" */;

VoiceAgent/App/AppViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class AppViewModel {
1414
// MARK: - Constants
1515

1616
private enum Constants {
17-
static let agentConnectionTimeout: TimeInterval = 10
17+
static let agentConnectionTimeout: TimeInterval = 20
1818
}
1919

2020
// MARK: - Errors

VoiceAgent/Chat/ChatViewModel.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import AsyncAlgorithms
21
import Collections
32
import Foundation
43
import LiveKit
@@ -11,12 +10,6 @@ import Observation
1110
@MainActor
1211
@Observable
1312
final class ChatViewModel {
14-
// MARK: - Constants
15-
16-
private enum Constants {
17-
static let throttle: Duration = .milliseconds(100)
18-
}
19-
2013
// MARK: - State
2114

2215
private(set) var messages: OrderedDictionary<ReceivedMessage.ID, ReceivedMessage> = [:]
@@ -45,10 +38,7 @@ final class ChatViewModel {
4538
for messageReceiver in messageReceivers {
4639
Task { [weak self] in
4740
do {
48-
for await message in try await messageReceiver
49-
.messages()
50-
._throttle(for: Constants.throttle)
51-
{
41+
for await message in try await messageReceiver.messages() {
5242
guard let self else { return }
5343
messages.updateValue(message, forKey: message.id)
5444
}

VoiceAgent/Chat/View/ChatView.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ struct ChatView: View {
66

77
var body: some View {
88
ScrollViewReader { scrollView in
9-
List {
10-
ForEach(viewModel.messages.values.reversed(), content: message)
9+
ScrollView {
10+
LazyVStack {
11+
ForEach(viewModel.messages.values.reversed(), content: message)
12+
}
1113
}
1214
.onChange(of: viewModel.messages.count) {
13-
withAnimation(.smooth) {
14-
scrollView.scrollTo(viewModel.messages.keys.last)
15-
}
15+
scrollView.scrollTo(viewModel.messages.keys.last)
1616
}
17+
.upsideDown()
18+
.padding(.horizontal)
19+
.scrollIndicators(.never)
20+
.animation(.default, value: viewModel.messages)
1721
}
18-
.upsideDown()
19-
.listStyle(.plain)
20-
.scrollIndicators(.never)
21-
.scrollContentBackground(.hidden)
22-
.animation(.default, value: viewModel.messages)
2322
}
2423

2524
@ViewBuilder
@@ -33,8 +32,6 @@ struct ChatView: View {
3332
}
3433
}
3534
.upsideDown()
36-
.listRowBackground(EmptyView())
37-
.listRowSeparator(.hidden)
3835
.id(message.id) // for the ScrollViewReader to work
3936
}
4037

0 commit comments

Comments
 (0)