Skip to main content

treeship_core/session/
render.rs

1//! Render configuration for Explorer Session Reports.
2//!
3//! Lightweight hints embedded in the .treeship package that tell
4//! Explorer how to present the session receipt visually.
5
6use serde::{Deserialize, Serialize};
7
8/// Render configuration for the session report.
9#[derive(Debug, Clone, Default, Serialize, Deserialize)]
10pub struct RenderConfig {
11    /// Display title for the report.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub title: Option<String>,
14
15    /// Theme name (e.g., "default", "dark", "minimal").
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub theme: Option<String>,
18
19    /// Which sections to render and in what order.
20    #[serde(default, skip_serializing_if = "Vec::is_empty")]
21    pub sections: Vec<RenderSection>,
22
23    /// Whether to generate a preview.html in the package.
24    #[serde(default = "default_true")]
25    pub generate_preview: bool,
26}
27
28fn default_true() -> bool {
29    true
30}
31
32/// A section in the rendered report.
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct RenderSection {
35    /// Section identifier.
36    pub id: String,
37
38    /// Human-readable section label.
39    pub label: String,
40
41    /// Whether this section is visible by default.
42    #[serde(default = "default_true")]
43    pub visible: bool,
44}
45
46impl RenderConfig {
47    /// Default sections matching the spec's Explorer UX.
48    pub fn default_sections() -> Vec<RenderSection> {
49        vec![
50            RenderSection {
51                id: "summary".into(),
52                label: "Session Summary".into(),
53                visible: true,
54            },
55            RenderSection {
56                id: "participants".into(),
57                label: "Participant Strip".into(),
58                visible: true,
59            },
60            RenderSection {
61                id: "agent_graph".into(),
62                label: "Delegation & Collaboration Graph".into(),
63                visible: true,
64            },
65            RenderSection {
66                id: "timeline".into(),
67                label: "Mission Timeline".into(),
68                visible: true,
69            },
70            RenderSection {
71                id: "side_effects".into(),
72                label: "Side-Effect Ledger".into(),
73                visible: true,
74            },
75            RenderSection {
76                id: "proofs".into(),
77                label: "Proofs Panel".into(),
78                visible: true,
79            },
80        ]
81    }
82}