git_iris/
messages.rs

1use crate::theme;
2use crate::theme::adapters::ratatui::ToRatatuiColor;
3use rand::prelude::*;
4use ratatui::style::Color;
5use std::sync::LazyLock;
6
7/// A message with a theme-based color token
8#[derive(Clone)]
9pub struct ColoredMessage {
10    pub text: String,
11    pub token: &'static str,
12}
13
14impl ColoredMessage {
15    /// Get the resolved color from the current theme
16    pub fn color(&self) -> Color {
17        theme::current().color(self.token).to_ratatui()
18    }
19}
20
21static WAITING_MESSAGES: LazyLock<Vec<ColoredMessage>> = LazyLock::new(|| {
22    vec![
23        // Cosmic vibes
24        ColoredMessage {
25            text: "๐Ÿ”ฎ Consulting the commit oracle...".to_string(),
26            token: "accent.deep",
27        },
28        ColoredMessage {
29            text: "โœจ Weaving stardust into your message...".to_string(),
30            token: "text.primary",
31        },
32        ColoredMessage {
33            text: "๐ŸŒŒ Exploring the commit-verse...".to_string(),
34            token: "accent.secondary",
35        },
36        ColoredMessage {
37            text: "๐Ÿ”ญ Peering through the code telescope...".to_string(),
38            token: "accent.secondary",
39        },
40        ColoredMessage {
41            text: "โญ Aligning the celestial diffs...".to_string(),
42            token: "text.primary",
43        },
44        ColoredMessage {
45            text: "๐ŸŒ™ Reading your changes by moonlight...".to_string(),
46            token: "accent.secondary",
47        },
48        // Nerdy & clever
49        ColoredMessage {
50            text: "๐ŸŽฒ Rolling for commit inspiration...".to_string(),
51            token: "success",
52        },
53        ColoredMessage {
54            text: "๐Ÿงฌ Decoding the DNA of your changes...".to_string(),
55            token: "accent.tertiary",
56        },
57        ColoredMessage {
58            text: "๐Ÿ”ฌ Analyzing diff particles...".to_string(),
59            token: "accent.deep",
60        },
61        ColoredMessage {
62            text: "๐Ÿ“ก Tuning into the commit frequency...".to_string(),
63            token: "accent.secondary",
64        },
65        ColoredMessage {
66            text: "๐Ÿงช Distilling the essence of your changes...".to_string(),
67            token: "success",
68        },
69        ColoredMessage {
70            text: "โšก Parsing the diff matrix...".to_string(),
71            token: "warning",
72        },
73        // Warm & grounded
74        ColoredMessage {
75            text: "โ˜• Brewing a fresh commit message...".to_string(),
76            token: "warning",
77        },
78        ColoredMessage {
79            text: "๐ŸŽจ Painting your changes in prose...".to_string(),
80            token: "accent.tertiary",
81        },
82        ColoredMessage {
83            text: "๐Ÿงฉ Piecing together the story...".to_string(),
84            token: "accent.secondary",
85        },
86        ColoredMessage {
87            text: "๐ŸŽต Composing a commit symphony...".to_string(),
88            token: "accent.deep",
89        },
90        ColoredMessage {
91            text: "๐Ÿ’Ž Polishing your commit to a shine...".to_string(),
92            token: "accent.secondary",
93        },
94        ColoredMessage {
95            text: "๐ŸŒฟ Growing ideas from your diff...".to_string(),
96            token: "success",
97        },
98        // Playful
99        ColoredMessage {
100            text: "๐Ÿš€ Launching into commit space...".to_string(),
101            token: "error",
102        },
103        ColoredMessage {
104            text: "๐Ÿ—บ๏ธ Charting the diff territory...".to_string(),
105            token: "warning",
106        },
107        ColoredMessage {
108            text: "๐ŸŒŠ Riding the code waves...".to_string(),
109            token: "accent.secondary",
110        },
111        ColoredMessage {
112            text: "๐Ÿฆ‰ Consulting the git guardians...".to_string(),
113            token: "accent.secondary",
114        },
115        ColoredMessage {
116            text: "๐Ÿงญ Calibrating the commit compass...".to_string(),
117            token: "warning",
118        },
119        ColoredMessage {
120            text: "๐Ÿ” Unlocking the secrets of your diff...".to_string(),
121            token: "accent.deep",
122        },
123        ColoredMessage {
124            text: "๐ŸŽ Wrapping up your changes nicely...".to_string(),
125            token: "text.primary",
126        },
127        ColoredMessage {
128            text: "๐Ÿ„ Surfing the staged changes...".to_string(),
129            token: "success",
130        },
131    ]
132});
133
134static REVIEW_WAITING_MESSAGES: LazyLock<Vec<ColoredMessage>> = LazyLock::new(|| {
135    vec![
136        // Cosmic & mystical
137        ColoredMessage {
138            text: "๐Ÿ”ฎ Gazing into the code quality crystal...".to_string(),
139            token: "accent.deep",
140        },
141        ColoredMessage {
142            text: "โœจ Illuminating the hidden corners...".to_string(),
143            token: "text.primary",
144        },
145        ColoredMessage {
146            text: "๐ŸŒŸ Channeling review wisdom...".to_string(),
147            token: "accent.secondary",
148        },
149        ColoredMessage {
150            text: "๐ŸŒ™ Meditating on your abstractions...".to_string(),
151            token: "accent.secondary",
152        },
153        ColoredMessage {
154            text: "๐Ÿ”ญ Scanning the code horizon...".to_string(),
155            token: "accent.deep",
156        },
157        ColoredMessage {
158            text: "โญ Reading the code constellations...".to_string(),
159            token: "text.primary",
160        },
161        // Nerdy & technical
162        ColoredMessage {
163            text: "๐Ÿ”ฌ Analyzing code under the microscope...".to_string(),
164            token: "success",
165        },
166        ColoredMessage {
167            text: "๐Ÿงฌ Sequencing your code genome...".to_string(),
168            token: "accent.tertiary",
169        },
170        ColoredMessage {
171            text: "๐Ÿ“ก Scanning for code anomalies...".to_string(),
172            token: "accent.secondary",
173        },
174        ColoredMessage {
175            text: "๐Ÿงช Running quality experiments...".to_string(),
176            token: "success",
177        },
178        ColoredMessage {
179            text: "โšก Tracing the logic pathways...".to_string(),
180            token: "warning",
181        },
182        ColoredMessage {
183            text: "๐ŸŽฒ Rolling perception checks...".to_string(),
184            token: "warning",
185        },
186        // Exploratory
187        ColoredMessage {
188            text: "๐Ÿ—บ๏ธ Mapping your code architecture...".to_string(),
189            token: "warning",
190        },
191        ColoredMessage {
192            text: "๐Ÿ” Hunting for hidden issues...".to_string(),
193            token: "error",
194        },
195        ColoredMessage {
196            text: "๐Ÿงญ Navigating your control flow...".to_string(),
197            token: "accent.deep",
198        },
199        ColoredMessage {
200            text: "๐ŸŠ Diving into the logic depths...".to_string(),
201            token: "accent.secondary",
202        },
203        ColoredMessage {
204            text: "โ›๏ธ Mining for code gems...".to_string(),
205            token: "warning",
206        },
207        ColoredMessage {
208            text: "๐ŸŒŠ Flowing through your functions...".to_string(),
209            token: "accent.secondary",
210        },
211        // Warm & grounded
212        ColoredMessage {
213            text: "โ˜• Taking a thoughtful look...".to_string(),
214            token: "warning",
215        },
216        ColoredMessage {
217            text: "๐ŸŽจ Appreciating your code craft...".to_string(),
218            token: "accent.tertiary",
219        },
220        ColoredMessage {
221            text: "๐Ÿงฉ Piecing together the full picture...".to_string(),
222            token: "accent.secondary",
223        },
224        ColoredMessage {
225            text: "๐Ÿ’Ž Searching for rough edges to polish...".to_string(),
226            token: "accent.secondary",
227        },
228        ColoredMessage {
229            text: "๐Ÿฆ‰ Consulting the wise owl...".to_string(),
230            token: "success",
231        },
232        ColoredMessage {
233            text: "๐Ÿ“œ Checking against best practices...".to_string(),
234            token: "warning",
235        },
236        ColoredMessage {
237            text: "๐ŸŽต Listening to your code's rhythm...".to_string(),
238            token: "accent.deep",
239        },
240        ColoredMessage {
241            text: "๐ŸŒฟ Tending the code garden...".to_string(),
242            token: "success",
243        },
244    ]
245});
246
247static USER_MESSAGES: LazyLock<Vec<ColoredMessage>> = LazyLock::new(|| {
248    vec![
249        ColoredMessage {
250            text: "๐Ÿš€ Launching...".to_string(),
251            token: "error",
252        },
253        ColoredMessage {
254            text: "โœจ Working magic...".to_string(),
255            token: "text.primary",
256        },
257        ColoredMessage {
258            text: "๐Ÿ”ฎ Divining...".to_string(),
259            token: "accent.deep",
260        },
261        ColoredMessage {
262            text: "โšก Processing...".to_string(),
263            token: "accent.secondary",
264        },
265        ColoredMessage {
266            text: "๐ŸŒŒ Exploring...".to_string(),
267            token: "accent.secondary",
268        },
269        ColoredMessage {
270            text: "๐Ÿ”ฌ Analyzing...".to_string(),
271            token: "success",
272        },
273        ColoredMessage {
274            text: "โ˜• Brewing...".to_string(),
275            token: "warning",
276        },
277        ColoredMessage {
278            text: "๐ŸŽจ Crafting...".to_string(),
279            token: "accent.tertiary",
280        },
281        ColoredMessage {
282            text: "๐Ÿงฉ Piecing...".to_string(),
283            token: "accent.secondary",
284        },
285        ColoredMessage {
286            text: "๐Ÿ’Ž Polishing...".to_string(),
287            token: "accent.secondary",
288        },
289        ColoredMessage {
290            text: "๐ŸŽต Composing...".to_string(),
291            token: "accent.deep",
292        },
293        ColoredMessage {
294            text: "๐ŸŒŠ Flowing...".to_string(),
295            token: "success",
296        },
297        ColoredMessage {
298            text: "๐Ÿ”ญ Scanning...".to_string(),
299            token: "warning",
300        },
301        ColoredMessage {
302            text: "๐Ÿงช Testing...".to_string(),
303            token: "warning",
304        },
305        ColoredMessage {
306            text: "๐ŸŒฟ Growing...".to_string(),
307            token: "success",
308        },
309    ]
310});
311
312pub fn get_waiting_message() -> ColoredMessage {
313    let mut rng = rand::rng();
314    WAITING_MESSAGES
315        .choose(&mut rng)
316        .cloned()
317        .unwrap_or_else(|| ColoredMessage {
318            text: "Processing your request...".to_string(),
319            token: "warning",
320        })
321}
322
323pub fn get_review_waiting_message() -> ColoredMessage {
324    let mut rng = rand::rng();
325    REVIEW_WAITING_MESSAGES
326        .choose(&mut rng)
327        .cloned()
328        .unwrap_or_else(|| ColoredMessage {
329            text: "Analyzing your code quality...".to_string(),
330            token: "accent.deep",
331        })
332}
333
334/// Get a waiting message appropriate for the given capability
335pub fn get_capability_message(capability: &str) -> ColoredMessage {
336    match capability {
337        "review" => get_review_waiting_message(),
338        "pr" => get_pr_waiting_message(),
339        "changelog" => get_changelog_waiting_message(),
340        "release_notes" => get_release_notes_waiting_message(),
341        // "commit" and any other capability use the default cosmic messages
342        _ => get_waiting_message(),
343    }
344}
345
346static PR_WAITING_MESSAGES: std::sync::LazyLock<Vec<ColoredMessage>> =
347    std::sync::LazyLock::new(|| {
348        vec![
349            ColoredMessage {
350                text: "๐Ÿ”ฎ Crafting your PR narrative...".to_string(),
351                token: "accent.deep",
352            },
353            ColoredMessage {
354                text: "โœจ Weaving your commits into a story...".to_string(),
355                token: "text.primary",
356            },
357            ColoredMessage {
358                text: "๐Ÿ“ Summarizing your brilliant work...".to_string(),
359                token: "accent.secondary",
360            },
361            ColoredMessage {
362                text: "๐ŸŽฏ Distilling the essence of your changes...".to_string(),
363                token: "accent.secondary",
364            },
365            ColoredMessage {
366                text: "๐ŸŒŸ Highlighting your contributions...".to_string(),
367                token: "success",
368            },
369            ColoredMessage {
370                text: "๐Ÿ“‹ Building your PR description...".to_string(),
371                token: "warning",
372            },
373            ColoredMessage {
374                text: "๐ŸŽจ Painting the PR picture...".to_string(),
375                token: "accent.tertiary",
376            },
377            ColoredMessage {
378                text: "๐Ÿงต Threading your commits together...".to_string(),
379                token: "warning",
380            },
381        ]
382    });
383
384static CHANGELOG_WAITING_MESSAGES: std::sync::LazyLock<Vec<ColoredMessage>> =
385    std::sync::LazyLock::new(|| {
386        vec![
387            ColoredMessage {
388                text: "๐Ÿ“œ Chronicling your changes...".to_string(),
389                token: "accent.deep",
390            },
391            ColoredMessage {
392                text: "โœจ Cataloging your accomplishments...".to_string(),
393                token: "text.primary",
394            },
395            ColoredMessage {
396                text: "๐Ÿ“– Writing the history of your code...".to_string(),
397                token: "accent.secondary",
398            },
399            ColoredMessage {
400                text: "๐Ÿ›๏ธ Archiving your progress...".to_string(),
401                token: "accent.secondary",
402            },
403            ColoredMessage {
404                text: "๐Ÿ”– Tagging your milestones...".to_string(),
405                token: "success",
406            },
407            ColoredMessage {
408                text: "๐Ÿ“ Documenting the journey...".to_string(),
409                token: "warning",
410            },
411            ColoredMessage {
412                text: "๐Ÿ—‚๏ธ Organizing your achievements...".to_string(),
413                token: "accent.tertiary",
414            },
415            ColoredMessage {
416                text: "โšก Capturing the deltas...".to_string(),
417                token: "warning",
418            },
419        ]
420    });
421
422static RELEASE_NOTES_WAITING_MESSAGES: std::sync::LazyLock<Vec<ColoredMessage>> =
423    std::sync::LazyLock::new(|| {
424        vec![
425            ColoredMessage {
426                text: "๐Ÿš€ Preparing launch notes...".to_string(),
427                token: "error",
428            },
429            ColoredMessage {
430                text: "โœจ Polishing the release highlights...".to_string(),
431                token: "text.primary",
432            },
433            ColoredMessage {
434                text: "๐Ÿ“ฃ Announcing your achievements...".to_string(),
435                token: "accent.deep",
436            },
437            ColoredMessage {
438                text: "๐ŸŽ‰ Celebrating the release...".to_string(),
439                token: "success",
440            },
441            ColoredMessage {
442                text: "๐Ÿ“ฆ Packaging the release story...".to_string(),
443                token: "accent.secondary",
444            },
445            ColoredMessage {
446                text: "๐ŸŒŸ Showcasing new features...".to_string(),
447                token: "accent.secondary",
448            },
449            ColoredMessage {
450                text: "๐Ÿ“ข Composing the release fanfare...".to_string(),
451                token: "warning",
452            },
453            ColoredMessage {
454                text: "๐ŸŽŠ Wrapping up the release...".to_string(),
455                token: "accent.tertiary",
456            },
457        ]
458    });
459
460fn get_pr_waiting_message() -> ColoredMessage {
461    let mut rng = rand::rng();
462    PR_WAITING_MESSAGES
463        .choose(&mut rng)
464        .cloned()
465        .unwrap_or_else(|| ColoredMessage {
466            text: "Building PR description...".to_string(),
467            token: "accent.deep",
468        })
469}
470
471fn get_changelog_waiting_message() -> ColoredMessage {
472    let mut rng = rand::rng();
473    CHANGELOG_WAITING_MESSAGES
474        .choose(&mut rng)
475        .cloned()
476        .unwrap_or_else(|| ColoredMessage {
477            text: "Generating changelog...".to_string(),
478            token: "accent.secondary",
479        })
480}
481
482fn get_release_notes_waiting_message() -> ColoredMessage {
483    let mut rng = rand::rng();
484    RELEASE_NOTES_WAITING_MESSAGES
485        .choose(&mut rng)
486        .cloned()
487        .unwrap_or_else(|| ColoredMessage {
488            text: "Creating release notes...".to_string(),
489            token: "success",
490        })
491}
492
493pub fn get_user_message() -> ColoredMessage {
494    let mut rng = rand::rng();
495    USER_MESSAGES
496        .choose(&mut rng)
497        .cloned()
498        .unwrap_or_else(|| ColoredMessage {
499            text: "What would you like to do?".to_string(),
500            token: "accent.secondary",
501        })
502}