Skip to content

Commit b329d36

Browse files
committed
Errors
1 parent 7d61954 commit b329d36

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

VoiceAgent/App/AppView.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ struct AppView: View {
2222
.environment(\.namespace, namespace)
2323
#if os(visionOS)
2424
.ornament(attachmentAnchor: .scene(.bottom)) {
25-
if session.isReady {
25+
if session.isConnected {
2626
ControlBar(chat: $chat)
2727
.glassBackgroundEffect()
2828
}
2929
}
3030
.alert("warning.reconnecting", isPresented: .constant(session.connectionState == .reconnecting)) {}
3131
.alert(session.error?.localizedDescription ?? "error.title", isPresented: .constant(session.error != nil)) {
32-
Button("error.ok") { session.resetError() }
32+
Button("error.ok") { session.dismissError() }
33+
}
34+
.alert(session.agent.error?.localizedDescription ?? "error.title", isPresented: .constant(session.agent.error != nil)) {
35+
Button("error.ok") { Task { await session.end() } }
36+
}
37+
.alert(localMedia.error?.localizedDescription ?? "error.title", isPresented: .constant(localMedia.error != nil)) {
38+
Button("error.ok") { localMedia.dismissError() }
3339
}
3440
#else
3541
.safeAreaInset(edge: .bottom) {
@@ -43,8 +49,10 @@ struct AppView: View {
4349
.animation(.default, value: chat)
4450
.animation(.default, value: session.isConnected)
4551
.animation(.default, value: session.error?.localizedDescription)
52+
.animation(.default, value: session.agent.error?.localizedDescription)
4653
.animation(.default, value: localMedia.isCameraEnabled)
4754
.animation(.default, value: localMedia.isScreenShareEnabled)
55+
.animation(.default, value: localMedia.error?.localizedDescription)
4856
#if os(iOS)
4957
.sensoryFeedback(.impact, trigger: session.agent.agentState) { $0 == nil && $1 == .listening }
5058
#endif
@@ -87,7 +95,15 @@ struct AppView: View {
8795
}
8896

8997
if let error = session.error {
90-
ErrorView(error: error) { session.resetError() }
98+
ErrorView(error: error) { session.dismissError() }
99+
}
100+
101+
if let agentError = session.agent.error {
102+
ErrorView(error: agentError) { Task { await session.end() }}
103+
}
104+
105+
if let mediaError = localMedia.error {
106+
ErrorView(error: mediaError) { localMedia.dismissError() }
91107
}
92108
#endif
93109
}

0 commit comments

Comments
 (0)