import SwiftUI struct TaskReviewSummary: View { let task: ThinTask var body: some View { VStack(alignment: .leading, spacing: 8) { SectionTitle(text: EquipoStrings.text("fact.review")) if let review = TaskPage.latestReview(task) { if ["running", "queued"].contains(review.state) { Text(EquipoStrings.text("review.running")).foregroundStyle(Palette.secondary) } else { if !review.headline.isEmpty { Text(review.headline).font(.headline) } if !review.summary.isEmpty { Text(review.summary).font(Typo.body).textSelection(.enabled).fixedSize(horizontal: false, vertical: true) } } } else { Text(EquipoStrings.text("runner.verdict.skipped")).foregroundStyle(Palette.secondary) } } } } struct TaskChecksView: View { let task: ThinTask let client: EquipoClient @State private var sections: [CheckSection] = [] @State private var failure: String? @State private var loadedStep: String? private var step: ThinStep? { TaskPage.checksLogStep(task) } var body: some View { VStack(alignment: .leading, spacing: 16) { if let step { if loadedStep == step.id, let failure { Text(failure).foregroundStyle(Palette.negative) Button(EquipoStrings.text("read.retry")) { Task { await load(step) } } } else if loadedStep != step.id { ProgressView().accessibilityLabel(EquipoStrings.text("fact.checks")) } else { ForEach(sections) { section in if section.isSummary { Text(section.text).font(Typo.body).textSelection(.enabled).fixedSize(horizontal: false, vertical: true) } else { CheckSectionView(section: section) } } } } else { VStack(alignment: .leading, spacing: 8) { SectionTitle(text: EquipoStrings.text("fact.checks")) Text(EquipoStrings.text(TaskPage.latestChecks(task) == nil ? "runner.verdict.skipped" : "checks.running")) .foregroundStyle(Palette.secondary) } } TaskReviewSummary(task: task) } .task(id: task.revision) { sections = []; loadedStep = nil; if let step { await load(step) } } } private func load(_ step: ThinStep) async { failure = nil do { let log = try await client.stepLog(step.id) try Task.checkCancellation() sections = CheckSection.split(log, step: step); loadedStep = step.id } catch { guard !Task.isCancelled else { return } failure = StoppedWorkActions.logFailure(error); loadedStep = step.id } } } private struct CheckSectionView: View { let section: CheckSection @State private var expanded: Bool init(section: CheckSection) { self.section = section; _expanded = State(initialValue: section.failed) } var body: some View { DisclosureGroup(isExpanded: $expanded) { LogTailView(tail: section.text) } label: { Label(section.name.isEmpty ? EquipoStrings.text("native.step.log_tail") : section.name, systemImage: section.failed ? "xmark.circle.fill" : "text.alignleft") .font(.system(.subheadline, design: .monospaced)).foregroundStyle(section.failed ? Palette.negative : Palette.text) } .onChange(of: section.failed) { if section.failed { expanded = true } } } } struct TaskMoveSheet: View { @Bindable var model: TaskDetailModel @State private var selected = "" @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { Form { Text(EquipoStrings.text("placement.restart_note")) if model.busy { ProgressView().accessibilityLabel(EquipoStrings.text("placement.destination")) } if let failure = model.failure { Text(failure).foregroundStyle(Palette.negative) } Picker(EquipoStrings.text("placement.destination"), selection: $selected) { Text(EquipoStrings.text("placement.question")).tag("") ForEach(model.destinations, id: \.self) { Text(verbatim: $0).tag($0) } } Button(EquipoStrings.text(model.task?.steps?.contains(where: { $0.specialist == "engineering" }) == true ? "placement.restart" : "placement.confirm")) { let revision = model.task?.revision Task { await model.perform(.move, seenRevision: revision, repo: selected) } }.disabled(model.busy || !model.destinations.contains(selected)) } .navigationTitle(EquipoStrings.text("placement.title")) .toolbar { ToolbarItem(placement: .cancellationAction) { Button(EquipoStrings.text("placement.back")) { dismiss() } } } }.frame(minWidth: 300, minHeight: 300) } }