Server setup in the app

This commit is contained in:
Ian Gulliver
2026-10-18 22:17:54 -07:00
parent 327aab069d
commit 602e6703b4
16 changed files with 825 additions and 269 deletions
+24 -1
View File
@@ -199,6 +199,7 @@ final class Connection {
final class ConnectForm {
var serverText = ""
var problem: String?
var missing: [Check] = []
var connecting = false
func connect() async -> URL? {
@@ -223,7 +224,14 @@ final class ConnectForm {
func installHere() async -> URL? {
connecting = true
problem = nil
missing = []
do {
let checks = try await Server.checks()
if !checks.ready {
missing = checks.checks.filter { !$0.ok }
connecting = false
return nil
}
let origin = try await Server.turnOn()
serverText = origin.absoluteString
try await waitForServer(origin)
@@ -294,6 +302,16 @@ struct ConnectView: View {
let connected: (URL) -> Void
var body: some View {
GeometryReader { g in
ScrollView {
fields
.padding(.vertical, 24)
.frame(maxWidth: .infinity, minHeight: g.size.height)
}
}
}
private var fields: some View {
VStack(alignment: .leading, spacing: 10) {
Text("Server URL")
TextField("https://byre.example.ts.net", text: $form.serverText)
@@ -310,9 +328,14 @@ struct ConnectView: View {
.textSelection(.enabled)
.fixedSize(horizontal: false, vertical: true)
}
if !form.missing.isEmpty {
Text("byre can't run on this Mac yet. Install what's missing, then click Run byre on this Mac again.")
.fixedSize(horizontal: false, vertical: true)
.padding(.top, 6)
ChecksView(checks: form.missing)
}
}
.frame(width: 460)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
private func connect() {