Skip to content

Commit 904bbb0

Browse files
committed
Errors
1 parent 7d61954 commit 904bbb0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

VoiceAgent/App/AppView.swift

Lines changed: 17 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) {
@@ -87,7 +93,15 @@ struct AppView: View {
8793
}
8894

8995
if let error = session.error {
90-
ErrorView(error: error) { session.resetError() }
96+
ErrorView(error: error) { session.dismissError() }
97+
}
98+
99+
if let agentError = session.agent.error {
100+
ErrorView(error: agentError) { Task { await session.end() }}
101+
}
102+
103+
if let mediaError = localMedia.error {
104+
ErrorView(error: mediaError) { localMedia.dismissError() }
91105
}
92106
#endif
93107
}

0 commit comments

Comments
 (0)