Implementation:0xsline OpenChatCut GenerationProgressPlugin
Appearance
| Knowledge Sources | |
|---|---|
| Domains | AI_Generation, Progress_Tracking, HTTP |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Concrete Vite plugin that exposes `POST /generate/progress` for querying, long-polling, and resuming AI generation jobs, returning structured progress reports for one or more job IDs.
Description
The generationProgressPlugin function registers an HTTP endpoint at `/generate/progress` that supports four actions:
- `params`: Returns the current parameters and submit arguments for the requested jobs.
- `status`: Returns the current status and progress for the requested jobs (non-blocking).
- `wait`: Long-polls until all requested jobs reach a terminal status or the timeout expires. Polls every 250ms, with `timeoutSeconds` (0–3600, default 90).
- `resume`: Re-engages with provider tasks that may still be running for the requested jobs.
The response includes a `reports` array with per-job status:
- `jobId`, `operationId`, `status`, `progress`, `phase`
- `processedFrames`, `totalFrames`
- `resultUrls`, `error`, `retryable`
The plugin also initializes the job store and resumes restored jobs on server startup.
Usage
- UI progress polling: The editor UI long-polls this endpoint to show real-time generation progress.
- Agent progress: MCP agents query job status to wait for completion.
- Resume after restart: On server restart, the plugin restores persisted jobs and re-engages provider tasks.
Code Reference
Source Location
- Repository: OpenChatCut
- File:*** server/plugins/generation-jobs.ts
Signature
export function generationProgressPlugin(): Plugin;
// Internal: applies progress updates to a job
export function applyProgress(job: GenerationJob, next: GenerationJobProgress): void;
Import
import { generationProgressPlugin } from '../server/plugins/generation-jobs.ts';
I/O Contract
Inputs (HTTP POST body)
| Name | Type | Required | Description |
|---|---|---|---|
| target | 'generation' | Yes | Must be 'generation' |
| action | string | Yes | 'params', 'status', 'wait', or 'resume' |
| jobIds | string[] | Yes | Job IDs to query |
| timeoutSeconds | number | No | Long-poll timeout (0–3600, default 90) |
Outputs (HTTP 200 JSON)
| Name | Type | Description |
|---|---|---|
| target | 'generation' | Always 'generation' |
| action | string | The action performed |
| reports | array | Per-job reports with status, progress, result URLs, errors |
Usage Examples
Long-Poll for Job Completion
# Long-poll: wait up to 90s for jobs to complete
curl -X POST http://localhost:5199/generate/progress \
-H 'Content-Type: application/json' \
-d '{"target":"generation","action":"wait","jobIds":["abc-123"],"timeoutSeconds":90}'
Query Status (Non-Blocking)
curl -X POST http://localhost:5199/generate/progress \
-H 'Content-Type: application/json' \
-d '{"target":"generation","action":"status","jobIds":["abc-123"]}'
Programmatic (TypeScript)
// Response shape:
// {
// target: 'generation',
// action: 'wait',
// reports: [{
// jobId: 'abc-123',
// operationId: 'abc-123',
// status: 'completed',
// progress: 100,
// phase: 'completed',
// resultUrls: ['https://...'],
// }]
// }
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment