fix: close Nearlight release blockers

This commit is contained in:
snowspeeder committed 2026-09-12 10:13:14 -04:00
1 parent 5577162594
commit b7cec80a99
7 files changed
+310 -179

No files matched your search

+12 -21
View File
@@ -12,12 +12,9 @@ struct SettingsView: View {
@State private var urlText: String = ""
@State private var urlError: String?
@State private var showVoicePicker = false
@State private var urlJustSaved = false
@State private var savedURLConfirmation: String?
@State private var showModelPicker = false
@FocusState private var urlFocused: Bool
@State private var applyingTrim = false
/// Guards the success-trim against the edit observer (N3).
init(settings: SettingsStore, session: VoiceSession) {
self.settings = settings
self.session = session
@@ -73,17 +70,15 @@ struct SettingsView: View {
.accessibilityLabel("Server URL")
.focused($urlFocused)
.onAppear { urlText = settings.serverURL }
.onChange(of: urlText) { oldValue, newValue in
// A programmatic normalization on successful Save must
// not erase its own confirmation; only user edits do.
guard applyingTrim == false else { return }
if newValue != oldValue {
urlJustSaved = false
urlError = nil
}
.onChange(of: urlText) { _, newValue in
// Keep confirmation across the asynchronous onChange
// caused by successful whitespace normalization.
guard newValue != savedURLConfirmation else { return }
savedURLConfirmation = nil
urlError = nil
}
.overlay(alignment: .trailing) {
if urlJustSaved {
if savedURLConfirmation != nil {
Image(systemName: "checkmark.circle")
.foregroundStyle(Nearlight.quiet)
.padding(.trailing, 8)
@@ -95,7 +90,7 @@ struct SettingsView: View {
.font(.footnote)
.foregroundStyle(Nearlight.alert)
.accessibilityIdentifier("settings.server.error")
} else if urlJustSaved {
} else if savedURLConfirmation != nil {
Text("Server address saved.")
.font(.footnote)
.foregroundStyle(Nearlight.quiet)
@@ -135,7 +130,7 @@ struct SettingsView: View {
/// left untouched so the active session keeps using its original URL.
/// Guarded: only applies when the session is idle (no active call).
private func applyServerURL() {
urlJustSaved = false
savedURLConfirmation = nil
guard canApplyServerURL else {
urlError = "End the conversation before changing servers."
return
@@ -148,13 +143,9 @@ struct SettingsView: View {
switch ServerConfig.parse(trimmed) {
case .success:
settings.serverURL = trimmed
if trimmed != urlText {
applyingTrim = true
urlText = trimmed
applyingTrim = false
}
urlText = trimmed
urlError = nil
urlJustSaved = true
savedURLConfirmation = trimmed
urlFocused = false
case .failure(let error):
urlError = error.localizedDescription