← back to gstrainovic__agent-session-manager

Function bodies 251 total

All specs Real LLM only Function bodies
test_load_sessions_with_progress function · rust · L434-L454 (21 LOC)
src/store.rs
    fn test_load_sessions_with_progress() {
        let (tmp, store) = create_test_store();

        let p1 = tmp.path().join("projects/project-a");
        fs::create_dir_all(&p1).unwrap();

        let line = r#"{"type":"user","message":{"role":"user","content":"msg"},"uuid":"x"}"#;
        fs::write(p1.join("s1.jsonl"), line).unwrap();
        fs::write(p1.join("s2.jsonl"), line).unwrap();

        let mut progress_calls = Vec::new();
        let sessions = store
            .load_sessions_with_progress(|loaded, total| {
                progress_calls.push((loaded, total));
            })
            .unwrap();

        assert_eq!(sessions.len(), 2);
        assert_eq!(progress_calls.len(), 1);
        assert_eq!(progress_calls[0], (2, 2));
    }
test_slug_to_path_resolves_home function · rust · L457-L463 (7 LOC)
src/store.rs
    fn test_slug_to_path_resolves_home() {
        // "-home-g" should resolve to /home/g if it exists
        let result = slug_to_path("-home-g");
        if PathBuf::from("/home/g").is_dir() {
            assert_eq!(result, Some(PathBuf::from("/home/g")));
        }
    }
test_move_to_trash_moves_file function · rust · L479-L490 (12 LOC)
src/store.rs
    fn test_move_to_trash_moves_file() {
        let (tmp, store) = create_test_store();
        let project_dir = tmp.path().join("projects/-home-g-project");
        fs::create_dir_all(&project_dir).unwrap();
        let line = r#"{"type":"user","message":{"role":"user","content":"hi"},"uuid":"x"}"#;
        fs::write(project_dir.join("s1.jsonl"), line).unwrap();

        store.move_to_trash("-home-g-project", "s1").unwrap();

        assert!(!project_dir.join("s1.jsonl").exists());
        assert!(tmp.path().join("trash/-home-g-project/s1.jsonl").exists());
    }
test_load_trash_reads_moved_files function · rust · L493-L504 (12 LOC)
src/store.rs
    fn test_load_trash_reads_moved_files() {
        let (tmp, store) = create_test_store();
        let trash_dir = tmp.path().join("trash/-home-g-project");
        fs::create_dir_all(&trash_dir).unwrap();
        let line = r#"{"type":"user","message":{"role":"user","content":"hi"},"uuid":"x"}"#;
        fs::write(trash_dir.join("s1.jsonl"), line).unwrap();

        let trash = store.load_trash().unwrap();
        assert_eq!(trash.len(), 1);
        assert_eq!(trash[0].id, "s1");
        assert_eq!(trash[0].project_name, "-home-g-project");
    }
test_restore_moves_file_back function · rust · L507-L520 (14 LOC)
src/store.rs
    fn test_restore_moves_file_back() {
        let (tmp, store) = create_test_store();
        let project_dir = tmp.path().join("projects/-home-g-project");
        fs::create_dir_all(&project_dir).unwrap();
        let line = r#"{"type":"user","message":{"role":"user","content":"hi"},"uuid":"x"}"#;
        fs::write(project_dir.join("s1.jsonl"), line).unwrap();

        store.move_to_trash("-home-g-project", "s1").unwrap();
        let trash = store.load_trash().unwrap();
        store.restore_session_file(&trash[0]).unwrap();

        assert!(project_dir.join("s1.jsonl").exists());
        assert!(!tmp.path().join("trash/-home-g-project/s1.jsonl").exists());
    }
