catfood-bar 0.3.0

A system bar component of the catfood utility suite
Documentation
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
use ratatui::{prelude::Stylize, style::Color, text::Span};
use serde::Deserialize;
use std::process::Command;

use crate::logging;

#[derive(Deserialize, Debug)]
struct KittyWindow {
    #[serde(default)]
    is_active: bool,
    #[serde(default)]
    is_focused: bool,
    #[serde(default)]
    last_focused: bool,
    tabs: Vec<KittyTab>,
}

#[derive(Deserialize, Debug)]
struct KittyTab {
    title: String,
    #[serde(default)]
    is_active: bool,
}

#[derive(Debug, Clone)]
pub struct TabInfo {
    title: String,
    is_active: bool,
}

#[derive(Debug, Default, Clone)]
pub struct KittyTabs {
    pub tabs: Vec<TabInfo>,
    kitty_pid: Option<u32>,
    socket_path: Option<String>,
}

impl KittyTabs {
    pub fn new() -> Self {
        Self::with_config(None)
    }

    pub fn with_config(socket_path: Option<String>) -> Self {
        Self {
            tabs: get_kitty_tabs(socket_path.as_deref()).unwrap_or_default(),
            kitty_pid: get_focused_kitty_pid(),
            socket_path,
        }
    }

    pub fn update(&mut self) {
        self.kitty_pid = get_focused_kitty_pid();
        self.tabs = if let Some(pid) = self.kitty_pid {
            get_kitty_tabs_for_pid(pid, self.socket_path.as_deref()).unwrap_or_default()
        } else {
            Vec::new()
        };
    }

    pub fn render_as_spans(&self, colorize: bool) -> Vec<Span<'_>> {
        if self.tabs.is_empty() {
            return vec![];
        }

        self.tabs
            .iter()
            .map(|tab| {
                if tab.is_active {
                    // Active tab: show icon + full title
                    let icon = get_tab_icon(&tab.title);
                    let title = truncate_title(&tab.title, true);
                    let content = format!(" {} {} ", icon, title);
                    if colorize {
                        let (bg_color, fg_color) = get_tab_color(&tab.title);
                        Span::raw(content).bg(bg_color).fg(fg_color)
                    } else {
                        Span::raw(content).bg(Color::White).fg(Color::Black)
                    }
                } else {
                    // Inactive tab: show icon only (very compact)
                    let content = format!(" {} ", get_tab_icon(&tab.title));
                    if colorize {
                        Span::raw(content).fg(Color::Rgb(103, 117, 140)) // Kitty gray text
                    } else {
                        Span::raw(content).fg(Color::White)
                    }
                }
            })
            .collect::<Vec<Span>>()
    }
}

fn truncate_title(title: &str, is_active: bool) -> String {
    // NOTE: This might be redundant given that we always get_tab_icon for non-active tabs below.
    // TODO: Make these truncation lengths configurable constants instead of magic numbers
    // Allow users to customize max title lengths via configuration
    let max_len = if is_active { 16 } else { 12 }; // Account for icon in active tabs
    if title.len() > max_len {
        format!("{}...", &title[..max_len - 3])
    } else {
        title.to_string()
    }
}

