From 430741f0236ab21583acda8e2774d95e6e0e4ffe Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 18 Mar 2026 19:34:59 -0500 Subject: stabilize build task identity and log cache keys --- Hutch/Views/Builds/BuildDetailView.swift | 4 ++-- Hutch/Views/Builds/BuildDetailViewModel.swift | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'Hutch/Views/Builds') diff --git a/Hutch/Views/Builds/BuildDetailView.swift b/Hutch/Views/Builds/BuildDetailView.swift index 977cd87..0479f76 100644 --- a/Hutch/Views/Builds/BuildDetailView.swift +++ b/Hutch/Views/Builds/BuildDetailView.swift @@ -312,13 +312,13 @@ private struct TaskLogSection: View { var body: some View { DisclosureGroup(isExpanded: $isExpanded) { - if viewModel.loadingTaskLogs.contains(task.name) { + if viewModel.loadingTaskLogs.contains(task.logCacheKey) { HStack { Spacer() ProgressView("Loading log…") Spacer() } - } else if let logText = viewModel.taskLogs[task.name] { + } else if let logText = viewModel.taskLogs[task.logCacheKey] { ScrollView(.horizontal, showsIndicators: false) { Text(logText) .font(.caption2.monospaced()) diff --git a/Hutch/Views/Builds/BuildDetailViewModel.swift b/Hutch/Views/Builds/BuildDetailViewModel.swift index c14e47b..1768e47 100644 --- a/Hutch/Views/Builds/BuildDetailViewModel.swift +++ b/Hutch/Views/Builds/BuildDetailViewModel.swift @@ -104,7 +104,11 @@ final class BuildDetailViewModel { variables: ["id": jobId], responseType: JobDetailResponse.self ) - job = result.job + var loadedJob = result.job + loadedJob.tasks = loadedJob.tasks.enumerated().map { index, task in + task.withOrdinal(index) + } + job = loadedJob } catch { self.error = error.localizedDescription } @@ -113,19 +117,20 @@ final class BuildDetailViewModel { } func loadTaskLog(task: BuildTask) async { + let cacheKey = task.logCacheKey guard let log = task.log, let logURL = URL(string: log.fullURL), - !loadingTaskLogs.contains(task.name), - taskLogs[task.name] == nil else { return } - loadingTaskLogs.insert(task.name) + !loadingTaskLogs.contains(cacheKey), + taskLogs[cacheKey] == nil else { return } + loadingTaskLogs.insert(cacheKey) do { - taskLogs[task.name] = try await client.fetchText(url: logURL) + taskLogs[cacheKey] = try await client.fetchText(url: logURL) } catch { self.error = error.localizedDescription } - loadingTaskLogs.remove(task.name) + loadingTaskLogs.remove(cacheKey) } func cancelJob() async { -- cgit v1.2.3