# Generation jobs Active contributors: Douwe de Vries, vriesd ## Purpose Generation jobs run local provider CLIs in the background, stream progress back to the renderer, and persist the final output through the Rust core workflow. They keep long-running AI actions from blocking the Tauri command thread. ## Key source files | File | Purpose | | --- | --- | | `src-tauri/src/jobs.rs` | Job state, lifecycle, cancellation, partial text, and pruning. | | `src-tauri/src/commands/ai/job_runner.rs` | Starts background AI action jobs. | | `src-tauri/src/commands/ai/job_events.rs` | Event types sent to the frontend channel. | | `src-tauri/src/commands/ai/provider_execution.rs` | Provider readiness and execution wrapper. | | `src-tauri/src/commands/ai/streaming_exec.rs` | Spawns provider CLI, writes stdin, drains output, handles cancellation/watchdog. | | `crates/qa-scribe-core/src/generation/workflow.rs` | Prepare and finish persistence lifecycle. | | `frontend/src/app/generationActions.ts` | Frontend job start, event handling, and reconciliation. | ## Flow ```mermaid sequenceDiagram participant UI as Frontend participant Job as Tauri job_runner participant Core as Core generation workflow participant CLI as Provider CLI UI->>Job: start_ai_action_job Job->>Core: prepare_ai_action_generation Job->>CLI: run prompt on stdin CLI-->>Job: stream JSON/text chunks Job-->>UI: Progress and Partial events Job->>Core: finish_ai_action_generation Job-->>UI: Completed, Failed, or Cancelled ``` ## Integration points Generation jobs depend on [Provider detection](systems--provider-detection.md), [AI-assisted Testware](features--ai-assisted-testware.md), and [Rust core](systems--rust-core.md). The renderer subscribes to job events through `frontend/src/app/generationActions.ts`. ## Entry points for modification Change process behavior in `src-tauri/src/commands/ai/streaming_exec.rs`, job status behavior in `src-tauri/src/jobs.rs`, and persisted generation outcomes in `crates/qa-scribe-core/src/generation/workflow.rs`.