// TODO: Refactor this large match statement to use a data-driven approach
// Consider extracting to a HashMap lookup or creating separate modules by category
// This would improve maintainability and make adding new applications easier
fn get_tab_color(title: &str) -> (Color, Color) {
    let title_lower = title.to_lowercase();

    // Terminal-based applications - use title
    if title_lower.starts_with("nvim") || title_lower.contains("neovim") {
        return (Color::Rgb(0, 107, 84), Color::White); // Neovim Green
    } else if title_lower.starts_with("vim") {
        return (Color::Rgb(19, 134, 71), Color::White); // Vim Green
    } else if title_lower.starts_with("emacs") {
        return (Color::Rgb(146, 35, 127), Color::White); // Emacs Purple
    } else if title_lower.starts_with("htop") || title_lower.starts_with("btop") {
        return (Color::Rgb(255, 152, 0), Color::Black); // System Monitor Orange
    } else if title_lower.starts_with("yazi") {
        return (Color::Rgb(255, 200, 87), Color::Black); // Yazi Yellow
    } else if title_lower.starts_with("ranger") || title_lower.starts_with("lf") {
        return (Color::Rgb(41, 128, 185), Color::White); // File Manager Blue
    } else if title_lower.starts_with("git") {
        return (Color::Rgb(240, 80, 50), Color::White); // Git Orange
    } else if title_lower.starts_with("ssh") {
        return (Color::Rgb(0, 100, 200), Color::White); // SSH Blue
    } else if title_lower.starts_with("cmus") || title_lower.starts_with("ncmpcpp") {
        return (Color::Rgb(29, 185, 84), Color::White); // Music Green
    } else if title_lower.starts_with("docker") {
        return (Color::Rgb(41, 128, 185), Color::White); // Docker Blue
    } else if title_lower.starts_with("node") || title_lower.starts_with("npm") {
        return (Color::Rgb(102, 77, 255), Color::White); // Node.js Green
    } else if title_lower.starts_with("python") || title_lower.starts_with("python3") {
        return (Color::Rgb(53, 114, 165), Color::White); // Python Blue
    } else if title_lower.starts_with("rustc") || title_lower.contains("cargo") {
        return (Color::Rgb(222, 76, 65), Color::White); // Rust Orange
    } else if title_lower.starts_with("go") {
        return (Color::Rgb(0, 173, 216), Color::Black); // Go Cyan
    } else if title_lower.starts_with("java") {
        return (Color::Rgb(255, 87, 34), Color::White); // Java Orange
    } else if title_lower.starts_with("k9s") || title_lower.starts_with("kubectl") {
        return (Color::Rgb(61, 90, 254), Color::White); // Kubernetes Blue
    } else if title_lower.starts_with("terraform") || title_lower.starts_with("tf") {
        return (Color::Rgb(94, 103, 110), Color::White); // Terraform Gray
    } else if title_lower.starts_with("lazygit") || title_lower.starts_with("gitui") {
        return (Color::Rgb(240, 80, 50), Color::White); // Git UI Orange
    } else if title_lower.starts_with("tmux") || title_lower.starts_with("screen") {
        return (Color::Rgb(46, 52, 64), Color::White); // Terminal Multiplexer Dark
    } else if title_lower.starts_with("weechat") || title_lower.starts_with("irssi") {
        return (Color::Rgb(254, 0, 84), Color::White); // IRC Red
    } else if title_lower.starts_with("neomutt") || title_lower.starts_with("mutt") {
        return (Color::Rgb(0, 112, 193), Color::White); // Email Blue
    } else if title_lower.starts_with("newsboat") || title_lower.starts_with("nnn") {
        return (Color::Rgb(255, 193, 7), Color::Black); // News Yellow
    } else if title_lower.starts_with("glow") || title_lower.starts_with("mdcat") {
        return (Color::Rgb(33, 150, 243), Color::White); // Markdown Blue
    } else if title_lower.starts_with("tig") || title_lower.starts_with("lazydocker") {
        return (Color::Rgb(240, 80, 50), Color::White); // Git TUI Orange
    } else if title_lower.starts_with("jq") || title_lower.starts_with("yq") {
        return (Color::Rgb(0, 150, 136), Color::White); // JSON/YAML Teal
    } else if title_lower.starts_with("sqlite3")
        || title_lower.starts_with("mysql")
        || title_lower.starts_with("redis-cli")
        || title_lower.starts_with("psql")
    {
        return (Color::Rgb(40, 167, 69), Color::White); // Database Green
    } else if title_lower.starts_with("gh") || title_lower.starts_with("hub") {
        return (Color::Rgb(29, 185, 84), Color::White); // GitHub Green
    } else if title_lower.starts_with("opencode")
        || title_lower.contains("opencode")
        || title_lower.starts_with("oc |")
    {
        return (Color::Rgb(88, 101, 242), Color::White); // OpenCode Blue
    } else if title_lower.contains("watch") || title_lower.contains("tail") {
        return (Color::Rgb(156, 39, 176), Color::White); // Watch Purple
    } else if title_lower.starts_with("wget") || title_lower.starts_with("curl") {
        return (Color::Rgb(52, 152, 219), Color::White); // Network Blue
    } else if title_lower.starts_with("make") || title_lower.starts_with("cmake") {
        return (Color::Rgb(230, 126, 34), Color::White); // Build Orange
    } else if title_lower.starts_with("gdb") || title_lower.starts_with("lldb") {
        return (Color::Rgb(231, 76, 60), Color::White); // Debugger Red
    } else if title_lower.starts_with("hugo") || title_lower.starts_with("jekyll") {
        return (Color::Rgb(155, 89, 182), Color::White); // SSG Purple
    } else if title_lower.starts_with("pip") || title_lower.starts_with("poetry") {
        return (Color::Rgb(53, 114, 165), Color::White); // Python Package Blue
    } else if title_lower.starts_with("deno") || title_lower.starts_with("bun") {
        return (Color::Rgb(46, 125, 50), Color::White); // JS Runtime Green
    } else if title_lower.starts_with("zig") || title_lower.starts_with("nim") {
        return (Color::Rgb(222, 76, 65), Color::White); // Compiled Lang Orange
    }

    // Default fallback for shells and other terminals
    (Color::Rgb(103, 117, 140), Color::White) // Kitty Gray
}

