Tag v0.1.0

This commit is contained in:
Ian Gulliver
2026-10-18 16:14:03 -07:00
parent 543d1289e3
commit c4d7a67dad
14 changed files with 349 additions and 103 deletions
+51 -2
View File
@@ -86,6 +86,46 @@ final class Connection {
await start(origin)
}
func installHere() async {
connecting = true
problem = nil
let gen = generation
do {
let origin = try await Server.turnOn()
serverText = origin.absoluteString
try await waitForServer(origin)
} catch {
if gen == generation {
connecting = false
problem = errorText(error)
}
return
}
guard gen == generation else {
return
}
await connect()
}
private func waitForServer(_ origin: URL) async throws {
let api = API(origin: origin)
try await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
while (try? await api.client.getStatus().ok) == nil {
try await Task.sleep(for: .milliseconds(500))
}
}
group.addTask {
try await Task.sleep(for: .seconds(10))
throw ProcessFailure(errorDescription: "byre was installed but \(origin.absoluteString) didn't answer within 10 s.")
}
defer {
group.cancelAll()
}
try await group.next()
}
}
func changeServer() {
generation += 1
if let store {
@@ -175,8 +215,11 @@ struct ConnectView: View {
TextField("https://byre.example.ts.net", text: $connection.serverText)
.textFieldStyle(.roundedBorder)
.onSubmit(connect)
Button("Connect", action: connect)
.disabled(connection.connecting)
HStack(spacing: 10) {
Button("Connect", action: connect)
Button("Run byre on this Mac", action: installHere)
}
.disabled(connection.connecting)
if let problem = connection.problem {
Text(problem)
.foregroundStyle(Palette.danger)
@@ -193,6 +236,12 @@ struct ConnectView: View {
await connection.connect()
}
}
private func installHere() {
Task {
await connection.installHere()
}
}
}
struct FatalView: View {