mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
get queue size to 50, remove misleading comment
This commit is contained in:
@@ -1,11 +1,3 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Jobs API Fetchers
|
|
||||||
* @module platform/remote/comfyui/jobs/fetchJobs
|
|
||||||
*
|
|
||||||
* Unified jobs API fetcher for history, queue, and job details.
|
|
||||||
* All distributions use the /jobs endpoint.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { PromptId } from '@/schemas/apiSchema'
|
import type { PromptId } from '@/schemas/apiSchema'
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
@@ -14,7 +6,7 @@ import type {
|
|||||||
JobStatus,
|
JobStatus,
|
||||||
RawJobListItem
|
RawJobListItem
|
||||||
} from './jobTypes'
|
} from './jobTypes'
|
||||||
import { zJobDetail, zJobsListResponse, zWorkflowContainer } from './jobTypes'
|
import { zJobDetail, zJobsListResponse } from './jobTypes'
|
||||||
|
|
||||||
interface FetchJobsRawResult {
|
interface FetchJobsRawResult {
|
||||||
jobs: RawJobListItem[]
|
jobs: RawJobListItem[]
|
||||||
@@ -94,7 +86,7 @@ export async function fetchQueue(
|
|||||||
const { jobs } = await fetchJobsRaw(
|
const { jobs } = await fetchJobsRaw(
|
||||||
fetchApi,
|
fetchApi,
|
||||||
['in_progress', 'pending'],
|
['in_progress', 'pending'],
|
||||||
200,
|
50,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -134,13 +126,14 @@ export async function fetchJobDetail(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Extracts workflow from job detail response */
|
||||||
* Extracts workflow from job detail response.
|
|
||||||
* The workflow is nested at: workflow.extra_data.extra_pnginfo.workflow
|
|
||||||
* Full workflow validation happens downstream via validateComfyWorkflow.
|
|
||||||
*/
|
|
||||||
export function extractWorkflow(job: JobDetail | undefined): unknown {
|
export function extractWorkflow(job: JobDetail | undefined): unknown {
|
||||||
const parsed = zWorkflowContainer.safeParse(job?.workflow)
|
const workflow = job?.workflow
|
||||||
if (!parsed.success) return undefined
|
if (!workflow || typeof workflow !== 'object') return undefined
|
||||||
return parsed.data.extra_data?.extra_pnginfo?.workflow
|
const container = workflow as Record<string, unknown>
|
||||||
|
const extraData = container.extra_data
|
||||||
|
if (!extraData || typeof extraData !== 'object') return undefined
|
||||||
|
const pnginfo = (extraData as Record<string, unknown>).extra_pnginfo
|
||||||
|
if (!pnginfo || typeof pnginfo !== 'object') return undefined
|
||||||
|
return (pnginfo as Record<string, unknown>).workflow
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
/**
|
|
||||||
* @fileoverview Jobs API types - Backend job API format
|
|
||||||
* @module platform/remote/comfyui/jobs/jobTypes
|
|
||||||
*
|
|
||||||
* These types represent the jobs API format returned by the backend.
|
|
||||||
* Jobs API provides a memory-optimized alternative to history API.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { resultItemType, zTaskOutput } from '@/schemas/apiSchema'
|
import { resultItemType, zTaskOutput } from '@/schemas/apiSchema'
|
||||||
@@ -25,57 +17,49 @@ const zPreviewOutput = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execution error details for error jobs.
|
* Execution error details for failed jobs.
|
||||||
* Contains the same structure as ExecutionErrorWsMessage from WebSocket.
|
* Contains the same structure as ExecutionErrorWsMessage from WebSocket.
|
||||||
*/
|
*/
|
||||||
const zExecutionError = z
|
const zExecutionError = z.object({
|
||||||
.object({
|
prompt_id: z.string().optional(),
|
||||||
prompt_id: z.string().optional(),
|
timestamp: z.number().optional(),
|
||||||
timestamp: z.number().optional(),
|
node_id: z.string(),
|
||||||
node_id: z.string(),
|
node_type: z.string(),
|
||||||
node_type: z.string(),
|
executed: z.array(z.string()).optional(),
|
||||||
executed: z.array(z.string()).optional(),
|
exception_message: z.string(),
|
||||||
exception_message: z.string(),
|
exception_type: z.string(),
|
||||||
exception_type: z.string(),
|
traceback: z.array(z.string()),
|
||||||
traceback: z.array(z.string()),
|
current_inputs: z.record(z.string(), z.unknown()),
|
||||||
current_inputs: z.record(z.string(), z.unknown()),
|
current_outputs: z.record(z.string(), z.unknown())
|
||||||
current_outputs: z.record(z.string(), z.unknown())
|
})
|
||||||
})
|
|
||||||
.passthrough()
|
|
||||||
|
|
||||||
export type ExecutionError = z.infer<typeof zExecutionError>
|
export type ExecutionError = z.infer<typeof zExecutionError>
|
||||||
|
|
||||||
/**
|
/** Raw job from API list endpoint */
|
||||||
* Raw job from API - uses passthrough to allow extra fields
|
const zRawJobListItem = z.object({
|
||||||
*/
|
id: z.string(),
|
||||||
const zRawJobListItem = z
|
status: zJobStatus,
|
||||||
.object({
|
create_time: z.number(),
|
||||||
id: z.string(),
|
execution_start_time: z.number().optional(),
|
||||||
status: zJobStatus,
|
execution_end_time: z.number().optional(),
|
||||||
create_time: z.number(),
|
preview_output: zPreviewOutput.optional(),
|
||||||
execution_start_time: z.number().optional(),
|
outputs_count: z.number().optional(),
|
||||||
execution_end_time: z.number().optional(),
|
execution_error: zExecutionError.optional(),
|
||||||
preview_output: zPreviewOutput.optional(),
|
workflow_id: z.string().optional(),
|
||||||
outputs_count: z.number().optional(),
|
priority: z.number().optional()
|
||||||
execution_error: zExecutionError.optional(),
|
})
|
||||||
workflow_id: z.string().optional(),
|
|
||||||
priority: z.number().optional()
|
|
||||||
})
|
|
||||||
.passthrough()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job detail - returned by GET /api/jobs/{job_id} (detail endpoint)
|
* Job detail - returned by GET /api/jobs/{job_id} (detail endpoint)
|
||||||
* Includes full workflow and outputs for re-execution and downloads
|
* Includes full workflow and outputs for re-execution and downloads
|
||||||
*/
|
*/
|
||||||
export const zJobDetail = zRawJobListItem
|
export const zJobDetail = zRawJobListItem.extend({
|
||||||
.extend({
|
workflow: z.unknown().optional(),
|
||||||
workflow: z.unknown().optional(),
|
outputs: zTaskOutput.optional(),
|
||||||
outputs: zTaskOutput.optional(),
|
update_time: z.number().optional(),
|
||||||
update_time: z.number().optional(),
|
execution_status: z.unknown().optional(),
|
||||||
execution_status: z.unknown().optional(),
|
execution_meta: z.unknown().optional()
|
||||||
execution_meta: z.unknown().optional()
|
})
|
||||||
})
|
|
||||||
.passthrough()
|
|
||||||
|
|
||||||
const zPaginationInfo = z.object({
|
const zPaginationInfo = z.object({
|
||||||
offset: z.number(),
|
offset: z.number(),
|
||||||
@@ -89,19 +73,6 @@ export const zJobsListResponse = z.object({
|
|||||||
pagination: zPaginationInfo
|
pagination: zPaginationInfo
|
||||||
})
|
})
|
||||||
|
|
||||||
/** Schema for workflow container structure in job detail responses */
|
|
||||||
export const zWorkflowContainer = z.object({
|
|
||||||
extra_data: z
|
|
||||||
.object({
|
|
||||||
extra_pnginfo: z
|
|
||||||
.object({
|
|
||||||
workflow: z.unknown()
|
|
||||||
})
|
|
||||||
.optional()
|
|
||||||
})
|
|
||||||
.optional()
|
|
||||||
})
|
|
||||||
|
|
||||||
export type JobStatus = z.infer<typeof zJobStatus>
|
export type JobStatus = z.infer<typeof zJobStatus>
|
||||||
export type RawJobListItem = z.infer<typeof zRawJobListItem>
|
export type RawJobListItem = z.infer<typeof zRawJobListItem>
|
||||||
/** Job list item with priority always set (server-provided or synthetic) */
|
/** Job list item with priority always set (server-provided or synthetic) */
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ describe('fetchJobs', () => {
|
|||||||
const result = await fetchQueue(mockFetch)
|
const result = await fetchQueue(mockFetch)
|
||||||
|
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith(
|
||||||
'/jobs?status=in_progress,pending&limit=200&offset=0'
|
'/jobs?status=in_progress,pending&limit=50&offset=0'
|
||||||
)
|
)
|
||||||
expect(result.Running).toHaveLength(1)
|
expect(result.Running).toHaveLength(1)
|
||||||
expect(result.Pending).toHaveLength(2)
|
expect(result.Pending).toHaveLength(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user