chore: surface helper install status in onboarding

This commit is contained in:
Peter Steinberger
2025-12-07 18:43:49 +01:00
parent d57ebb3c94
commit 558af7a454

View File

@@ -44,6 +44,8 @@ struct OnboardingView: View {
@State private var cliStatus: String? @State private var cliStatus: String?
@State private var copied = false @State private var copied = false
@State private var monitoringPermissions = false @State private var monitoringPermissions = false
@State private var cliInstalled = false
@State private var cliInstallLocation: String?
@ObservedObject private var state = AppStateStore.shared @ObservedObject private var state = AppStateStore.shared
@ObservedObject private var permissionMonitor = PermissionMonitor.shared @ObservedObject private var permissionMonitor = PermissionMonitor.shared
@@ -91,7 +93,10 @@ struct OnboardingView: View {
self.updatePermissionMonitoring(for: newValue) self.updatePermissionMonitoring(for: newValue)
} }
.onDisappear { self.stopPermissionMonitoring() } .onDisappear { self.stopPermissionMonitoring() }
.task { await self.refreshPerms() } .task {
await self.refreshPerms()
self.refreshCLIStatus()
}
} }
private func welcomePage() -> some View { private func welcomePage() -> some View {
@@ -208,7 +213,7 @@ struct OnboardingView: View {
.frame(maxWidth: 520) .frame(maxWidth: 520)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
self.onboardingCard { self.onboardingCard(spacing: 10) {
HStack(spacing: 12) { HStack(spacing: 12) {
Button { Button {
Task { await self.installCLI() } Task { await self.installCLI() }
@@ -216,7 +221,7 @@ struct OnboardingView: View {
if self.installingCLI { if self.installingCLI {
ProgressView() ProgressView()
} else { } else {
Text("Install helper") Text(self.cliInstalled ? "Reinstall helper" : "Install helper")
} }
} }
.buttonStyle(.borderedProminent) .buttonStyle(.borderedProminent)
@@ -226,18 +231,24 @@ struct OnboardingView: View {
self.copyToPasteboard(self.devLinkCommand) self.copyToPasteboard(self.devLinkCommand)
} }
.disabled(self.installingCLI) .disabled(self.installingCLI)
if self.cliInstalled, let loc = self.cliInstallLocation {
Label("Installed at \(loc)", systemImage: "checkmark.circle.fill")
.font(.footnote)
.foregroundStyle(.green)
}
} }
if let cliStatus { if let cliStatus {
Text(cliStatus) Text(cliStatus)
.font(.caption) .font(.caption)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} else if !self.cliInstalled, self.cliInstallLocation == nil {
Text(
"We install into /usr/local/bin and /opt/homebrew/bin. Rerun anytime if you move the build output.")
.font(.footnote)
.foregroundStyle(.secondary)
} }
Text(
"We install into /usr/local/bin and /opt/homebrew/bin. Rerun anytime if you move the build output.")
.font(.footnote)
.foregroundStyle(.secondary)
} }
} }
} }
@@ -441,6 +452,13 @@ struct OnboardingView: View {
await CLIInstaller.install { message in await CLIInstaller.install { message in
await MainActor.run { self.cliStatus = message } await MainActor.run { self.cliStatus = message }
} }
self.refreshCLIStatus()
}
private func refreshCLIStatus() {
let installLocation = CLIInstaller.installedLocation()
self.cliInstallLocation = installLocation
self.cliInstalled = installLocation != nil
} }
private func copyToPasteboard(_ text: String) { private func copyToPasteboard(_ text: String) {