Skip to main content

distri_types/
thinking.rs

1//! Branded thinking/loading phrases shared between CLI and UI.
2
3use serde::Deserialize;
4
5const PHRASES_JSON: &str = include_str!("thinking_phrases.json");
6
7#[derive(Debug, Clone, Deserialize)]
8pub struct Phrase {
9    pub text: String,
10    pub emoji: String,
11    pub icon: String,
12}
13
14#[derive(Debug, Clone, Deserialize)]
15pub struct Phrases {
16    pub planning: Vec<Phrase>,
17    pub replanning: Vec<Phrase>,
18    pub thinking: Vec<Phrase>,
19}
20
21pub fn phrases() -> &'static Phrases {
22    use std::sync::OnceLock;
23    static PHRASES: OnceLock<Phrases> = OnceLock::new();
24    PHRASES.get_or_init(|| serde_json::from_str(PHRASES_JSON).expect("invalid thinking_phrases.json"))
25}
26
27/// Pick a phrase from a category using an index (wraps around).
28pub fn pick_planning(index: usize) -> &'static Phrase {
29    let p = &phrases().planning;
30    &p[index % p.len()]
31}
32
33pub fn pick_replanning(index: usize) -> &'static Phrase {
34    let p = &phrases().replanning;
35    &p[index % p.len()]
36}
37
38pub fn pick_thinking(index: usize) -> &'static Phrase {
39    let p = &phrases().thinking;
40    &p[index % p.len()]
41}