[PR #46] [CLOSED] feat: add getWorkflow() to fetch the graph that produced a job #56

Closed
opened 2026-10-31 22:04:12 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-typescript-sdk/pull/46
Author: @wei-hai
Created: 8/13/2026
Status: ❌ Closed

Base: main ← Head: wei/fetch-job-workflow


📝 Commits (2)

  • 66ae9be feat: add job.workflow() to fetch the graph that produced a job
  • 6bd601e fix: append /workflow when getJobWorkflow is given a job URL

📊 Changes

6 files changed (+158 additions, -2 deletions)

View changed files

📝 src/low/index.ts (+2 -0)
📝 src/low/transport.test.ts (+36 -0)
📝 src/low/transport.ts (+48 -0)
📝 src/sdk/jobs.test.ts (+25 -1)
📝 src/sdk/jobs.ts (+26 -1)
📝 test/support/stub-server.ts (+21 -0)

📄 Description

A caller holding a job — including one rehydrated by id — has no way to see the workflow behind it. The SDK holds the graph only when it submitted the job in the same process; otherwise it's gone.

flowchart LR
  subgraph B["Before"]
    J1["job (rehydrated by id)"] -. "?" .-> W1["workflow"]
  end
  subgraph A["After"]
    J2["job"] -- "GET /jobs/{id}/workflow" --> W2["workflow + format"]
  end

What it returns

Both the graph and the format discriminator, never just the graph:

  • api — the executed graph. Editor-only constructs (Note nodes, Get/Set) are already resolved away.
  • save — the authoring workflow at the version the job ran, un-mangled. Only for jobs that pin a workflow version; jobs submitted through this SDK today always get api.

Callers must branch on format — which shape comes back depends on how the job was submitted, not on anything the caller controls.

Server side is merged

GET /api/v2/jobs/{id}/workflow landed in Comfy-Org/cloud#6642, so this now works against a live server.

One follow-up, deliberately not done here

The transport call is written by hand, because the vendored spec didn't describe the operation when this was written. The spec-sync PR carrying it is open in this repo — once that merges, this call should move onto the generated client and the hand-written request dropped. A comment in the code marks the spot.

Keeping the two separate so this PR stays reviewable on its own; spec/openapi.yaml and spec/VERSION are untouched here and the drift check passes.

Naming

Matches the existing get_download_url / getDownloadUrl precedent for a network-fetching accessor, and the two SDKs stay in lockstep.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added the ability to retrieve a job’s workflow through the SDK.
    • Supports workflows in both API and save formats.
    • Allows requests to be cancelled with an abort signal.
  • Bug Fixes
    • Missing workflows now consistently return a NotFound error.

🔄 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-typescript-sdk/pull/46 **Author:** [@wei-hai](https://github.com/wei-hai) **Created:** 8/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `wei/fetch-job-workflow` --- ### 📝 Commits (2) - [`66ae9be`](https://github.com/Comfy-Org/comfy-typescript-sdk/commit/66ae9bebd4375a97c8d4b4abac3e089e228fdc07) feat: add job.workflow() to fetch the graph that produced a job - [`6bd601e`](https://github.com/Comfy-Org/comfy-typescript-sdk/commit/6bd601e8bb9942f3d1e62ec57d41ab2f60e1f517) fix: append /workflow when getJobWorkflow is given a job URL ### 📊 Changes **6 files changed** (+158 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/low/index.ts` (+2 -0) 📝 `src/low/transport.test.ts` (+36 -0) 📝 `src/low/transport.ts` (+48 -0) 📝 `src/sdk/jobs.test.ts` (+25 -1) 📝 `src/sdk/jobs.ts` (+26 -1) 📝 `test/support/stub-server.ts` (+21 -0) </details> ### 📄 Description A caller holding a job — including one rehydrated by id — has no way to see the workflow behind it. The SDK holds the graph only when it submitted the job in the same process; otherwise it's gone. ```mermaid flowchart LR subgraph B["Before"] J1["job (rehydrated by id)"] -. "?" .-> W1["workflow"] end subgraph A["After"] J2["job"] -- "GET /jobs/{id}/workflow" --> W2["workflow + format"] end ``` ## What it returns Both the graph **and** the `format` discriminator, never just the graph: - **`api`** — the executed graph. Editor-only constructs (Note nodes, Get/Set) are already resolved away. - **`save`** — the authoring workflow at the version the job ran, un-mangled. Only for jobs that pin a workflow version; jobs submitted through this SDK today always get `api`. Callers must branch on `format` — which shape comes back depends on how the job was submitted, not on anything the caller controls. ## Server side is merged `GET /api/v2/jobs/{id}/workflow` landed in Comfy-Org/cloud#6642, so this now works against a live server. ## One follow-up, deliberately not done here The transport call is written by hand, because the vendored spec didn't describe the operation when this was written. The spec-sync PR carrying it is open in this repo — once that merges, this call should move onto the generated client and the hand-written request dropped. A comment in the code marks the spot. Keeping the two separate so this PR stays reviewable on its own; `spec/openapi.yaml` and `spec/VERSION` are untouched here and the drift check passes. ## Naming Matches the existing `get_download_url` / `getDownloadUrl` precedent for a network-fetching accessor, and the two SDKs stay in lockstep. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added the ability to retrieve a job’s workflow through the SDK. * Supports workflows in both API and save formats. * Allows requests to be cancelled with an abort signal. * **Bug Fixes** * Missing workflows now consistently return a `NotFound` error. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:04:12 +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-typescript-sdk#56
No description provided.