test_empty_trash_removes_directory function · rust · L523-L535 (13 LOC)
src/store.rs
    fn test_empty_trash_removes_directory() {
        let (tmp, store) = create_test_store();
        let project_dir = tmp.path().join("projects/-home-g-project");
        fs::create_dir_all(&project_dir).unwrap();
        let line = r#"{"type":"user","message":{"role":"user","content":"hi"},"uuid":"x"}"#;
        fs::write(project_dir.join("s1.jsonl"), line).unwrap();

        store.move_to_trash("-home-g-project", "s1").unwrap();
        assert!(tmp.path().join("trash").exists());

        store.empty_trash().unwrap();
        assert!(!tmp.path().join("trash").exists());
    }
test_load_sessions_ignores_trash_dir function · rust · L538-L553 (16 LOC)
src/store.rs
    fn test_load_sessions_ignores_trash_dir() {
        let (tmp, store) = create_test_store();
        let project_dir = tmp.path().join("projects/-home-g-project");
        fs::create_dir_all(&project_dir).unwrap();
        let line = r#"{"type":"user","message":{"role":"user","content":"hi"},"uuid":"x"}"#;
        fs::write(project_dir.join("s1.jsonl"), line).unwrap();

        // Session in trash — darf NICHT in load_sessions erscheinen
        let trash_dir = tmp.path().join("trash/-home-g-project");
        fs::create_dir_all(&trash_dir).unwrap();
        fs::write(trash_dir.join("s2.jsonl"), line).unwrap();

        let sessions = store.load_sessions().unwrap();
        assert_eq!(sessions.len(), 1);
        assert_eq!(sessions[0].id, "s1");
    }
Repobility analyzer · published findings · https://repobility.com
test_new_uses_env_var_claude_data_dir function · rust · L556-L562 (7 LOC)
src/store.rs
    fn test_new_uses_env_var_claude_data_dir() {
        let tmp = tempfile::TempDir::new().unwrap();
        std::env::set_var("CLAUDE_DATA_DIR", tmp.path());
        let store = SessionStore::new();
        assert_eq!(store.projects_path, tmp.path().join("projects"));
        std::env::remove_var("CLAUDE_DATA_DIR");
    }
test_move_to_trash_removes_from_load_sessions function · rust · L572-L591 (20 LOC)
src/store.rs
    fn test_move_to_trash_removes_from_load_sessions() {
        let (tmp, store) = create_test_store();

        let project_dir = tmp.path().join("projects/-home-g-myproject");
        fs::create_dir_all(&project_dir).unwrap();

        let line = r#"{"type":"user","message":{"role":"user","content":"msg"},"uuid":"x"}"#;
        fs::write(project_dir.join("test-session.jsonl"), line).unwrap();

        let sessions = store.load_sessions().unwrap();
        assert_eq!(sessions.len(), 1);
        assert_eq!(sessions[0].id, "test-session");

        store
            .move_to_trash("-home-g-myproject", "test-session")
            .unwrap();

        let sessions_after_delete = store.load_sessions().unwrap();
        assert_eq!(sessions_after_delete.len(), 0);
    }
