mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[PR #26] [MERGED] refactor(transport): unify node→phase label mapping in shared PhaseLabel #28
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#28
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/26
Author: @mattmillerai
Created: 7/4/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @mattmillerai
Base:
main← Head:matt/be-2350-hoist-phase-label📝 Commits (1)
15db000refactor(transport): unify node→phase label mapping in shared PhaseLabel📊 Changes
3 files changed (+37 additions, -44 deletions)
View changed files
➕
Sources/ComfySwiftSDK/Internal/PhaseLabel.swift(+33 -0)📝
Sources/ComfySwiftSDK/Internal/PollingFallback.swift(+1 -21)📝
Sources/ComfySwiftSDK/Internal/WebSocketSession.swift(+3 -23)📄 Description
ELI-5
The SDK tells you what stage your image job is in ("sampling", "vae_decode", "saving", …). There were two identical copies of the code that turns a node name into one of those labels — one for the live WebSocket path, one for the HTTP polling fallback. Two copies means that if someone later adds a new node type or renames a phase in one place and forgets the other, the same job would report a different phase depending on which transport was active. This PR deletes both copies and replaces them with one shared
PhaseLabel.forNode(_:)that both paths call, so they can never drift apart.What changed
Sources/ComfySwiftSDK/Internal/PhaseLabel.swift— one internalenum PhaseLabelwithstatic func forNode(_:)holding the node→phase mapping.WebSocketSession.swift— removed thefileprivate func phaseLabel(for:); its 3 call sites now usePhaseLabel.forNode(_:).PollingFallback.swift— removed thestatic func phaseLabel(forNode:); its call site (the failed-node branch ofderivePhase) now usesPhaseLabel.forNode(_:).ReattachCoordinatorinherits the fix transitively, since it routes throughPollingFallback.derivePhase.Behavior
No behavior change. The mapping logic was moved verbatim — byte-for-byte identical to the two removed copies (same check order, same string literals, same
contains/==conditions). It's a pure function with no state.Testing
swift build— clean.swift test --no-parallel— 150 tests in 20 suites pass, including thederivePhasephase-emission tests (derivePhase uses node_type from execution_error on failedexercises thePhaseLabel.forNodepath and still returnssampling).Notes
PhaseLabelisinternal).swift testrequired pointing SwiftPM at the CommandLineToolsTesting.framework(this machine has no full Xcode); CI runs the suite normally.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.