bohay 0.9.4

Mission control for your AI coding agents
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
//! Color palette. "bohay vr46" — a near-black dark UI with a fluorescent
//! stabilo/Valentino-Rossi green accent for active/selected elements.

use ratatui::style::Color;

#[derive(Clone)]
pub struct Theme {
    // surfaces (dark → light)
    pub crust: Color,
    pub mantle: Color,
    pub base: Color,
    pub surface0: Color,
    pub surface1: Color,
    pub overlay0: Color,
    pub overlay1: Color,
    // text
    pub subtext0: Color,
    pub subtext1: Color,
    pub text: Color,
    // accents
    pub accent: Color,       // fluo green — brand, focus, active/selected
    pub sel_bg: Color,       // selection background (dark green tint)
    pub border: Color,       // pane border (unfocused) — grey
    pub border_focus: Color, // pane border (focused) — light grey/white
    pub green: Color,
    pub mint: Color,
    pub amber: Color,
    pub coral: Color,
}

impl Theme {
    pub fn noir() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x07, 0x07, 0x09),
            mantle: rgb(0x11, 0x11, 0x16), // pane background + inactive tabs + tab bar
            base: rgb(0x20, 0x20, 0x28),   // sidebar — a bit lighter than the pane
            surface0: rgb(0x1a, 0x1a, 0x20),
            surface1: rgb(0x25, 0x25, 0x2d),
            overlay0: rgb(0x4a, 0x4a, 0x54),
            overlay1: rgb(0x68, 0x68, 0x73),
            subtext0: rgb(0x93, 0x93, 0x9f),
            subtext1: rgb(0xb6, 0xb6, 0xc0),
            text: rgb(0xe7, 0xe7, 0xed),
            accent: rgb(0xc6, 0xff, 0x1a), // stabilo / VR46 fluo green
            sel_bg: rgb(0x33, 0x45, 0x0e), // dark green selection — stands out from the sidebar
            // Borders are filled (background), so keep the unfocused frame subtle
            // and let the focused one stand out by brightness alone.
            border: rgb(0x38, 0x38, 0x40), // subtle grey (unfocused pane frame)
            border_focus: rgb(0x8c, 0x8c, 0x96), // medium grey (focused pane frame)
            green: rgb(0x8f, 0xbc, 0x7a),  // sage (idle)
            mint: rgb(0x6f, 0xc6, 0xa3),   // mint (done)
            amber: rgb(0xe0, 0x9a, 0x4d),  // amber-orange (working)
            coral: rgb(0xe0, 0x6c, 0x66),  // coral (blocked)
        }
    }

    /// A near-black grayscale variant — no color, just contrast.
    pub fn mono() -> Self {
        let g = |v| Color::Rgb(v, v, v);
        Theme {
            crust: g(0x07),
            mantle: g(0x12),
            base: g(0x1e),
            surface0: g(0x18),
            surface1: g(0x28),
            overlay0: g(0x4a),
            overlay1: g(0x68),
            subtext0: g(0x93),
            subtext1: g(0xb6),
            text: g(0xec),
            accent: g(0xea), // near-white accent
            sel_bg: g(0x33),
            border: g(0x52),
            border_focus: g(0x90),
            // states by brightness: idle dim → blocked bright.
            green: g(0x82),
            mint: g(0xa6),
            amber: g(0xc8),
            coral: g(0xe6),
        }
    }

    /// Catppuccin **Mocha** — the dark flavour of the palette whose semantic
    /// names (crust/mantle/base/surface/overlay/subtext) this `Theme` borrows.
    /// Upstream hex values; the accent is Mocha's signature mauve.
    pub fn mocha() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x11, 0x11, 0x1b),
            mantle: rgb(0x18, 0x18, 0x25), // pane background
            base: rgb(0x1e, 0x1e, 0x2e),   // sidebar — Mocha's own `base`
            surface0: rgb(0x31, 0x32, 0x44),
            surface1: rgb(0x45, 0x47, 0x5a),
            overlay0: rgb(0x6c, 0x70, 0x86),
            overlay1: rgb(0x7f, 0x84, 0x9c),
            subtext0: rgb(0xa6, 0xad, 0xc8),
            subtext1: rgb(0xba, 0xc2, 0xde),
            text: rgb(0xcd, 0xd6, 0xf4),
            accent: rgb(0xcb, 0xa6, 0xf7), // mauve
            sel_bg: rgb(0x3f, 0x33, 0x59), // dark mauve tint
            border: rgb(0x45, 0x47, 0x5a),
            border_focus: rgb(0x7f, 0x84, 0x9c),
            green: rgb(0xa6, 0xe3, 0xa1), // idle
            mint: rgb(0x94, 0xe2, 0xd5),  // done (teal)
            amber: rgb(0xfa, 0xb3, 0x87), // working (peach)
            coral: rgb(0xf3, 0x8b, 0xa8), // blocked (red)
        }
    }

    /// Catppuccin **Macchiato** — one step lighter than Mocha. Upstream hexes.
    pub fn macchiato() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x18, 0x19, 0x26),
            mantle: rgb(0x1e, 0x20, 0x30),
            base: rgb(0x24, 0x27, 0x3a),
            surface0: rgb(0x36, 0x3a, 0x4f),
            surface1: rgb(0x49, 0x4d, 0x64),
            overlay0: rgb(0x6e, 0x73, 0x8d),
            overlay1: rgb(0x80, 0x87, 0xa2),
            subtext0: rgb(0xa5, 0xad, 0xcb),
            subtext1: rgb(0xb8, 0xc0, 0xe0),
            text: rgb(0xca, 0xd3, 0xf5),
            accent: rgb(0xc6, 0xa0, 0xf6), // mauve
            sel_bg: rgb(0x3b, 0x32, 0x54),
            border: rgb(0x49, 0x4d, 0x64),
            border_focus: rgb(0x80, 0x87, 0xa2),
            green: rgb(0xa6, 0xda, 0x95),
            mint: rgb(0x8b, 0xd5, 0xca),
            amber: rgb(0xf5, 0xa9, 0x7f),
            coral: rgb(0xed, 0x87, 0x96),
        }
    }

    /// Catppuccin **Frappé** — the lightest of the three dark flavours.
    pub fn frappe() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x23, 0x26, 0x34),
            mantle: rgb(0x29, 0x2c, 0x3c),
            base: rgb(0x30, 0x34, 0x46),
            surface0: rgb(0x41, 0x45, 0x59),
            surface1: rgb(0x51, 0x57, 0x6d),
            overlay0: rgb(0x73, 0x79, 0x94),
            overlay1: rgb(0x83, 0x8b, 0xa7),
            subtext0: rgb(0xa5, 0xad, 0xce),
            subtext1: rgb(0xb5, 0xbf, 0xe2),
            text: rgb(0xc6, 0xd0, 0xf5),
            accent: rgb(0xca, 0x9e, 0xe6), // mauve
            sel_bg: rgb(0x46, 0x3e, 0x5e),
            border: rgb(0x51, 0x57, 0x6d),
            border_focus: rgb(0x83, 0x8b, 0xa7),
            green: rgb(0xa6, 0xd1, 0x89),
            mint: rgb(0x81, 0xc8, 0xbe),
            amber: rgb(0xef, 0x9f, 0x76),
            coral: rgb(0xe7, 0x82, 0x84),
        }
    }

    /// Gruvbox **dark** — retro warm earth tones. Upstream hex values; the accent
    /// is Gruvbox's bright yellow rather than its orange, which would sit too
    /// close to `redsands` once downsampled to 256 colors.
    pub fn gruvbox() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x1d, 0x20, 0x21),  // bg0_h
            mantle: rgb(0x28, 0x28, 0x28), // bg — pane background
            base: rgb(0x3c, 0x38, 0x36),   // bg1 — sidebar
            surface0: rgb(0x32, 0x30, 0x2f),
            surface1: rgb(0x50, 0x49, 0x45),
            overlay0: rgb(0x66, 0x5c, 0x54),
            overlay1: rgb(0x7c, 0x6f, 0x64),
            subtext0: rgb(0xa8, 0x99, 0x84),
            subtext1: rgb(0xbd, 0xae, 0x93),
            text: rgb(0xeb, 0xdb, 0xb2),
            accent: rgb(0xfa, 0xbd, 0x2f), // bright yellow
            sel_bg: rgb(0x45, 0x3d, 0x21), // dark amber tint
            border: rgb(0x50, 0x49, 0x45),
            border_focus: rgb(0x92, 0x83, 0x74),
            green: rgb(0xb8, 0xbb, 0x26), // idle
            mint: rgb(0x8e, 0xc0, 0x7c),  // done (aqua)
            amber: rgb(0xfe, 0x80, 0x19), // working (orange)
            coral: rgb(0xfb, 0x49, 0x34), // blocked (bright red)
        }
    }

    /// Gruvbox **light** — the same earth tones on cream, for light terminals.
    /// Surfaces run lightest-first here, like `latte`.
    pub fn gruvbox_light() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0xfb, 0xf1, 0xc7),  // bg0
            mantle: rgb(0xf2, 0xe5, 0xbc), // pane background
            base: rgb(0xeb, 0xdb, 0xb2),   // bg1 — sidebar
            surface0: rgb(0xd5, 0xc4, 0xa1),
            surface1: rgb(0xbd, 0xae, 0x93),
            overlay0: rgb(0xa8, 0x99, 0x84),
            overlay1: rgb(0x92, 0x83, 0x74),
            subtext0: rgb(0x66, 0x5c, 0x54),
            subtext1: rgb(0x50, 0x49, 0x45),
            text: rgb(0x3c, 0x38, 0x36),
            accent: rgb(0xaf, 0x3a, 0x03), // burnt orange, dark enough for cream
            sel_bg: rgb(0xe0, 0xc6, 0x8a),
            border: rgb(0xbd, 0xae, 0x93),
            border_focus: rgb(0x7c, 0x6f, 0x64),
            green: rgb(0x79, 0x74, 0x0e), // idle
            mint: rgb(0x42, 0x7b, 0x58),  // done (aqua)
            amber: rgb(0xb5, 0x76, 0x14), // working
            coral: rgb(0x9d, 0x00, 0x06), // blocked
        }
    }

    /// A warm light palette (Catppuccin-Latte-ish) for light terminals.
    pub fn latte() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0xef, 0xf1, 0xf5),
            mantle: rgb(0xe6, 0xe9, 0xef),
            base: rgb(0xdc, 0xe0, 0xe8),
            surface0: rgb(0xcc, 0xd0, 0xda),
            surface1: rgb(0xbc, 0xc0, 0xcc),
            overlay0: rgb(0x9c, 0xa0, 0xb0),
            overlay1: rgb(0x7c, 0x80, 0x90),
            subtext0: rgb(0x6c, 0x6f, 0x85),
            subtext1: rgb(0x50, 0x52, 0x6c),
            text: rgb(0x4c, 0x4f, 0x69),
            accent: rgb(0x40, 0xa0, 0x2b), // green, darkened for light bg
            sel_bg: rgb(0xc6, 0xe8, 0xa8),
            border: rgb(0xac, 0xb0, 0xbe),
            border_focus: rgb(0x7c, 0x80, 0x90),
            green: rgb(0x40, 0xa0, 0x2b),
            mint: rgb(0x17, 0x92, 0x99),
            amber: rgb(0xdf, 0x8e, 0x1d),
            coral: rgb(0xd2, 0x0f, 0x39),
        }
    }

    /// "Ocean" — a deep cmd/PowerShell blue with a bright cyan accent.
    pub fn ocean() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x02, 0x10, 0x2a),
            mantle: rgb(0x06, 0x1d, 0x42),
            base: rgb(0x0c, 0x2e, 0x5e),
            surface0: rgb(0x05, 0x22, 0x4a),
            surface1: rgb(0x12, 0x3a, 0x6e),
            overlay0: rgb(0x35, 0x58, 0x86),
            overlay1: rgb(0x52, 0x76, 0xa4),
            subtext0: rgb(0x8f, 0xa8, 0xc8),
            subtext1: rgb(0xb8, 0xcc, 0xe6),
            text: rgb(0xe8, 0xf2, 0xff),
            accent: rgb(0x46, 0xc6, 0xff), // bright cyan
            sel_bg: rgb(0x12, 0x3e, 0x76),
            border: rgb(0x2a, 0x4e, 0x80),
            border_focus: rgb(0x5a, 0x86, 0xc0),
            green: rgb(0x6f, 0xcf, 0x97),
            mint: rgb(0x4f, 0xd6, 0xc8),
            amber: rgb(0xf2, 0xc1, 0x4e),
            coral: rgb(0xf0, 0x6a, 0x6a),
        }
    }

    /// "Homebrew" — the classic green-on-black terminal.
    pub fn homebrew() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x00, 0x00, 0x00),
            mantle: rgb(0x04, 0x0a, 0x04),
            base: rgb(0x08, 0x16, 0x08),
            surface0: rgb(0x06, 0x10, 0x06),
            surface1: rgb(0x0e, 0x24, 0x0e),
            overlay0: rgb(0x1e, 0x4c, 0x1e),
            overlay1: rgb(0x2e, 0x6c, 0x2e),
            subtext0: rgb(0x22, 0xb4, 0x22),
            subtext1: rgb(0x2e, 0xe0, 0x2e),
            text: rgb(0x3c, 0xff, 0x3c),   // bright green
            accent: rgb(0x00, 0xff, 0x41), // neon green
            sel_bg: rgb(0x0a, 0x3a, 0x0a),
            border: rgb(0x1a, 0x4e, 0x1a),
            border_focus: rgb(0x2e, 0xa8, 0x2e),
            green: rgb(0x35, 0xe0, 0x35),
            mint: rgb(0x5e, 0xff, 0xb0),
            amber: rgb(0xc8, 0xff, 0x3c),
            coral: rgb(0xff, 0x60, 0x50),
        }
    }

    /// "Red Sands" — warm dark red with a bright orange accent.
    pub fn red_sands() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x1f, 0x0a, 0x06),
            mantle: rgb(0x38, 0x12, 0x0c),
            base: rgb(0x4e, 0x1c, 0x12),
            surface0: rgb(0x2c, 0x0e, 0x08),
            surface1: rgb(0x5c, 0x26, 0x1a),
            overlay0: rgb(0x8a, 0x4a, 0x38),
            overlay1: rgb(0xa8, 0x68, 0x54),
            subtext0: rgb(0xc8, 0x9a, 0x80),
            subtext1: rgb(0xdc, 0xba, 0x9c),
            text: rgb(0xf2, 0xda, 0xba),   // warm tan
            accent: rgb(0xff, 0x8a, 0x3c), // orange
            sel_bg: rgb(0x70, 0x2e, 0x1e),
            border: rgb(0x7c, 0x3c, 0x2a),
            border_focus: rgb(0xba, 0x6e, 0x4c),
            green: rgb(0xa6, 0xbf, 0x5e),
            mint: rgb(0x5e, 0xc8, 0xa8),
            amber: rgb(0xff, 0xb4, 0x54),
            coral: rgb(0xff, 0x6a, 0x5a),
        }
    }

    /// "Grass" — a deep green field with pale-yellow text.
    pub fn grass() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x05, 0x20, 0x12),
            mantle: rgb(0x0a, 0x36, 0x1d),
            base: rgb(0x10, 0x4c, 0x28),
            surface0: rgb(0x08, 0x2c, 0x18),
            surface1: rgb(0x15, 0x58, 0x30),
            overlay0: rgb(0x36, 0x78, 0x50),
            overlay1: rgb(0x54, 0x96, 0x6c),
            subtext0: rgb(0xa8, 0xc8, 0x98),
            subtext1: rgb(0xc8, 0xe0, 0xae),
            text: rgb(0xff, 0xf0, 0xa5),   // pale yellow
            accent: rgb(0xbe, 0xe6, 0x32), // lime
            sel_bg: rgb(0x1a, 0x6c, 0x3a),
            border: rgb(0x28, 0x76, 0x48),
            border_focus: rgb(0x56, 0xa6, 0x6c),
            green: rgb(0x8f, 0xd0, 0x7a),
            mint: rgb(0x5e, 0xd6, 0xb0),
            amber: rgb(0xf2, 0xc8, 0x4e),
            coral: rgb(0xf0, 0x6a, 0x5a),
        }
    }

    /// "Dracula" — the famous dark theme: indigo with a violet accent.
    pub fn dracula() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x1a, 0x1b, 0x23),
            mantle: rgb(0x28, 0x2a, 0x36),
            base: rgb(0x33, 0x36, 0x47),
            surface0: rgb(0x21, 0x22, 0x2c),
            surface1: rgb(0x3c, 0x3f, 0x52),
            overlay0: rgb(0x56, 0x58, 0x69),
            overlay1: rgb(0x62, 0x72, 0xa4),
            subtext0: rgb(0xa0, 0xa4, 0xc0),
            subtext1: rgb(0xcc, 0xce, 0xe0),
            text: rgb(0xf8, 0xf8, 0xf2),
            accent: rgb(0xbd, 0x93, 0xf9), // purple
            sel_bg: rgb(0x44, 0x47, 0x5a),
            border: rgb(0x44, 0x47, 0x5a),
            border_focus: rgb(0x62, 0x72, 0xa4),
            green: rgb(0x50, 0xfa, 0x7b),
            mint: rgb(0x8b, 0xe9, 0xfd),
            amber: rgb(0xff, 0xb8, 0x6c),
            coral: rgb(0xff, 0x55, 0x55),
        }
    }

    /// "Nord" — a cool arctic blue-grey palette.
    pub fn nord() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x24, 0x29, 0x33),
            mantle: rgb(0x2e, 0x34, 0x40),
            base: rgb(0x3b, 0x42, 0x52),
            surface0: rgb(0x29, 0x2f, 0x3a),
            surface1: rgb(0x43, 0x4c, 0x5e),
            overlay0: rgb(0x4c, 0x56, 0x6a),
            overlay1: rgb(0x61, 0x6e, 0x88),
            subtext0: rgb(0xb0, 0xb8, 0xc8),
            subtext1: rgb(0xd8, 0xde, 0xe9),
            text: rgb(0xec, 0xef, 0xf4),
            accent: rgb(0x88, 0xc0, 0xd0), // frost cyan
            sel_bg: rgb(0x3b, 0x4a, 0x5e),
            border: rgb(0x43, 0x4c, 0x5e),
            border_focus: rgb(0x6a, 0x76, 0x90),
            green: rgb(0xa3, 0xbe, 0x8c),
            mint: rgb(0x8f, 0xbc, 0xbb),
            amber: rgb(0xeb, 0xcb, 0x8b),
            coral: rgb(0xbf, 0x61, 0x6a),
        }
    }

    /// "Sunset" — a neon synthwave palette: deep purple with a hot-pink accent.
    pub fn sunset() -> Self {
        let rgb = |r, g, b| Color::Rgb(r, g, b);
        Theme {
            crust: rgb(0x16, 0x0a, 0x1e),
            mantle: rgb(0x22, 0x10, 0x30),
            base: rgb(0x2e, 0x16, 0x40),
            surface0: rgb(0x1c, 0x0d, 0x2a),
            surface1: rgb(0x3a, 0x1d, 0x50),
            overlay0: rgb(0x5a, 0x3a, 0x70),
            overlay1: rgb(0x7a, 0x5a, 0x90),
            subtext0: rgb(0xb8, 0x9a, 0xd0),
            subtext1: rgb(0xd6, 0xbc, 0xe8),
            text: rgb(0xf6, 0xe8, 0xff),
            accent: rgb(0xff, 0x5f, 0xd0), // hot pink
            sel_bg: rgb(0x4a, 0x24, 0x66),
            border: rgb(0x4a, 0x2a, 0x64),
            border_focus: rgb(0x8a, 0x5a, 0xa8),
            green: rgb(0x5f, 0xe0, 0xa8),
            mint: rgb(0x5f, 0xd6, 0xe0),
            amber: rgb(0xff, 0xb5, 0x4f),
            coral: rgb(0xff, 0x5f, 0x8f),
        }
    }

    /// Downsample every color to the nearest xterm-256 index, for terminals
    /// without truecolor support.
    pub fn to_256(&self) -> Theme {
        let c = crate::ipc::protocol::to_256;
        Theme {
            crust: c(self.crust),
            mantle: c(self.mantle),
            base: c(self.base),
            surface0: c(self.surface0),
            surface1: c(self.surface1),
            overlay0: c(self.overlay0),
            overlay1: c(self.overlay1),
            subtext0: c(self.subtext0),
            subtext1: c(self.subtext1),
            text: c(self.text),
            accent: c(self.accent),
            sel_bg: c(self.sel_bg),
            border: c(self.border),
            border_focus: c(self.border_focus),
            green: c(self.green),
            mint: c(self.mint),
            amber: c(self.amber),
            coral: c(self.coral),
        }
    }
}