// TODO: Refactor this large match statement to use a HashMap or macro approach
// Consider separating into different modules by category (editors, tools, etc.)
// This 130+ line function is difficult to maintain and extend
fn get_tab_icon(title: &str) -> String {
    let title_lower = title.to_lowercase();

    // Check for common terminal programs first
    if title_lower.starts_with("nvim") || title_lower.contains("neovim") {
        return "".to_string();
    } else if title_lower.starts_with("vim") {
        return "".to_string();
    } else if title_lower.starts_with("emacs") {
        return "󰍹".to_string();
    } else if title_lower.starts_with("nano") {
        return "".to_string();
    } else if title_lower.starts_with("htop") || title_lower.starts_with("btop") {
        return "󰔚".to_string();
    } else if title_lower.starts_with("yazi") {
        return "󰇥".to_string();
    } else if title_lower.starts_with("ranger") || title_lower.starts_with("lf") {
        return "󰉋".to_string();
    } else if title_lower.starts_with("git") {
        return "󰊢".to_string();
    } else if title_lower.starts_with("man") {
        return "󰍹".to_string();
    } else if title_lower.starts_with("ssh") {
        return "󰣀".to_string();
    } else if title_lower.starts_with("cmus") || title_lower.starts_with("ncmpcpp") {
        return "󰓇".to_string();
    } else if title_lower.starts_with("docker") {
        return "󰡨".to_string();
    } else if title_lower.starts_with("node") || title_lower.starts_with("npm") {
        return "󰎙".to_string();
    } else if title_lower.starts_with("python") || title_lower.starts_with("python3") {
        return "󰌠".to_string();
    } else if title_lower.starts_with("rustc") || title_lower.contains("cargo") {
        return "󱘗".to_string();
    } else if title_lower.starts_with("go") {
        return "󰟦".to_string();
    } else if title_lower.starts_with("java") {
        return "󰬙".to_string();
    } else if title_lower.starts_with("fish")
        || title_lower.starts_with("bash")
        || title_lower.starts_with("zsh")
    {
        return "󰆍".to_string();
    } else if title_lower.contains("watch") || title_lower.contains("tail") {
        return "󰈰".to_string();
    } else if title_lower.starts_with("wget") || title_lower.starts_with("curl") {
        return "󰈁".to_string();
    } else if title_lower.contains("edit") || title_lower.contains("vi") {
        return "".to_string();
    } else if title_lower.starts_with("opencode")
        || title_lower.contains("opencode")
        || title_lower.starts_with("oc |")
    {
        return "󰚩".to_string();
    } else if title_lower.starts_with("lazygit") || title_lower.starts_with("gitui") {
        return "󰊢".to_string();
    } else if title_lower.starts_with("bat")
        || title_lower.starts_with("less")
        || title_lower.starts_with("more")
    {
        return "󰈚".to_string();
    } else if title_lower.starts_with("exa")
        || title_lower.starts_with("lsd")
        || title_lower.starts_with("tree")
    {
        return "󰉋".to_string();
    } else if title_lower.starts_with("fd")
        || title_lower.starts_with("find")
        || title_lower.starts_with("rg")
        || title_lower.starts_with("grep")
        || title_lower.starts_with("ag")
    {
        return "󰍉".to_string();
    } else if title_lower.starts_with("k9s") || title_lower.starts_with("kubectl") {
        return "󱃾".to_string();
    } else if title_lower.starts_with("terraform") || title_lower.starts_with("tf") {
        return "󱁢".to_string();
    } else if title_lower.starts_with("ansible") || title_lower.starts_with("ansible-playbook") {
        return "󰔚".to_string();
    } else if title_lower.starts_with("tmux") || title_lower.starts_with("screen") {
        return "󰆍".to_string();
    } else if title_lower.starts_with("weechat") || title_lower.starts_with("irssi") {
        return "󰒱".to_string();
    } else if title_lower.starts_with("neomutt") || title_lower.starts_with("mutt") {
        return "󰇰".to_string();
    } else if title_lower.starts_with("newsboat") || title_lower.starts_with("nnn") {
        return "󰎕".to_string();
    } else if title_lower.starts_with("ncdu") || title_lower.starts_with("du") {
        return "󰉋".to_string();
    } else if title_lower.starts_with("glow") || title_lower.starts_with("mdcat") {
        return "󰍹".to_string();
    } else if title_lower.starts_with("tig") || title_lower.starts_with("lazydocker") {
        return "󰊢".to_string();
    } else if title_lower.starts_with("fzf")
        || title_lower.starts_with("peco")
        || title_lower.starts_with("ripgrep-all")
        || title_lower.starts_with("rga")
    {
        return "󰍉".to_string();
    } else if title_lower.starts_with("jq") || title_lower.starts_with("yq") {
        return "󰉼".to_string();
    } else if title_lower.starts_with("bottom") || title_lower.starts_with("glances") {
        return "󰔚".to_string();
    } else if title_lower.starts_with("nmap") || title_lower.starts_with("netstat") {
        return "󰈁".to_string();
    } else if title_lower.starts_with("hugo") || title_lower.starts_with("jekyll") {
        return "󰀶".to_string();
    } else if title_lower.starts_with("pip") || title_lower.starts_with("poetry") {
        return "󰌠".to_string();
    } else if title_lower.starts_with("deno") || title_lower.starts_with("bun") {
        return "󰎙".to_string();
    } else if title_lower.starts_with("zig") || title_lower.starts_with("nim") {
        return "󱘗".to_string();
    } else if title_lower.starts_with("make") || title_lower.starts_with("cmake") {
        return "󰔧".to_string();
    } else if title_lower.starts_with("gdb") || title_lower.starts_with("lldb") {
        return "󰃤".to_string();
    } else if title_lower.starts_with("strace")
        || title_lower.starts_with("ltrace")
        || title_lower.starts_with("valgrind")
    {
        return "󰔚".to_string();
    } else if title_lower.starts_with("wireshark") || title_lower.starts_with("tshark") {
        return "󰈁".to_string();
    } else if title_lower.starts_with("sqlite3")
        || title_lower.starts_with("mysql")
        || title_lower.starts_with("redis-cli")
        || title_lower.starts_with("psql")
    {
        return "󰆼".to_string();
    } else if title_lower.starts_with("gh") || title_lower.starts_with("hub") {
        return "󰊢".to_string();
    } else if title_lower.starts_with("alacritty") || title_lower.starts_with("foot") {
        return "󰆍".to_string();
    } else if title_lower.starts_with("nvim-qt") || title_lower.starts_with("gvim") {
        return "".to_string();
    }

    // Default shell/terminal icon
    "󰆍".to_string()
}

