[PR #8] [MERGED] fix(transport): migrate job-status fetch off tombstoned /api/prompt to /api/jobs #13

Closed
opened 2026-10-26 22:33:53 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-swift-sdk/pull/8
Author: @mattmillerai
Created: 6/19/2026
Status: ✅ Merged
Merged: 6/19/2026
Merged by: @mattmillerai

Base: main ← Head: matt/be-1615-comfyswiftsdk-migrate-http-job-status-fetch-off-the


📝 Commits (1)

  • f2d636c fix(transport): migrate job-status fetch off tombstoned /api/prompt to /api/jobs

📊 Changes

9 files changed (+781 additions, -222 deletions)

View changed files

📝 Sources/ComfySwiftSDK/Internal/DTOs/JobStatusDTO.swift (+77 -46)
📝 Sources/ComfySwiftSDK/Internal/PollingFallback.swift (+43 -35)
📝 Sources/ComfySwiftSDK/Internal/ReattachCoordinator.swift (+19 -9)
📝 Sources/ComfySwiftSDK/Internal/Transport.swift (+6 -6)
➕ Tests/ComfySwiftSDKTests/JobStatusEndpointMigrationTests.swift (+434 -0)
📝 Tests/ComfySwiftSDKTests/OutputFetchTransientRetryTests.swift (+21 -18)
📝 Tests/ComfySwiftSDKTests/PollingFallbackTests.swift (+164 -94)
📝 Tests/ComfySwiftSDKTests/ReattachCoordinatorTests.swift (+16 -13)
📝 Tests/ComfySwiftSDKTests/ReattachTransientRetryTests.swift (+1 -1)

📄 Description

ELI5

The app was checking an old job-status URL that Cloud deliberately turns into a 404 — so whenever the live WebSocket dropped and the SDK fell back to polling, every backgrounded job looked permanently failed. This PR points the polling and reattach paths at the real /api/jobs/{id} endpoint and decodes its current response shape, so jobs that were running in the background actually recover when connectivity returns.

What

  • Transport: performFetchJobStatus URL changed from api/prompt/{id} to api/jobs/{id}.
  • DTO: JobStatusDTO rewritten as JobDetailResponse mirroring the JobDetailResponse schema from the ingest OpenAPI spec. Fields decoded: id, status, outputs, execution_error (as JobDetailExecutionError), create_time, update_time. A typealias JobStatusDTO = JobDetailResponse keeps existing internal call sites compiling.
  • Status enum remap: pending → active/queued; in_progress → active/progress; completed → terminal success; failed → terminal failure; cancelled → cancelled. The old legacy values (queued, running, success, error) are gone from the switch statements.
  • Phase derivation: derivePhase now operates on status alone (the HTTP endpoint carries no per-node progress hints); on failed, it reads execution_error.node_type to derive a phase label. deriveFraction always returns 0.0 (progress fraction is WebSocket-only).
  • Doc comments: every reference to /api/prompt/{id} in Transport, ReattachCoordinator, PollingFallback, and the DTO file updated to /api/jobs/{id}.

Why

GET /api/prompt/{id} is a deliberate 404 tombstone in Cloud (legacyNotFoundHandler). The previously-merged retry PRs hardened the symptom (transient backoff on network errors); this is the root-cause fix that points the SDK at the endpoint that actually exists.

Testing

  • New JobStatusEndpointMigrationTests suite covers all five status values on both the reattach and polling paths, the URL regression guard asserting the path is /api/jobs/{id} and never /api/prompt/{id}, and unchanged auth/rate-limit error classifications.
  • Existing PollingFallbackTests, ReattachCoordinatorTests, ReattachTransientRetryTests, and OutputFetchTransientRetryTests updated to use the new status enum values and DTO shape.
  • swift build clean; swift test green — 143 tests across 17 suites, 0 failures.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-swift-sdk/pull/8 **Author:** [@mattmillerai](https://github.com/mattmillerai) **Created:** 6/19/2026 **Status:** ✅ Merged **Merged:** 6/19/2026 **Merged by:** [@mattmillerai](https://github.com/mattmillerai) **Base:** `main` ← **Head:** `matt/be-1615-comfyswiftsdk-migrate-http-job-status-fetch-off-the` --- ### 📝 Commits (1) - [`f2d636c`](https://github.com/Comfy-Org/comfy-swift-sdk/commit/f2d636ce6b5b3ac1ccc61241304b47c2dd853f6b) fix(transport): migrate job-status fetch off tombstoned /api/prompt to /api/jobs ### 📊 Changes **9 files changed** (+781 additions, -222 deletions) <details> <summary>View changed files</summary> 📝 `Sources/ComfySwiftSDK/Internal/DTOs/JobStatusDTO.swift` (+77 -46) 📝 `Sources/ComfySwiftSDK/Internal/PollingFallback.swift` (+43 -35) 📝 `Sources/ComfySwiftSDK/Internal/ReattachCoordinator.swift` (+19 -9) 📝 `Sources/ComfySwiftSDK/Internal/Transport.swift` (+6 -6) ➕ `Tests/ComfySwiftSDKTests/JobStatusEndpointMigrationTests.swift` (+434 -0) 📝 `Tests/ComfySwiftSDKTests/OutputFetchTransientRetryTests.swift` (+21 -18) 📝 `Tests/ComfySwiftSDKTests/PollingFallbackTests.swift` (+164 -94) 📝 `Tests/ComfySwiftSDKTests/ReattachCoordinatorTests.swift` (+16 -13) 📝 `Tests/ComfySwiftSDKTests/ReattachTransientRetryTests.swift` (+1 -1) </details> ### 📄 Description ## ELI5 The app was checking an old job-status URL that Cloud deliberately turns into a 404 — so whenever the live WebSocket dropped and the SDK fell back to polling, every backgrounded job looked permanently failed. This PR points the polling and reattach paths at the real `/api/jobs/{id}` endpoint and decodes its current response shape, so jobs that were running in the background actually recover when connectivity returns. ## What - **Transport:** `performFetchJobStatus` URL changed from `api/prompt/{id}` to `api/jobs/{id}`. - **DTO:** `JobStatusDTO` rewritten as `JobDetailResponse` mirroring the `JobDetailResponse` schema from the ingest OpenAPI spec. Fields decoded: `id`, `status`, `outputs`, `execution_error` (as `JobDetailExecutionError`), `create_time`, `update_time`. A `typealias JobStatusDTO = JobDetailResponse` keeps existing internal call sites compiling. - **Status enum remap:** `pending` → active/queued; `in_progress` → active/progress; `completed` → terminal success; `failed` → terminal failure; `cancelled` → cancelled. The old legacy values (`queued`, `running`, `success`, `error`) are gone from the switch statements. - **Phase derivation:** `derivePhase` now operates on `status` alone (the HTTP endpoint carries no per-node progress hints); on `failed`, it reads `execution_error.node_type` to derive a phase label. `deriveFraction` always returns `0.0` (progress fraction is WebSocket-only). - **Doc comments:** every reference to `/api/prompt/{id}` in Transport, ReattachCoordinator, PollingFallback, and the DTO file updated to `/api/jobs/{id}`. ## Why `GET /api/prompt/{id}` is a deliberate 404 tombstone in Cloud (`legacyNotFoundHandler`). The previously-merged retry PRs hardened the symptom (transient backoff on network errors); this is the root-cause fix that points the SDK at the endpoint that actually exists. ## Testing - New `JobStatusEndpointMigrationTests` suite covers all five status values on both the reattach and polling paths, the URL regression guard asserting the path is `/api/jobs/{id}` and never `/api/prompt/{id}`, and unchanged auth/rate-limit error classifications. - Existing `PollingFallbackTests`, `ReattachCoordinatorTests`, `ReattachTransientRetryTests`, and `OutputFetchTransientRetryTests` updated to use the new status enum values and DTO shape. - `swift build` clean; `swift test` green — 143 tests across 17 suites, 0 failures. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:33:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-swift-sdk#13
No description provided.