/// Built-in palette names, in display order (first is the default).
pub const THEMES: &[&str] = &[
    "noir",
    "ocean",
    "dracula",
    "nord",
    "catppuccin-mocha",
    "catppuccin-macchiato",
    "catppuccin-frappe",
    "gruvbox",
    "sunset",
    "homebrew",
    "grass",
    "redsands",
    "catppuccin-latte",
    "gruvbox-light",
    "mono",
];

/// Map a stored theme name onto its current registry name. The Catppuccin
/// palettes were originally registered as bare `latte`/`mocha`; a config written
/// then must keep working rather than silently falling back to `noir`.
pub fn canonical(name: &str) -> &str {
    match name {
        "latte" => "catppuccin-latte",
        "mocha" => "catppuccin-mocha",
        "macchiato" => "catppuccin-macchiato",
        "frappe" => "catppuccin-frappe",
        "gruvboxlight" => "gruvbox-light",
        other => other,
    }
}

/// A theme by name; unknown names fall back to `noir`.
pub fn by_name(name: &str) -> Theme {
    match name {
        "ocean" => Theme::ocean(),
        "homebrew" => Theme::homebrew(),
        "redsands" => Theme::red_sands(),
        "grass" => Theme::grass(),
        "dracula" => Theme::dracula(),
        "nord" => Theme::nord(),
        "catppuccin-mocha" | "mocha" => Theme::mocha(),
        "catppuccin-macchiato" | "macchiato" => Theme::macchiato(),
        "catppuccin-frappe" | "frappe" => Theme::frappe(),
        "gruvbox" => Theme::gruvbox(),
        "gruvbox-light" | "gruvboxlight" => Theme::gruvbox_light(),
        "sunset" => Theme::sunset(),
        "catppuccin-latte" | "latte" => Theme::latte(),
        "mono" => Theme::mono(),
        _ => Theme::noir(),
    }
}

