diff options
| author | Christian Cleberg <[email protected]> | 2026-03-18 19:34:59 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-03-18 19:34:59 -0500 |
| commit | 430741f0236ab21583acda8e2774d95e6e0e4ffe (patch) | |
| tree | e8ef38d574939a0c47f2a92e14db60950b824151 /Hutch/Views/Builds | |
| parent | 796c39d8ff08829bd695bc4e7497a147640eb79a (diff) | |
| download | hutch-430741f0236ab21583acda8e2774d95e6e0e4ffe.tar.gz hutch-430741f0236ab21583acda8e2774d95e6e0e4ffe.tar.bz2 hutch-430741f0236ab21583acda8e2774d95e6e0e4ffe.zip | |
stabilize build task identity and log cache keys
Diffstat (limited to 'Hutch/Views/Builds')
| -rw-r--r-- | Hutch/Views/Builds/BuildDetailView.swift | 4 | ||||
| -rw-r--r-- | Hutch/Views/Builds/BuildDetailViewModel.swift | 17 |
2 files changed, 13 insertions, 8 deletions
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 { |
