mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-27 18:24:11 +00:00
feat(historyV2): load workflows for images (#6384)
## Summary Hooked up the "Load Workflow" action to our `history_v2` API. Note: Our cloud envs were being stress tested right now so images are loading at time of recording. Images were loading for me during development before I had time to create the video. ## Screenshots 📷 https://github.com/user-attachments/assets/02145504-ceae-497b-9049-553796d698da ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6384-Feat-history-v2-workflows-29b6d73d365081bcb706fe799b8ce66a) by [Unito](https://www.unito.io)
This commit is contained in:
21
src/platform/workflow/cloud/getWorkflowFromHistory.ts
Normal file
21
src/platform/workflow/cloud/getWorkflowFromHistory.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema'
|
||||
import type { PromptId } from '@/schemas/apiSchema'
|
||||
|
||||
export async function getWorkflowFromHistory(
|
||||
fetchApi: (url: string) => Promise<Response>,
|
||||
promptId: PromptId
|
||||
): Promise<ComfyWorkflowJSON | undefined> {
|
||||
try {
|
||||
const res = await fetchApi(`/history_v2/${promptId}`)
|
||||
const json = await res.json()
|
||||
|
||||
const historyItem = json[promptId]
|
||||
if (!historyItem) return undefined
|
||||
|
||||
const workflow = historyItem.prompt?.extra_data?.extra_pnginfo?.workflow
|
||||
return workflow ?? undefined
|
||||
} catch (error) {
|
||||
console.error(`Failed to fetch workflow for prompt ${promptId}:`, error)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
10
src/platform/workflow/cloud/index.ts
Normal file
10
src/platform/workflow/cloud/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Cloud: Fetches workflow by prompt_id. Desktop: Returns undefined (workflows already in history).
|
||||
*/
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
|
||||
import { getWorkflowFromHistory as cloudImpl } from './getWorkflowFromHistory'
|
||||
|
||||
export const getWorkflowFromHistory = isCloud
|
||||
? cloudImpl
|
||||
: async () => undefined
|
||||
Reference in New Issue
Block a user