import SwiftUI struct StepLogView: View { let stepID: String let client: EquipoClient #if DEBUG @State private var expanded = ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] == "stopped" #else @State private var expanded = false #endif @State private var tail: String? @State private var failure: String? var body: some View { DisclosureGroup(isExpanded: $expanded) { Group { if let tail { LogTailView(tail: tail) } else if let failure { Text(failure).font(Typo.secondary) Button(EquipoStrings.text("read.retry")) { Task { await load() } } } else { ProgressView().accessibilityLabel(EquipoStrings.text("native.step.log_tail")) } } .task { await load() } } label: { // COPY APPROVED (Luna via controller, 2026-11-25). Text(EquipoStrings.text("native.step.log_tail")).font(Typo.secondary) } } private func load() async { failure = nil do { tail = try await client.stepLog(stepID).boundedTail } catch { failure = StoppedWorkActions.logFailure(error) } } } /// A bounded log used by both the step disclosure and the Checks tab. struct LogTailView: View { let tail: String var maxHeight: CGFloat = 180 @State private var contentHeight: CGFloat = 44 var body: some View { ScrollView(scrollAxes) { logText(tail).padding(8) .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { contentHeight = $0 } } .defaultScrollAnchor(.topLeading) .frame(height: min(max(contentHeight, 44), maxHeight)) .background(Palette.surface2, in: .rect(cornerRadius: 8)) } private var scrollAxes: Axis.Set { #if os(iOS) .vertical #else [.horizontal, .vertical] #endif } @ViewBuilder private func logText(_ tail: String) -> some View { #if os(iOS) WrappingLogText(text: tail) #else Text(verbatim: tail).font(.system(.caption, design: .monospaced)) .textSelection(.enabled).fixedSize() #endif } }