/// One-line description of a palette, for the Settings UI.
pub fn describe(name: &str) -> &'static str {
    match name {
        "ocean" => "deep cmd-blue, cyan accent",
        "homebrew" => "classic green-on-black",
        "redsands" => "warm dark red, orange accent",
        "grass" => "green field, pale-yellow text",
        "dracula" => "indigo dark, violet accent",
        "nord" => "cool arctic blue-grey",
        "catppuccin-mocha" | "mocha" => "darkest Catppuccin, mauve",
        "catppuccin-macchiato" | "macchiato" => "softer dark Catppuccin",
        "catppuccin-frappe" | "frappe" => "lightest dark Catppuccin",
        "gruvbox" => "retro warm dark, yellow accent",
        "gruvbox-light" | "gruvboxlight" => "Gruvbox on cream, burnt orange",
        "sunset" => "neon synthwave, hot-pink",
        "catppuccin-latte" | "latte" => "light Catppuccin, warm",
        "mono" => "grayscale, no accent color",
        _ => "near-black, fluo-green accent",
    }
}

/// Agent / pane activity state. Drives sidebar glyphs and colors.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum State {
    Blocked,
    Working,
    Done,
    Idle,
    Unknown,
}

impl State {
    pub fn dot(self) -> &'static str {
        match self {
            State::Idle | State::Unknown => "",
            _ => "",
        }
    }

    pub fn color(self, t: &Theme) -> Color {
        match self {
            State::Blocked => t.coral,
            State::Working => t.amber,
            State::Done => t.mint,
            State::Idle => t.green,
            State::Unknown => t.overlay0,
        }
    }

    pub fn label(self) -> &'static str {
        match self {
            State::Blocked => "blocked",
            State::Working => "working",
            State::Done => "done",
            State::Idle => "idle",
            State::Unknown => "",
        }
    }
}

