Skip to main content

git_iris/
messages.rs

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