feat: consolidate iOS with API and web preserving history
Rebuild & Deploy / rebuild (push) Failing after 23s
Rebuild & Deploy / rebuild (push) Failing after 23s
This commit is contained in:
commit
d735ee72fa
102 files changed
+13077
-258
No files matched your search
@@ -0,0 +1,89 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ConnectionTestView: View {
|
||||
@ObservedObject var settings: SettingsStore
|
||||
var bearerToken: String = ""
|
||||
@State private var isBusy = false
|
||||
@State private var result: Result<TokenResponse, Error>?
|
||||
@State private var urlError: String?
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section("Server") {
|
||||
LabeledContent("URL") {
|
||||
Text(settings.trimmedServerURL)
|
||||
.font(.footnote.monospaced())
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
if let urlError {
|
||||
Label(urlError, systemImage: "xmark.octagon")
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
}
|
||||
Section {
|
||||
Button(action: runTest) {
|
||||
HStack {
|
||||
Spacer()
|
||||
if isBusy {
|
||||
ProgressView()
|
||||
} else {
|
||||
Text("Test connection")
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.disabled(isBusy || settings.trimmedServerURL.isEmpty)
|
||||
}
|
||||
if let result {
|
||||
switch result {
|
||||
case .success(let response):
|
||||
Section("Server access verified") {
|
||||
LabeledContent("Room") {
|
||||
Text(response.room)
|
||||
.font(.footnote.monospaced())
|
||||
}
|
||||
LabeledContent("User") {
|
||||
Text(response.user.displayName ?? response.user.id)
|
||||
}
|
||||
Label("Account access and session setup verified. This does not test microphone permission, secure voice transport, or spoken replies.", systemImage: "checkmark.circle")
|
||||
.foregroundStyle(.green)
|
||||
Text("Start a conversation to verify live voice and replies.").font(.footnote).foregroundStyle(.secondary)
|
||||
}
|
||||
case .failure(let error):
|
||||
Section("Error") {
|
||||
Label(error.localizedDescription, systemImage: "xmark.octagon")
|
||||
.foregroundStyle(.red)
|
||||
.font(.footnote)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Connection test")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
private func runTest() {
|
||||
result = nil
|
||||
urlError = nil
|
||||
switch ServerConfig.parse(settings.trimmedServerURL) {
|
||||
case .success(let config):
|
||||
isBusy = true
|
||||
Task {
|
||||
let client = TokenClient(config: config, bearerToken: bearerToken)
|
||||
do {
|
||||
let response = try await client.fetchToken()
|
||||
result = .success(response)
|
||||
} catch {
|
||||
result = .failure(error)
|
||||
}
|
||||
isBusy = false
|
||||
}
|
||||
case .failure(let error):
|
||||
urlError = error.localizedDescription
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ConnectionTestView(settings: SettingsStore())
|
||||
}
|
||||
Reference in new issue
Block a user