/// The working spinner's frames: a braille mark rotating around the **middle**
/// of the cell, so it sits level with the `○`/`●` dots on neighbouring rows.
///
/// A braille cell has four dot rows, and which rows a glyph uses decides where it
/// sits vertically. The classic CLI spinner (`⠋⠙⠹…`) uses dots 1-6 (the upper
/// three rows) and visibly rides high; the bottom two rows (dots 3/6/7/8) ride
/// just as visibly low. These frames use dots **2/3/5/6** — rows two and three —
/// which is the vertical centre of the cell.
///
/// Each frame is one edge of that 2x2 dot square, so the mark sweeps clockwise:
/// left → top → right → bottom. Every frame is exactly two dots, so the spinner
/// keeps constant weight as it turns (no pulsing).
///
/// Glyph choice matters for alignment, so don't swap these casually:
///
/// * **Every frame is the same width.** Braille (U+2800..=U+28FF) is East Asian
///   *Neutral* — exactly one column in every terminal, whatever its
///   ambiguous-width setting. The old half-circle set (`◐◓◑◒`) mixed classes:
///   `◐`/`◑` are *Ambiguous* (2 cells wherever a terminal draws ambiguous glyphs
///   wide) while `◒`/`◓` are Narrow, so the icon changed size every other frame
///   and drifted against the 1-column slot ratatui reserves for it.
/// * **Every frame carries the same ink.** All ten are six-dot patterns, so the
///   spinner never looks like it grows or shrinks as it turns.
/// * **Font coverage is effectively universal.** Braille is *the* spinner block,
///   so there is no fallback to another face at a different size.
///
/// [`state_glyphs_are_one_column`] guards these properties.
const FRAMES: [&str; 4] = ["", "", "", ""];

