feat(background-task): rendu live des tâches de fond — subscriber UI + canal IPC (#58)

Câble un canal attachable au flux de sortie d'une tâche de fond (runner
infrastructure + commande app-tauri + port/adaptateurs frontend) et le
panneau ProjectWorkStatePanel s'y abonne pour un rendu live au lieu d'un
état figé au dernier snapshot.

Validations obtenues avant commit :
- cargo test -p infrastructure --test background_task_runner : vert
- cargo check -p backend -p app-tauri : vert
- npx vitest run src/features/workstate/workstate.test.tsx : vert
- npm run typecheck : vert
- verdict QA #58 : vert

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 16:48:29 +02:00
parent 6f532d7434
commit b734c237d3
17 changed files with 528 additions and 23 deletions

View File

@ -388,6 +388,18 @@ export interface ReattachResult {
scrollback: Uint8Array;
}
/** A UI subscription attached to one background task output stream. */
export interface BackgroundTaskAttachment {
/** Attached task id, echoed by the backend. */
taskId: string;
/** Retained bytes to repaint immediately before live chunks arrive. */
scrollback: Uint8Array;
/** Whether subsequent live bytes are expected on the supplied callback. */
live: boolean;
/** Detaches the local UI subscriber without cancelling the task. */
detach(): void;
}
/** Projects: create/open/close/list (L2). */
export interface ProjectGateway {
/** Lists the projects known to the registry. */
@ -932,6 +944,15 @@ export interface PermissionGateway {
export interface WorkStateGateway {
/** Reads the current per-agent live/offline and idle/busy state for a project. */
getProjectWorkState(projectId: string): Promise<ProjectWorkState>;
/**
* Attaches a UI output subscriber to a background task. Running tasks replay
* PTY scrollback and then stream live chunks; terminal tasks return only their
* persisted output tail.
*/
attachBackgroundTask(
taskId: string,
onData: (bytes: Uint8Array) => void,
): Promise<BackgroundTaskAttachment>;
/**
* Cancels a running/pending background task by id. The read-model refreshes
* through the `backgroundTaskChanged` domain event.