gitai/core/
messages.rs

1use crate::ui::{
2    AURORA_GREEN, CELESTIAL_BLUE, COMET_ORANGE, GALAXY_PINK, METEOR_RED, NEBULA_PURPLE,
3    PLASMA_CYAN, SOLAR_YELLOW, STARLIGHT,
4};
5use rand::seq::IndexedRandom;
6use ratatui::style::Color;
7use std::sync::LazyLock;
8
9#[derive(Clone, Debug)]
10pub struct ColoredMessage {
11    pub text: String,
12    pub color: Color,
13}
14
15impl ColoredMessage {
16    fn from_static(text: &'static str, color: Color) -> Self {
17        Self {
18            text: text.to_string(),
19            color,
20        }
21    }
22}
23
24macro_rules! messages {
25    ($($text:expr => $color:expr),+ $(,)?) => {
26        vec![
27            $(ColoredMessage::from_static($text, $color)),+
28        ]
29    };
30}
31
32static WAITING_MESSAGES: LazyLock<Vec<ColoredMessage>> = LazyLock::new(|| {
33    messages![
34        "Consulting the cosmic commit oracle..." => NEBULA_PURPLE,
35        "Aligning the celestial code spheres..." => CELESTIAL_BLUE,
36        "Channeling the spirit of clean commits..." => AURORA_GREEN,
37        "Launching commit ideas into the coding cosmos..." => METEOR_RED,
38        "Exploring the galaxy of potential messages..." => PLASMA_CYAN,
39        "Peering into the commit-verse for inspiration..." => SOLAR_YELLOW,
40        "Casting a spell for the perfect commit message..." => GALAXY_PINK,
41        "Harnessing the power of a thousand code stars..." => STARLIGHT,
42        "Orbiting the planet of precise git descriptions..." => CELESTIAL_BLUE,
43        "Weaving a tapestry of colorful commit prose..." => PLASMA_CYAN,
44        "Igniting the fireworks of code brilliance..." => COMET_ORANGE,
45        "Syncing with the collective coding consciousness..." => AURORA_GREEN,
46        "Aligning the moon phases for optimal commit clarity..." => STARLIGHT,
47        "Analyzing code particles at the quantum level..." => NEBULA_PURPLE,
48        "Decoding the DNA of your changes..." => GALAXY_PINK,
49        "Summoning the ancient spirits of version control..." => METEOR_RED,
50        "Tuning into the frequency of flawless commits..." => CELESTIAL_BLUE,
51        "Charging the commit crystals with cosmic energy..." => PLASMA_CYAN,
52        "Translating your changes into universal code..." => AURORA_GREEN,
53        "Distilling the essence of your modifications..." => SOLAR_YELLOW,
54        "Unraveling the threads of your code tapestry..." => NEBULA_PURPLE,
55        "Consulting the all-knowing git guardians..." => CELESTIAL_BLUE,
56        "Harmonizing with the rhythms of the coding universe..." => GALAXY_PINK,
57        "Diving into the depths of the code ocean..." => PLASMA_CYAN,
58        "Seeking wisdom from the repository sages..." => AURORA_GREEN,
59        "Calibrating the commit compass for true north..." => SOLAR_YELLOW,
60        "Unlocking the secrets of the commit constellations..." => NEBULA_PURPLE,
61        "Gathering stardust for your stellar commit..." => STARLIGHT,
62        "Focusing the lens of the code telescope..." => CELESTIAL_BLUE,
63        "Riding the waves of inspiration through the code cosmos..." => PLASMA_CYAN,
64    ]
65});
66
67static REVIEW_WAITING_MESSAGES: LazyLock<Vec<ColoredMessage>> = LazyLock::new(|| {
68    messages![
69        "Scanning code dimensions for quality signatures..." => NEBULA_PURPLE,
70        "Traversing the architecture cosmos for patterns..." => CELESTIAL_BLUE,
71        "Invoking the guardians of code integrity..." => AURORA_GREEN,
72        "Illuminating shadow bugs with code starlight..." => STARLIGHT,
73        "Gazing into the crystal orb of future maintainability..." => PLASMA_CYAN,
74        "Unrolling the ancient scrolls of best practices..." => SOLAR_YELLOW,
75        "Distilling your code into its purest essence..." => GALAXY_PINK,
76        "Weighing your code on the scales of elegance..." => CELESTIAL_BLUE,
77        "Tracing the rainbow paths between your functions..." => AURORA_GREEN,
78        "Magnifying the subtle harmonies in your algorithms..." => NEBULA_PURPLE,
79        "Communing with the collective wisdom of master coders..." => METEOR_RED,
80        "Diving into the depths of your code ocean..." => PLASMA_CYAN,
81        "Consulting the monoliths of software architecture..." => COMET_ORANGE,
82        "Sifting through the time sands of execution paths..." => SOLAR_YELLOW,
83        "Assembling the puzzle pieces of your code story..." => GALAXY_PINK,
84        "Analyzing code particles at quantum precision..." => CELESTIAL_BLUE,
85        "Measuring the brightness of your code stars..." => STARLIGHT,
86        "Following the threads of logic throughout your tapestry..." => AURORA_GREEN,
87        "Summoning the trident of code quality dimensions..." => NEBULA_PURPLE,
88        "Spiraling through nested layers of abstraction..." => PLASMA_CYAN,
89        "Examining the ancient artifacts of your repository..." => METEOR_RED,
90        "Unmasking the hidden characters in your code drama..." => GALAXY_PINK,
91        "Warding off evil bugs with protective insights..." => CELESTIAL_BLUE,
92        "Forging stronger code in the flames of analysis..." => COMET_ORANGE,
93        "Nurturing the seeds of excellence in your codebase..." => AURORA_GREEN,
94        "Pinpointing opportunities for cosmic refinement..." => SOLAR_YELLOW,
95        "Mapping the intricate web of dependencies..." => NEBULA_PURPLE,
96        "Calibrating the tools of code enlightenment..." => PLASMA_CYAN,
97        "Computing the algorithms of optimal elegance..." => STARLIGHT,
98        "Charting the trajectory of your code evolution..." => CELESTIAL_BLUE,
99    ]
100});
101
102/// Returns a random waiting message for commit operations
103pub fn get_waiting_message() -> &'static ColoredMessage {
104    WAITING_MESSAGES
105        .choose(&mut rand::rng())
106        .expect("WAITING_MESSAGES should never be empty")
107}
108
109/// Returns a random waiting message for code review operations
110pub fn get_review_waiting_message() -> &'static ColoredMessage {
111    REVIEW_WAITING_MESSAGES
112        .choose(&mut rand::rng())
113        .expect("REVIEW_WAITING_MESSAGES should never be empty")
114}
115
116#[cfg(test)]
117mod tests {
118    use super::*;
119
120    #[test]
121    fn test_waiting_messages_not_empty() {
122        assert!(!WAITING_MESSAGES.is_empty());
123        assert!(!REVIEW_WAITING_MESSAGES.is_empty());
124    }
125
126    #[test]
127    fn test_get_messages_returns_valid() {
128        let msg = get_waiting_message();
129        assert!(!msg.text.is_empty());
130
131        let review_msg = get_review_waiting_message();
132        assert!(!review_msg.text.is_empty());
133    }
134}