mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[PR #43] [MERGED] refactor(job-status): decode wire job status once into a JobStatus enum #45
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-swift-sdk#45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-swift-sdk/pull/43
Author: @mattmillerai
Created: 7/11/2026
Status: ✅ Merged
Merged: 7/16/2026
Merged by: @mattmillerai
Base:
main← Head:matt/be-2857-job-status-enum📝 Commits (2)
cb424ddrefactor(job-status): decode wire status once into a JobStatus enum34e3e3ddocs(reattach): clarify only .unknown reaches the terminal-status branch📊 Changes
5 files changed (+78 additions, -35 deletions)
View changed files
📝
Sources/ComfySwiftSDK/Internal/DTOs/JobStatusDTO.swift(+22 -1)📝
Sources/ComfySwiftSDK/Internal/PollingFallback.swift(+12 -12)📝
Sources/ComfySwiftSDK/Internal/ReattachCoordinator.swift(+15 -9)📝
Tests/ComfySwiftSDKTests/OutputFetchTransientRetryTests.swift(+3 -3)📝
Tests/ComfySwiftSDKTests/PollingFallbackTests.swift(+26 -10)📄 Description
ELI-5
A job on the server has a status word —
pending,in_progress,completed,failed, orcancelled. Our code used to take that word, lowercase it, and compare it against hand-typed strings in four different places. Type one of those strings wrong and nothing complains — it just silently falls into the "ignore it" branch.This change decodes the word once into a real
JobStatusenum. Now the four places switch on the enum instead of on strings. If someone typos a case or the server adds a new status, the compiler tells us — instead of a bug hiding in adefault:.What changed
enum JobStatus: String { case pending, inProgress = "in_progress", completed, failed, cancelled, unknown }inJobStatusDTO.swift.JobDetailResponse.statuschanges fromStringtoJobStatus. A custom decoder lowercases the raw wire value and maps anything unrecognized to.unknown..lowercased()and switch the enum directly:PollingFallback.runPollLoopPollingFallback.derivePhaseReattachCoordinator.runReattach(×2)default:), so a new/typo'd case is a compile error.Behavior preserved
.unknowncase does exactly what the olddefault:did at each site (keep polling / return"executing"/ emit.queued), so unrecognized statuses are still ignored rather than treated as errors.statusstill throws, exactly as before — only the recognized-value mapping moved into the enum.Tests
PollingFallbackTests/OutputFetchTransientRetryTeststo use the enum (.pending,.completed, …) in assertions and DTO fixtures..unknown, and case-insensitive mapping ("IN_PROGRESS"→.inProgress).swift test --no-parallel).Judgment call
The ticket phrased the custom decoder as living "on
JobDetailResponse". I put it onJobStatusitself instead — this still decodes the status exactly once and, importantly, keepsJobDetailResponse's synthesized memberwise initializer intact (the test fixtures constructJobDetailResponse(...)directly). Net decoding behavior is identical.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.