Skip to main content

forge_primitives/
background.rs

1//! The seat's live tasks, as a view reads it.
2//!
3//! The CLI announces its whole background registry on
4//! `background_tasks_changed`, and a long foreground call on `task_started`
5//! and `task_notification` only - it never enters that registry. Both are
6//! held on the session, because a view that attached after they arrived has
7//! no other way to learn what is running: the update stream carries them once.
8
9use serde::{Deserialize, Serialize};
10
11/// One of the seat's live tasks, with the command its own card carried where
12/// forge has seen both.
13#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
14pub struct BackgroundTask {
15    pub task_id: String,
16    /// Whether the CLI put the call in the background, as the frame that
17    /// announced it said. A registry entry is backgrounded by definition; a
18    /// long foreground call the CLI tracks rides here with `false` while it
19    /// runs, which is how a consumer tells the two kinds of hold apart.
20    pub is_backgrounded: bool,
21    /// The kind a view routes the row on: `local_bash` is the processes feed
22    /// (a backgrounded call, or a foreground one the CLI tracks while it
23    /// runs), an agent kind the sub-agent section.
24    pub task_type: String,
25    /// The line the row leads with, as the CLI wrote it.
26    pub description: String,
27    /// The command the task's own tool call carried, which is what an OS scan
28    /// adopts a detached process by. `None` when forge has not seen the card:
29    /// the task still draws, without one.
30    pub command: Option<String>,
31    /// The tool call that began the task, from the CLI's `task_started` link.
32    /// `None` until forge has seen it: the row draws without a call to reach.
33    pub tool_use_id: Option<String>,
34}