draw_loading function · rust · L9-L44 (36 LOC)
src/ui.rs
pub fn draw_loading(f: &mut Frame, loaded: usize, total: usize) {
    let area = f.area();
    let percent = if total > 0 { (loaded * 100) / total } else { 0 };

    let gauge = ratatui::widgets::Gauge::default()
        .block(
            Block::default()
                .title(" Loading Sessions ")
                .borders(Borders::ALL)
                .border_style(Style::default().fg(Color::Green)),
        )
        .gauge_style(Style::default().fg(Color::Green).bg(Color::Black))
        .percent(percent as u16)
        .label(format!("{}/{}", loaded, total));

    let centered = Layout::default()
        .direction(Direction::Vertical)
        .constraints([
            Constraint::Percentage(45),
            Constraint::Length(3),
            Constraint::Percentage(45),
        ])
        .split(area);

    let horizontal = Layout::default()
        .direction(Direction::Horizontal)
        .constraints([
            Constraint::Percentage(20),
            Constraint::Percenta
draw function · rust · L45-L88 (44 LOC)
src/ui.rs
pub fn draw(f: &mut Frame, app: &mut App) {
    let chunks = Layout::default()
        .direction(Direction::Vertical)
        .margin(0)
        .constraints(
            [
                Constraint::Length(3),
                Constraint::Min(10),
                Constraint::Length(3),
            ]
            .as_ref(),
        )
        .split(f.area());

    // Click-Regionen jedes Frame neu aufbauen (Single Source of Truth)
    let area = f.area();
    app.terminal_size = (area.width, area.height);
    app.click_regions.clear();

    draw_tabs(f, chunks[0], app);

    let content_chunks = Layout::default()
        .direction(Direction::Horizontal)
        .constraints([Constraint::Percentage(30), Constraint::Percentage(70)])
        .split(chunks[1]);

    draw_list(f, content_chunks[0], app);
    draw_preview(f, content_chunks[1], app);

    draw_commands(f, chunks[2], app);

    if app.show_search {
        draw_search_modal(f, app);
    }

    if app.show_help {
        draw
draw_tabs function · rust · L89-L142 (54 LOC)
src/ui.rs
fn draw_tabs(f: &mut Frame, area: Rect, app: &mut App) {
    let session_count = app.sessions.len();
    let trash_count = app.trash.len();

    let tab_indicator = |tab: Tab| {
        if app.current_tab == tab {
            ("●", Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD))
        } else {
            ("○", Style::default().fg(Color::DarkGray))
        }
    };
    let (sessions_marker, sessions_style) = tab_indicator(Tab::Sessions);
    let (trash_marker, trash_style) = tab_indicator(Tab::Trash);

    let sessions_text = format!("  {} 1 Sessions ({})  ", sessions_marker, session_count);
    let trash_text = format!("  {} 2 Trash ({})  ", trash_marker, trash_count);
    let help_text = "│  h help  ";

    let tabs = vec![
        Span::styled(&sessions_text, sessions_style),
        Span::styled(&trash_text, trash_style),
        Span::styled(help_text, Style::default().fg(Color::DarkGray)),
    ];

    let tabs_line = Line::from(tabs);
    let tabs_widget = Parag
draw_list function · rust · L143-L254 (112 LOC)
src/ui.rs
fn draw_list(f: &mut Frame, area: Rect, app: &mut App) {
    // Clone to release borrow on app before we need &mut app.list_table_state
    let filtered: Vec<_> = app.filtered_sessions().into_iter().cloned().collect();

    let sort_arrow = match app.sort_direction {
        crate::app::SortDirection::Ascending => "▲",
        crate::app::SortDirection::Descending => "▼",
    };

    let project_header = if app.sort_field == crate::app::SortField::Project {
        format!("Project {}", sort_arrow)
    } else {
        "Project".to_string()
    };

    let date_header = if app.sort_field == crate::app::SortField::Date {
        format!("Date {}", sort_arrow)
    } else {
        "Date".to_string()
    };

    let msgs_header = if app.sort_field == crate::app::SortField::Messages {
        format!("Msgs {}", sort_arrow)
    } else {
        "Msgs".to_string()
    };

    let header = Row::new(vec![
        Cell::from(project_header).style(
            Style::default()
                .
format_datetime function · rust · L255-L264 (10 LOC)
src/ui.rs
fn format_datetime(iso_string: &str) -> String {
    if iso_string.len() >= 16 {
        let date_part = &iso_string[0..10];
        let time_part = &iso_string[11..16];
        format!("{} {}", date_part, time_part)
    } else {
        iso_string.to_string()
    }
}
draw_preview function · rust · L265-L380 (116 LOC)
src/ui.rs
fn draw_preview(f: &mut Frame, area: Rect, app: &App) {
    if let Some(session) = app.get_selected_session() {
        let mut lines = vec![
            Line::from(vec![
                Span::styled("Project: ", Style::default().fg(Color::Yellow)),
                Span::raw(&session.project_name),
            ]),
            Line::from(vec![
                Span::styled("Session: ", Style::default().fg(Color::Yellow)),
                Span::raw(&session.id),
            ]),
            Line::from(vec![
                Span::styled("Updated: ", Style::default().fg(Color::Yellow)),
                Span::raw(&session.updated_at),
            ]),
            Line::from(vec![
                Span::styled("Size: ", Style::default().fg(Color::Yellow)),
                Span::raw(format_size(session.size)),
            ]),
            Line::from(vec![
                Span::styled("Messages: ", Style::default().fg(Color::Yellow)),
                Span::raw(format!("{}", session.messages.len())
Open data scored by Repobility · https://repobility.com
draw_search_modal function · rust · L381-L406 (26 LOC)
src/ui.rs
fn draw_search_modal(f: &mut Frame, app: &mut App) {
    let size = f.area();
    let area = Rect {
        x: size.width / 4,
        y: size.height / 2 - 1,
        width: size.width / 2,
        height: 3,
    };

    f.render_widget(Clear, area);

    let search = Paragraph::new(format!("Search: {}_", app.search_query))
        .block(
            Block::default()
                .title(" Search (Esc to close) ")
                .borders(Borders::ALL)
                .border_style(Style::default().fg(Color::Cyan)),
        )
        .style(Style::default().bg(Color::Black).fg(Color::White));

    f.render_widget(search, area);

    // Search-Modal: Keine Click-Regionen → click-outside in main.rs schließt das Modal
    app.click_regions.clear();
}
draw_commands function · rust · L407-L529 (123 LOC)
src/ui.rs
fn draw_commands(f: &mut Frame, area: Rect, app: &mut App) {
    let sep = Span::styled("  │  ", Style::default().fg(Color::DarkGray));

    // Confirmation mit [y]/[n] Buttons
    if app.is_confirmation_pending() {
        if let Some(ref msg) = app.status_message {
            let question = if let Some(pos) = msg.find(" Press ") {
                &msg[..pos]
            } else {
                msg.as_str()
            };
            let question_with_pad = format!("{}  ", question);
            let yes_text = " [y] yes ";
            let gap = "  ";
            let no_text = " [n] no  ";
            let bar = Paragraph::new(Line::from(vec![
                Span::styled(&question_with_pad, Style::default().fg(Color::Yellow)),
                Span::styled(yes_text, Style::default().fg(Color::Black).bg(Color::Green)),
                Span::raw(gap),
                Span::styled(no_text, Style::default().fg(Color::Black).bg(Color::Red)),
            ]))
            .block(Block::defau
sanitize_for_display function · rust · L534-L544 (11 LOC)
src/ui.rs
fn sanitize_for_display(text: &str) -> String {
    text.chars()
        .map(|c| match c as u32 {
            0x2600..=0x26FF => ' ',   // Miscellaneous Symbols (⛁, ⛀, ⛶, etc.)
            0x2700..=0x27BF => ' ',   // Dingbats
            0x1F300..=0x1F9FF => ' ', // Miscellaneous Symbols and Pictographs, Emoticons, etc.
            0x1FA00..=0x1FAFF => ' ', // Supplemental Symbols
            _ => c,
        })
        .collect()
}
format_size function · rust · L545-L554 (10 LOC)
src/ui.rs
fn format_size(bytes: u64) -> String {
    if bytes < 1024 {
        format!("{} B", bytes)
    } else if bytes < 1024 * 1024 {
        format!("{:.1} KB", bytes as f64 / 1024.0)
    } else {
        format!("{:.1} MB", bytes as f64 / (1024.0 * 1024.0))
    }
}
draw_help_modal function · rust · L555-L595 (41 LOC)
src/ui.rs
fn draw_help_modal(f: &mut Frame, app: &mut App) {
    let area = f.area();
    let width = (area.width as f32 * 0.8).min(100.0) as u16;
    let height = (area.height as f32 * 0.8).min(40.0) as u16;

    let popup_area = Rect {
        x: (area.width - width) / 2,
        y: (area.height - height) / 2,
        width,
        height,
    };

    f.render_widget(Clear, popup_area);

    let help_text = std::fs::read_to_string("help.md")
        .or_else(|_| std::fs::read_to_string("/home/g/workspace/agent-session-manager/help.md"))
        .unwrap_or_else(|_| "README.md not found".to_string());
    let lines: Vec<String> = help_text.lines().map(|s| s.to_string()).collect();

    let visible_lines: Vec<Line> = lines
        .iter()
        .skip(app.help_scroll as usize)
        .take(height as usize - 2)
        .map(|line| parse_markdown_line(line))
        .collect();

    let help_widget = Paragraph::new(visible_lines)
        .block(
            Block::default()
                .tit
parse_markdown_line function · rust · L596-L655 (60 LOC)
src/ui.rs
fn parse_markdown_line(line: &str) -> Line<'_> {
    let line = sanitize_for_display(line);

    if line.starts_with("# ") {
        Line::from(vec![Span::styled(
            line[2..].to_string(),
            Style::default()
                .fg(Color::Cyan)
                .add_modifier(Modifier::BOLD),
        )])
    } else if line.starts_with("## ") {
        Line::from(vec![Span::styled(
            line[3..].to_string(),
            Style::default()
                .fg(Color::Yellow)
                .add_modifier(Modifier::BOLD),
        )])
    } else if line.starts_with("### ") {
        Line::from(vec![Span::styled(
            line[4..].to_string(),
            Style::default()
                .fg(Color::Green)
                .add_modifier(Modifier::BOLD),
        )])
    } else if line.starts_with("```") {
        Line::from(vec![Span::styled(
            line.to_string(),
            Style::default().fg(Color::DarkGray),
        )])
    } else if line.starts_with("| ") |
parse_inline_formatting function · rust · L656-L750 (95 LOC)
src/ui.rs
fn parse_inline_formatting(text: String, base_style: Style) -> Vec<Span<'static>> {
    let mut spans = Vec::new();
    let mut chars = text.chars().peekable();
    let mut current_text = String::new();

    while let Some(ch) = chars.next() {
        if ch == '`' {
            if !current_text.is_empty() {
                spans.push(Span::styled(current_text.clone(), base_style));
                current_text.clear();
            }
            let mut code_content = String::new();
            while let Some(next_ch) = chars.next() {
                if next_ch == '`' {
                    break;
                }
                code_content.push(next_ch);
            }
            spans.push(Span::styled(
                code_content,
                Style::default().fg(Color::Yellow).bg(Color::DarkGray),
            ));
        } else if ch == '*' || ch == '_' {
            if chars.peek() == Some(&ch) {
                chars.next();
                if !current_text.is_empty() {
   
draw_settings_modal function · rust · L751-L815 (65 LOC)
src/ui.rs
fn draw_settings_modal(f: &mut Frame, app: &mut App) {
    let area = f.area();
    let width = (area.width as f32 * 0.6) as u16;
    let height = 7u16;

    let popup_area = Rect {
        x: (area.width.saturating_sub(width)) / 2,
        y: (area.height.saturating_sub(height)) / 2,
        width: width.min(area.width),
        height: height.min(area.height),
    };

    let block = Block::default()
        .title(" Settings ")
        .borders(Borders::ALL)
        .border_style(Style::default().fg(Color::Magenta));

    let inner = block.inner(popup_area);

    let save_text = "  [Enter]";
    let save_desc = " save  ";
    let cancel_text = "[Esc]";
    let cancel_desc = " cancel";

    let text = vec![
        Line::from(""),
        Line::from(vec![
            Span::styled("  Export Path: ", Style::default().fg(Color::Gray)),
        ]),
        Line::from(vec![
            Span::styled(
                format!("  {}_", app.settings_input),
                Style::default().fg
Same scanner, your repo: https://repobility.com — Repobility
make_session function · rust · L824-L836 (13 LOC)
src/ui.rs
    fn make_session(id: &str, project: &str, messages: Vec<Message>) -> Session {
        Session {
            id: id.to_string(),
            project_path: format!("/home/g/{}", project),
            project_name: project.to_string(),
            created_at: "2026-01-15T10:00:00+01:00".to_string(),
            updated_at: "2026-01-15T12:00:00+01:00".to_string(),
            size: 1024,
            total_entries: messages.len() + 3,
            messages,
        }
    }
make_msg function · rust · L837-L843 (7 LOC)
src/ui.rs
    fn make_msg(role: &str, content: &str) -> Message {
        Message {
            role: role.to_string(),
            content: content.to_string(),
        }
    }
render_to_string function · rust · L844-L850 (7 LOC)
src/ui.rs
    fn render_to_string(app: &mut App, width: u16, height: u16) -> String {
        let backend = TestBackend::new(width, height);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw(f, app)).unwrap();
        terminal.backend().to_string()
    }
test_renders_session_list_header function · rust · L853-L858 (6 LOC)
src/ui.rs
    fn test_renders_session_list_header() {
        let mut app = App::with_sessions(vec![make_session("abc12345-6789", "my-project", vec![])]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(output.contains("Sessions"), "Should show Sessions tab");
        assert!(output.contains("my-project"), "Should show project name");
    }
test_renders_message_count function · rust · L861-L869 (9 LOC)
src/ui.rs
    fn test_renders_message_count() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "test-proj",
            vec![make_msg("user", "Hello"), make_msg("assistant", "Hi there")],
        )]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(output.contains("2"), "Should show message count of 2");
    }
test_renders_preview_for_selected_session function · rust · L872-L887 (16 LOC)
src/ui.rs
    fn test_renders_preview_for_selected_session() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "my-project",
            vec![
                make_msg("user", "How do I test TUIs?"),
                make_msg("assistant", "Use TestBackend from ratatui"),
            ],
        )]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(output.contains("Preview"), "Should show Preview panel");
        assert!(
            output.contains("How do I test TUIs"),
            "Should show user message in preview"
        );
    }
test_renders_empty_state function · rust · L890-L898 (9 LOC)
src/ui.rs
    fn test_renders_empty_state() {
        let mut app = App::with_sessions(vec![]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(output.contains("Sessions (0)"), "Should show 0 sessions");
        assert!(
            output.contains("No session selected"),
            "Should show empty state message"
        );
    }
test_selection_moves_preview function · rust · L901-L929 (29 LOC)
src/ui.rs
    fn test_selection_moves_preview() {
        let mut app = App::with_sessions(vec![
            make_session(
                "aaa11111-0000",
                "first-project",
                vec![make_msg("user", "First message")],
            ),
            make_session(
                "bbb22222-0000",
                "second-project",
                vec![make_msg("user", "Second message")],
            ),
        ]);

        // Initially first session selected
        let output = render_to_string(&mut app, 100, 20);
        assert!(
            output.contains("First message"),
            "Should show first session preview"
        );

        // Move selection down
        app.select_next();
        let output = render_to_string(&mut app, 100, 20);
        assert!(
            output.contains("Second message"),
            "Should show second session preview"
        );
    }
Repobility · code-quality intelligence · https://repobility.com
test_search_modal_renders function · rust · L932-L940 (9 LOC)
src/ui.rs
    fn test_search_modal_renders() {
        let mut app = App::with_sessions(vec![make_session("abc12345-6789", "my-project", vec![])]);
        app.show_search = true;
        app.search_query = "test".to_string();

        let output = render_to_string(&mut app, 100, 20);
        assert!(output.contains("Search"), "Should show search modal");
        assert!(output.contains("test"), "Should show search query");
    }
test_truncated_session_id_in_list function · rust · L943-L959 (17 LOC)
src/ui.rs
    fn test_truncated_session_id_in_list() {
        let mut app = App::with_sessions(vec![make_session(
            "abcdef12-3456-7890-abcd-ef1234567890",
            "proj",
            vec![],
        )]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(
            output.contains("abcdef12"),
            "List should show truncated ID (first 8 chars)"
        );
        // Full ID is shown in Preview panel - that's correct
        assert!(
            output.contains("abcdef12-3456-7890"),
            "Preview should show full ID"
        );
    }
test_commands_bar_shows_keybindings function · rust · L962-L968 (7 LOC)
src/ui.rs
    fn test_commands_bar_shows_keybindings() {
        let mut app = App::with_sessions(vec![make_session("abc12345-6789", "my-project", vec![])]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(output.contains("resume"), "Should show resume command");
        assert!(output.contains("elete"), "Should show delete command");
        assert!(output.contains("search"), "Should show search command");
    }
test_sanitize_replaces_problematic_unicode function · rust · L971-L979 (9 LOC)
src/ui.rs
    fn test_sanitize_replaces_problematic_unicode() {
        // These chars (Miscellaneous Symbols) cause width mismatches
        let input = "⛁ Active files ⛀ board ⛶ custom";
        let result = sanitize_for_display(input);
        assert!(!result.contains('⛁'), "Should replace ⛁");
        assert!(!result.contains('⛀'), "Should replace ⛀");
        assert!(!result.contains('⛶'), "Should replace ⛶");
        assert!(result.contains("Active files"), "Should keep regular text");
    }
test_sanitize_keeps_normal_text function · rust · L982-L989 (8 LOC)
src/ui.rs
    fn test_sanitize_keeps_normal_text() {
        let input = "Hello, Welt! Ärger mit Ümlauten.";
        let result = sanitize_for_display(input);
        assert_eq!(
            result, input,
            "Normal text including umlauts should be unchanged"
        );
    }
test_preview_with_problematic_unicode_renders_clean function · rust · L999-L1008 (10 LOC)
src/ui.rs
    fn test_preview_with_problematic_unicode_renders_clean() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "project",
            vec![make_msg("user", "⛁ Active 30+ ⛁ files ⛶ custom stack")],
        )]);
        let output = render_to_string(&mut app, 100, 20);
        assert!(!output.contains('⛁'), "Preview should not contain ⛁");
        assert!(output.contains("Active 30+"), "Should keep normal text");
    }
test_preview_shows_entries_and_messages function · rust · L1011-L1021 (11 LOC)
src/ui.rs
    fn test_preview_shows_entries_and_messages() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "my-project",
            vec![make_msg("user", "Hello")],
        )]);
        let output = render_to_string(&mut app, 100, 20);
        // Preview should show both messages count and total entries
        assert!(output.contains("Messages:"), "Should show Messages label");
        assert!(output.contains("Entries:"), "Should show Entries label");
    }
test_snapshot_initial_render function · rust · L1024-L1044 (21 LOC)
src/ui.rs
    fn test_snapshot_initial_render() {
        let mut app = App::with_sessions(vec![
            make_session(
                "abc12345-6789",
                "my-project",
                vec![
                    make_msg("user", "Hello, how are you?"),
                    make_msg("assistant", "I am doing well, thank you!"),
                ],
            ),
            make_session(
                "def98765-4321",
                "other-project",
                vec![make_msg("user", "What is Rust?")],
            ),
        ]);
        let backend = TestBackend::new(100, 20);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw(f, &mut app)).unwrap();
        insta::assert_snapshot!(terminal.backend());
    }
Repobility analyzer · published findings · https://repobility.com
test_snapshot_settings_modal function · rust · L1047-L1058 (12 LOC)
src/ui.rs
    fn test_snapshot_settings_modal() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "my-project",
            vec![make_msg("user", "Hello")],
        )]);
        app.open_settings();
        let backend = TestBackend::new(100, 20);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw(f, &mut app)).unwrap();
        insta::assert_snapshot!(terminal.backend());
    }
test_snapshot_help_modal function · rust · L1061-L1072 (12 LOC)
src/ui.rs
    fn test_snapshot_help_modal() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "my-project",
            vec![make_msg("user", "Hello")],
        )]);
        app.toggle_help();
        let backend = TestBackend::new(100, 20);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw(f, &mut app)).unwrap();
        insta::assert_snapshot!(terminal.backend());
    }
test_snapshot_delete_confirm function · rust · L1075-L1086 (12 LOC)
src/ui.rs
    fn test_snapshot_delete_confirm() {
        let mut app = App::with_sessions(vec![make_session(
            "abc12345-6789",
            "my-project",
            vec![make_msg("user", "Hello")],
        )]);
        app.request_delete_confirmation();
        let backend = TestBackend::new(100, 20);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw(f, &mut app)).unwrap();
        insta::assert_snapshot!(terminal.backend());
    }
test_snapshot_loading_progress function · rust · L1163-L1168 (6 LOC)
src/ui.rs
    fn test_snapshot_loading_progress() {
        let backend = TestBackend::new(80, 24);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw_loading(f, 42, 100)).unwrap();
        insta::assert_snapshot!(terminal.backend());
    }
test_parse_inline_unclosed_backtick function · rust · L1234-L1239 (6 LOC)
src/ui.rs
    fn test_parse_inline_unclosed_backtick() {
        let spans = parse_inline_formatting("use `unclosed code".to_string(), Style::default());
        // Should not panic; unclosed backtick produces a span with content up to end
        assert!(!spans.is_empty());
        assert!(spans.iter().any(|s| s.content.as_ref() == "unclosed code"));
    }
test_parse_inline_unclosed_link function · rust · L1249-L1257 (9 LOC)
src/ui.rs
    fn test_parse_inline_unclosed_link() {
        let spans =
            parse_inline_formatting("see [broken link".to_string(), Style::default());
        assert!(!spans.is_empty());
        // Should include the bracket as plain text
        assert!(spans
            .iter()
            .any(|s| s.content.as_ref().contains("[") || s.content.as_ref().contains("broken")));
    }
test_parse_inline_link_without_url function · rust · L1260-L1266 (7 LOC)
src/ui.rs
    fn test_parse_inline_link_without_url() {
        let spans =
            parse_inline_formatting("see [text] no url".to_string(), Style::default());
        assert!(!spans.is_empty());
        // [text] without (url) should be treated as plain text
        assert!(spans.iter().any(|s| s.content.as_ref().contains("text")));
    }
test_parse_inline_single_asterisk_not_bold function · rust · L1276-L1281 (6 LOC)
src/ui.rs
    fn test_parse_inline_single_asterisk_not_bold() {
        let spans =
            parse_inline_formatting("a * b * c".to_string(), Style::default());
        // Single asterisks should be kept as plain text
        assert!(spans.iter().any(|s| s.content.as_ref().contains("*")));
    }
Open data scored by Repobility · https://repobility.com
test_draw_loading_zero_total function · rust · L1292-L1299 (8 LOC)
src/ui.rs
    fn test_draw_loading_zero_total() {
        let backend = TestBackend::new(80, 24);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw_loading(f, 0, 0)).unwrap();
        // Should not panic with total=0
        let output = terminal.backend().to_string();
        assert!(output.contains("0/0"));
    }
test_sanitize_replaces_emoji function · rust · L1304-L1310 (7 LOC)
src/ui.rs
    fn test_sanitize_replaces_emoji() {
        let input = "Hello \u{1F600} World"; // 😀
        let result = sanitize_for_display(input);
        assert!(!result.contains('\u{1F600}'));
        assert!(result.contains("Hello"));
        assert!(result.contains("World"));
    }
test_snapshot_trash_tab function · rust · L1334-L1346 (13 LOC)
src/ui.rs
    fn test_snapshot_trash_tab() {
        let mut app = App::with_sessions(vec![]);
        app.trash = vec![make_session(
            "trash-session",
            "deleted-project",
            vec![make_msg("user", "old message")],
        )];
        app.current_tab = crate::app::Tab::Trash;
        let backend = TestBackend::new(100, 20);
        let mut terminal = Terminal::new(backend).unwrap();
        terminal.draw(|f| draw(f, &mut app)).unwrap();
        insta::assert_snapshot!(terminal.backend());
    }
‹ prevpage 5 / 6next ›