macos: show detailed health failure

This commit is contained in:
Peter Steinberger
2025-12-08 23:20:02 +00:00
parent 594e837440
commit 04b34adec6
2 changed files with 43 additions and 8 deletions

View File

@@ -330,14 +330,34 @@ private enum RemoteStatus: Equatable {
extension GeneralSettings {
private var healthRow: some View {
HStack(spacing: 10) {
Circle()
.fill(self.healthStore.state.tint)
.frame(width: 10, height: 10)
Text(self.healthStore.summaryLine)
.font(.callout)
.lineLimit(1)
.frame(maxWidth: .infinity, alignment: .leading)
VStack(alignment: .leading, spacing: 6) {
HStack(spacing: 10) {
Circle()
.fill(self.healthStore.state.tint)
.frame(width: 10, height: 10)
Text(self.healthStore.summaryLine)
.font(.callout)
.frame(maxWidth: .infinity, alignment: .leading)
}
if let detail = self.healthStore.detailLine {
Text(detail)
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
HStack(spacing: 10) {
Button("Retry now") {
Task { await HealthStore.shared.refresh(onDemand: true) }
}
.disabled(self.healthStore.isRefreshing)
Button("Open logs") { self.revealLogs() }
.buttonStyle(.link)
.foregroundStyle(.secondary)
}
.font(.caption)
}
}

View File

@@ -149,6 +149,21 @@ final class HealthStore: ObservableObject {
return "linked · auth \(auth) · socket ok"
}
/// Short, human-friendly detail for the last failure, used in the UI.
var detailLine: String? {
if let error = self.lastError, !error.isEmpty {
let lower = error.lowercased()
if lower.contains("connection refused") {
return "The relay control port (127.0.0.1:18789) isnt listening — restart Clawdis to bring it back."
}
if lower.contains("timeout") {
return "Timed out waiting for the control server; the relay may be crashed or still starting."
}
return error
}
return nil
}
private func describeFailure(from snap: HealthSnapshot, fallback: String?) -> String {
if !snap.web.linked {
return "Not linked — run clawdis login"