// TODO: Consider caching the Kitty PID for short periods to reduce hyprctl calls
// This would improve performance by avoiding repeated system calls during update cycles
fn get_focused_kitty_pid() -> Option<u32> {
    let active_output = Command::new("hyprctl")
        .args(["activewindow", "-j"])
        .output()
        .ok()?;

    if !active_output.status.success() {
        return None;
    }

    let active_stdout = String::from_utf8(active_output.stdout).ok()?;
    if let Ok(active_window) = serde_json::from_str::<serde_json::Value>(&active_stdout)
        && let (Some(class), Some(pid)) = (
            active_window.get("class").and_then(|v| v.as_str()),
            active_window.get("pid").and_then(|v| v.as_u64()),
        )
    {
        // Only return if the active window is a Kitty window
        if class == "kitty" {
            // Check if this Kitty instance uses --single-instance flag
            if is_single_instance_kitty(pid as u32) {
                return Some(pid as u32);
            }
        }
    }

    None
}

fn is_single_instance_kitty(pid: u32) -> bool {
    let output = match Command::new("pgrep")
        .args(["-f", "kitty.*--single-instance"])
        .output()
    {
        Ok(output) => output,
        Err(_) => return false,
    };

    if !output.status.success() {
        return false;
    }

    let stdout = match String::from_utf8(output.stdout) {
        Ok(stdout) => stdout,
        Err(_) => return false,
    };
    for pid_str in stdout.lines() {
        if let Ok(found_pid) = pid_str.parse::<u32>()
            && found_pid == pid
        {
            return true;
        }
    }

    false
}

// TODO: This function appears redundant - consider removing and using get_kitty_tabs_for_pid directly
// The socket_path parameter makes this wrapper unnecessary
fn get_kitty_tabs(socket_path: Option<&str>) -> Option<Vec<TabInfo>> {
    if let Some(pid) = get_focused_kitty_pid() {
        get_kitty_tabs_for_pid(pid, socket_path)
    } else {
        None
    }
}