/// Frames in one full revolution. Iterate this instead of hardcoding a count so
/// changing the animation can't silently desync a caller or a test.
pub const SPINNER_FRAMES: u64 = FRAMES.len() as u64;

/// One frame of the "working" spinner, advanced by `App.spinner` while an agent
/// is working — a busy agent shows live motion instead of a static `●`.
pub fn spinner_frame(n: u64) -> &'static str {
    FRAMES[(n % SPINNER_FRAMES) as usize]
}

#[cfg(test)]
mod tests {
    use super::*;

    // The agent-state icon sits in a one-column slot: ratatui lays the row out
    // with `UnicodeWidthStr::width` (== 1 for all of these), so any glyph a
    // terminal draws two cells wide pushes the label right and breaks the column.
    // Requiring `width_cjk == 1` too keeps every icon *unambiguously* narrow, so
    // the slot is honored even where ambiguous-width glyphs render wide — and
    // every spinner frame stays exactly the same size as the static dots.
    #[test]
    fn state_glyphs_are_one_column() {
        use unicode_width::UnicodeWidthStr;
        let mut glyphs: Vec<&str> = [
            State::Blocked,
            State::Working,
            State::Done,
            State::Idle,
            State::Unknown,
        ]
        .iter()
        .map(|s| s.dot())
        .collect();
        glyphs.extend((0..SPINNER_FRAMES).map(spinner_frame));

        for g in glyphs {
            assert_eq!(g.chars().count(), 1, "{g:?} must be a single glyph");
            assert_eq!(g.width(), 1, "{g:?} must occupy one column");
        }

        // The regression this guards: the spinner animates *in place*, so if its
        // frames disagree on East Asian width the icon visibly changes size as it
        // turns (the old `◐◓◑◒` mixed Ambiguous `◐`/`◑` with Narrow `◒`/`◓`).
        // Every frame must sit in the same width class as every other.
        let widths: std::collections::HashSet<usize> = (0..SPINNER_FRAMES)
            .map(|i| spinner_frame(i).width_cjk())
            .collect();
        assert_eq!(
            widths.len(),
            1,
            "spinner frames disagree on East Asian width, so the icon changes \
             size mid-animation: {:?}",
            (0..SPINNER_FRAMES)
                .map(|i| (spinner_frame(i), spinner_frame(i).width_cjk()))
                .collect::<Vec<_>>()
        );
        // The static dots must likewise agree with each other, so an idle row and
        // a blocked row never sit at different widths.
        assert_eq!(
            State::Idle.dot().width_cjk(),
            State::Blocked.dot().width_cjk(),
            "the idle and active dots must be the same width class"
        );

        // The four frames must be distinct, or the spinner would stutter…
        let frames: std::collections::HashSet<&str> =
            (0..SPINNER_FRAMES).map(spinner_frame).collect();
        assert_eq!(
            frames.len() as u64,
            SPINNER_FRAMES,
            "spinner frames must all differ"
        );
        // …and it must cycle with that period.
        assert_eq!(spinner_frame(0), spinner_frame(SPINNER_FRAMES));
    }

