Skip to main content

par_term_config/config/config_struct/
automation_config.rs

1//! Trigger, coprocess and observer-script definitions.
2//!
3//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
4//! All fields serialise at the top level of the YAML config file -- existing
5//! config files remain 100% compatible.
6
7use std::collections::HashMap;
8
9use serde::{Deserialize, Serialize};
10
11/// Regex triggers, coprocess definitions and external observer scripts.
12#[derive(Debug, Clone, Default, Serialize, Deserialize)]
13pub struct AutomationConfig {
14    /// Regex trigger definitions that match terminal output and fire actions
15    #[serde(default)]
16    pub triggers: Vec<crate::automation::TriggerConfig>,
17
18    /// Coprocess definitions for piped subprocess management
19    #[serde(default)]
20    pub coprocesses: Vec<crate::automation::CoprocessDefConfig>,
21
22    /// External observer script definitions
23    #[serde(default)]
24    pub scripts: Vec<crate::scripting::ScriptConfig>,
25
26    /// Plugin state entries (O2 Phase 3); empty until the user enables one.
27    #[serde(default)]
28    pub plugins: Vec<PluginStateConfig>,
29}
30
31/// Per-plugin persisted state (one `plugins:` list entry).
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct PluginStateConfig {
34    /// Manifest id; must match a discovered plugin.
35    pub id: String,
36    /// Whether the host may run this plugin. Defaults to false: plugins are
37    /// land-disabled, so a dropped-in plugin directory does nothing until
38    /// the Settings layer flips this bit.
39    #[serde(default = "default_plugin_disabled")]
40    pub enabled: bool,
41    /// Persisted settings values; validated against the manifest schema at
42    /// apply time, not parse time.
43    #[serde(default)]
44    pub settings: HashMap<String, serde_json::Value>,
45    /// Status-bar section placement override; the manifest default is used
46    /// when absent.
47    #[serde(default, skip_serializing_if = "Option::is_none")]
48    pub section: Option<crate::status_bar::StatusBarSection>,
49}
50
51/// `PluginStateConfig::enabled` serde seed: plugins land disabled.
52fn default_plugin_disabled() -> bool {
53    false
54}
55
56impl Default for PluginStateConfig {
57    fn default() -> Self {
58        Self {
59            id: String::new(),
60            enabled: default_plugin_disabled(),
61            settings: HashMap::new(),
62            section: None,
63        }
64    }
65}