fn get_kitty_tabs_for_pid(pid: u32, socket_path: Option<&str>) -> Option<Vec<TabInfo>> {
    let socket_path_str = match socket_path {
        Some(path) => path.to_string(),
        None => format!("/tmp/kitty-{}", pid),
    };

    let output = Command::new("kitty")
        .args(["@", "--to", &format!("unix:{}", socket_path_str), "ls"])
        .output()
        .ok()?;

    if !output.status.success() {
        logging::log_component_error(
            "KITTY_TABS",
            str::from_utf8(&output.stderr).unwrap_or("unknown error"),
        );
        return None;
    }

    let stdout = str::from_utf8(&output.stdout).unwrap();
    let windows: Vec<KittyWindow> = serde_json::from_str(stdout).ok()?;

    for window in windows {
        if window.is_active || window.is_focused || window.last_focused {
            let tabs: Vec<TabInfo> = window
                .tabs
                .into_iter()
                .enumerate()
                .map(|(index, tab)| TabInfo {
                    title: if tab.title.is_empty() {
                        format!("Tab {}", index + 1)
                    } else {
                        tab.title
                    },
                    is_active: tab.is_active,
                })
                .collect();

            return Some(tabs);
        }
    }

    None
}

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

    #[test]
    fn test_kitty_tabs_new() {
        let kitty_tabs = KittyTabs::new();
        assert!(kitty_tabs.kitty_pid.is_none() || kitty_tabs.kitty_pid.is_some());
        assert!(kitty_tabs.socket_path.is_none());
    }

    #[test]
    fn test_kitty_tabs_with_config() {
        let socket_path = Some("/tmp/custom-kitty".to_string());
        let kitty_tabs = KittyTabs::with_config(socket_path.clone());
        assert!(kitty_tabs.kitty_pid.is_none() || kitty_tabs.kitty_pid.is_some());
        assert_eq!(kitty_tabs.socket_path, socket_path);
    }

    #[test]
    fn test_kitty_tabs_update() {
        let mut kitty_tabs = KittyTabs::new();
        kitty_tabs.update();

        let mut kitty_tabs_with_config = KittyTabs::with_config(Some("/tmp/test".to_string()));
        kitty_tabs_with_config.update();
    }

    #[test]
    fn test_kitty_tabs_render_empty() {
        let kitty_tabs = KittyTabs {
            tabs: vec![],
            kitty_pid: None,
            socket_path: None,
        };
        let spans = kitty_tabs.render_as_spans(true);
        assert_eq!(spans.len(), 0);
    }

    #[test]
    fn test_kitty_tabs_render_with_tabs() {
        let kitty_tabs = KittyTabs {
            tabs: vec![
                TabInfo {
                    title: "Tab 1".to_string(),
                    is_active: false,
                },
                TabInfo {
                    title: "Active Tab".to_string(),
                    is_active: true,
                },
            ],
            kitty_pid: Some(12345),
            socket_path: None,
        };
        let spans = kitty_tabs.render_as_spans(true);
        assert_eq!(spans.len(), 2);

        // Check that active tab includes icon + title
        let active_content = spans[1].content.clone();
        assert!(active_content.contains("󰆍")); // Default shell icon
        assert!(active_content.contains("Active Tab"));
    }

    #[test]
    fn test_truncate_title() {
        let long_title = "This is a very long tab title that should be truncated";
        let truncated = truncate_title(long_title, true);
        assert!(truncated.len() <= 20);
        assert!(truncated.ends_with("..."));

        let short_title = "Short title";
        let not_truncated = truncate_title(short_title, false);
        assert_eq!(not_truncated, short_title);
    }

    #[test]
    fn test_get_tab_icon() {
        assert_eq!(get_tab_icon("nvim config"), "");
        assert_eq!(get_tab_icon("vim /etc/fstab"), "");
        assert_eq!(get_tab_icon("htop"), "󰔚");
        assert_eq!(get_tab_icon("opencode help"), "󰚩");
        assert_eq!(get_tab_icon("lazygit"), "󰊢");
        assert_eq!(get_tab_icon("bat README.md"), "󰈚");
        assert_eq!(get_tab_icon("k9s"), "󱃾");
        assert_eq!(get_tab_icon("fzf"), "󰍉");
        assert_eq!(get_tab_icon("random command"), "󰆍"); // default shell icon
    }

    #[test]
    fn test_active_tab_with_icon() {
        let kitty_tabs = KittyTabs {
            tabs: vec![TabInfo {
                title: "opencode help".to_string(),
                is_active: true,
            }],
            kitty_pid: Some(12345),
            socket_path: None,
        };
        let spans = kitty_tabs.render_as_spans(true);
        assert_eq!(spans.len(), 1);

        let content = spans[0].content.clone();
        assert!(content.contains("󰚩")); // OpenCode icon
        assert!(content.contains("opencode"));
    }
}