    #[test]
    fn theme_registry_is_consistent() {
        // Every listed palette resolves, has a description, and a distinct accent
        // (guards against adding a name to THEMES but forgetting by_name/describe).
        let mut swatches = std::collections::HashSet::new();
        // The picker swatch is (background, accent) and is downsampled to 256
        // colors on non-truecolor terminals — the *pair* must stay distinct, or two
        // rows look identical. A pair rather than the accent alone, because the
        // Catppuccin flavours deliberately share an accent and differ by surface.
        let mut swatches_256 = std::collections::HashSet::new();
        for &name in THEMES {
            assert!(!describe(name).is_empty(), "{name} needs a description");
            let pal = by_name(name);
            assert!(
                swatches.insert(format!("{:?}{:?}", pal.base, pal.accent)),
                "{name} should have a distinct background+accent swatch"
            );
            let px = crate::ipc::protocol::to_256(pal.base);
            let pa = crate::ipc::protocol::to_256(pal.accent);
            assert!(
                swatches_256.insert(format!("{px:?}{pa:?}")),
                "{name}'s swatch must stay distinct after 256-color downsampling"
            );
        }
        assert!(THEMES.len() >= 15, "the new palettes are registered");

        // Legacy config values must keep resolving to the same palette.
        for (old, new) in [
            ("mocha", "catppuccin-mocha"),
            ("latte", "catppuccin-latte"),
            ("gruvboxlight", "gruvbox-light"),
        ] {
            assert_eq!(canonical(old), new, "{old} should map to {new}");
            assert_eq!(
                format!("{:?}", by_name(old).accent),
                format!("{:?}", by_name(new).accent),
                "{old} must still resolve to the {new} palette"
            );
        }
    }
}