oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1import SwiftUI
2
3/// The same pause and actions on a task and its conversation report.
4struct TaskPauseActions: View {
5 let pause: TaskPause
6 let taskID: String
7 let session: EquipoSession
8 var showsLead = true
9 @State private var busy = false
10 @State private var message: String?
11 @State private var resume = ResumeAction()
12
13 var body: some View {
14 VStack(alignment: .leading, spacing: 8) {
15 if showsLead {
16 PauseLead(pause: pause) { run in perform { await session.runNow(task: taskID, run) } }
17 } else if let run = pause.runNow {
18 RosterButton(title: run.label, primary: true) {
19 perform { await session.runNow(task: taskID, run) }
20 }
21 if let note = pause.note { Text(note).font(Typo.secondary) }
22 }
23 if pause.canRetry {
24 RosterButton(title: EquipoStrings.text("work.pause.try_again"), primary: true, expanded: true) {
25 perform { await StoppedWorkActions.retry(client: session.client, task: taskID) }
26 }
27 }
28 if pause.canRecover {
29 RosterButton(title: EquipoStrings.text("work.recover"), primary: true) {
30 perform { await StoppedWorkActions.recover(client: session.client, task: taskID) }
31 }
32 }
33 if let step = pause.resumeStep, resume.connection != nil {
34 RosterButton(title: EquipoStrings.text("work.hold.resume"), primary: true) {
35 perform { await resume.perform(client: session.client, step: step) }
36 }
37 }
38 if let path = pause.settingsPath, let label = pause.settingsLabel {
39 RosterButton(title: label) { session.settings.open(origin: session.origin, path: path) }
40 }
41 if let message { Text(message).font(Typo.secondary).foregroundStyle(Palette.negative) }
42 if busy { ProgressView(EquipoStrings.text("action.sending")) }
43 }
44 .disabled(busy)
45 #if DEBUG
46 .task {
47 if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] == "conversation-retry" {
48 try? await Task.sleep(for: .milliseconds(700))
49 perform { await StoppedWorkActions.retry(client: session.client, task: taskID) }
50 }
51 }
52 #endif
53 .task(id: pause.resumeStep) {
54 resume.connection = nil
55 if let step = pause.resumeStep { await resume.load(client: session.client, step: step) }
56 }
57 }
58
59 private func perform(_ action: @escaping @MainActor () async -> String?) {
60 guard !busy else { return }
61 busy = true; message = nil
62 Task {
63 message = await action()
64 await session.refresh()
65 busy = false
66 }
67 }
68}
69