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
3struct StepLogView: View {
4 let stepID: String
5 let client: EquipoClient
6 #if DEBUG
7 @State private var expanded = ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] == "stopped"
8 #else
9 @State private var expanded = false
10 #endif
11 @State private var tail: String?
12 @State private var failure: String?
13
14 var body: some View {
15 DisclosureGroup(isExpanded: $expanded) {
16 Group {
17 if let tail {
18 LogTailView(tail: tail)
19 } else if let failure {
20 Text(failure).font(Typo.secondary)
21 Button(EquipoStrings.text("read.retry")) { Task { await load() } }
22 } else { ProgressView().accessibilityLabel(EquipoStrings.text("native.step.log_tail")) }
23 }
24 .task { await load() }
25 } label: {
26 // COPY APPROVED (Luna via controller, 2026-11-25).
27 Text(EquipoStrings.text("native.step.log_tail")).font(Typo.secondary)
28 }
29 }
30
31 private func load() async {
32 failure = nil
33 do { tail = try await client.stepLog(stepID).boundedTail }
34 catch { failure = StoppedWorkActions.logFailure(error) }
35 }
36}
37
38/// A bounded log used by both the step disclosure and the Checks tab.
39struct LogTailView: View {
40 let tail: String
41 var maxHeight: CGFloat = 180
42 @State private var contentHeight: CGFloat = 44
43 var body: some View {
44 ScrollView(scrollAxes) {
45 logText(tail).padding(8)
46 .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { contentHeight = $0 }
47 }
48 .defaultScrollAnchor(.topLeading)
49 .frame(height: min(max(contentHeight, 44), maxHeight))
50 .background(Palette.surface2, in: .rect(cornerRadius: 8))
51 }
52 private var scrollAxes: Axis.Set {
53 #if os(iOS)
54 .vertical
55 #else
56 [.horizontal, .vertical]
57 #endif
58 }
59
60 @ViewBuilder private func logText(_ tail: String) -> some View {
61 #if os(iOS)
62 WrappingLogText(text: tail)
63 #else
64 Text(verbatim: tail).font(.system(.caption, design: .monospaced))
65 .textSelection(.enabled).fixedSize()
66 #endif
67 }
68
69}
70