mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[PR #25] [MERGED] refactor(transport): share output-assembly tail between WS and polling paths #26
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#26
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/25
Author: @mattmillerai
Created: 7/4/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @mattmillerai
Base:
main← Head:refactor/shared-output-assembler📝 Commits (2)
bffadd0refactor(transport): extract shared output-assembly tail from WS + polling paths3c9c053fix(transport): clean up orphaned temp files when output assembly fails partway📊 Changes
2 files changed (+57 additions, -46 deletions)
View changed files
📝
Sources/ComfySwiftSDK/Internal/PollingFallback.swift(+52 -19)📝
Sources/ComfySwiftSDK/Internal/WebSocketSession.swift(+5 -27)📄 Description
ELI-5
When a workflow finishes, the SDK downloads the resulting images/videos and packs them into a
WorkflowOutput. There are two ways a job can finish — over the live WebSocket, or via the polling fallback — and both did the exact same download-and-pack work with copy-pasted code. This moves that shared tail into one function both paths call. Same behavior, one copy instead of two.What changed
Extracted the identical "download refs →
WorkflowOutput" tail into a shared helper:PollingFallback.buildOutputnow callsassembleOutputafter its dto-extraction + empty-refs throw.execution_successcase inWebSocketSession.runReadLoopnow callsPollingFallback.assembleOutput, passing its incrementally-bufferedbufferedImageRefs/bufferedVideoRefs.What deliberately stayed separate
The two paths collect refs differently, and that stays untouched:
OutputFileRefs incrementally fromexecutedframes.buildOutputextracts them fromdto.outputs.The empty-refs handling also stays per-caller (WS yields
.failedearly; pollingthrows) — only the download-and-assemble tail is shared.ReattachCoordinatoralready reusedbuildOutput, so the WS path was the sole outlier; it now shares the same tail too.Testing
swift build— clean.swift test --no-parallel— 150 tests, 20 suites, all pass.No behavior change: the extracted body is verbatim the previously-duplicated code.
Notes / judgment calls
assembleOutputisinternal).macos-15+ Xcode 16) runsswift test --no-parallelas normal.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.