Function bodies 251 total
test_handle_n_cancels_confirmation function · rust · L940-L945 (6 LOC)src/main.rs
fn test_handle_n_cancels_confirmation() {
let mut app = App::with_sessions(vec![make_session("s1", "p1")]);
app.request_delete_confirmation();
handle_key_event(&mut app, press(KeyCode::Char('n')));
assert!(!app.is_confirmation_pending());
}test_handle_settings_enter_saves function · rust · L950-L957 (8 LOC)src/main.rs
fn test_handle_settings_enter_saves() {
let mut app = App::with_sessions(vec![]);
app.open_settings();
app.settings_input = "/new/path".to_string();
handle_key_event(&mut app, press(KeyCode::Enter));
assert!(!app.show_settings);
assert_eq!(app.config.export_path, "/new/path");
}test_handle_settings_backspace function · rust · L960-L966 (7 LOC)src/main.rs
fn test_handle_settings_backspace() {
let mut app = App::with_sessions(vec![]);
app.open_settings();
let initial_len = app.settings_input.len();
handle_key_event(&mut app, press(KeyCode::Backspace));
assert_eq!(app.settings_input.len(), initial_len - 1);
}test_handle_help_page_up function · rust · L971-L977 (7 LOC)src/main.rs
fn test_handle_help_page_up() {
let mut app = App::with_sessions(vec![]);
app.toggle_help();
app.help_scroll = 15;
handle_key_event(&mut app, press(KeyCode::PageUp));
assert_eq!(app.help_scroll, 5);
}test_handle_help_up_scrolls function · rust · L980-L986 (7 LOC)src/main.rs
fn test_handle_help_up_scrolls() {
let mut app = App::with_sessions(vec![]);
app.toggle_help();
app.help_scroll = 5;
handle_key_event(&mut app, press(KeyCode::Up));
assert_eq!(app.help_scroll, 4);
}test_handle_help_esc_closes function · rust · L989-L994 (6 LOC)src/main.rs
fn test_handle_help_esc_closes() {
let mut app = App::with_sessions(vec![]);
app.toggle_help();
handle_key_event(&mut app, press(KeyCode::Esc));
assert!(!app.show_help);
}test_handle_shift_s_toggles_sort_direction function · rust · L999-L1004 (6 LOC)src/main.rs
fn test_handle_shift_s_toggles_sort_direction() {
let mut app = App::with_sessions(vec![]);
assert_eq!(app.sort_direction, crate::app::SortDirection::Descending);
handle_key_event(&mut app, press(KeyCode::Char('S')));
assert_eq!(app.sort_direction, crate::app::SortDirection::Ascending);
}All rows scored by the Repobility analyzer (https://repobility.com)
test_handle_left_switches_to_list function · rust · L1016-L1021 (6 LOC)src/main.rs
fn test_handle_left_switches_to_list() {
let mut app = App::with_sessions(vec![make_session("s1", "p1")]);
app.focus = FocusPanel::Preview;
handle_key_event(&mut app, press(KeyCode::Left));
assert_eq!(app.focus, FocusPanel::List);
}test_handle_pagedown_in_list function · rust · L1026-L1034 (9 LOC)src/main.rs
fn test_handle_pagedown_in_list() {
let mut app = App::with_sessions(vec![
make_session("s1", "p1"),
make_session("s2", "p2"),
make_session("s3", "p3"),
]);
handle_key_event(&mut app, press(KeyCode::PageDown));
assert_eq!(app.selected_session_idx, 2);
}test_handle_pageup_in_list function · rust · L1037-L1046 (10 LOC)src/main.rs
fn test_handle_pageup_in_list() {
let mut app = App::with_sessions(vec![
make_session("s1", "p1"),
make_session("s2", "p2"),
make_session("s3", "p3"),
]);
app.selected_session_idx = 2;
handle_key_event(&mut app, press(KeyCode::PageUp));
assert_eq!(app.selected_session_idx, 0);
}test_handle_r_restore_in_sessions_tab function · rust · L1051-L1056 (6 LOC)src/main.rs
fn test_handle_r_restore_in_sessions_tab() {
let mut app = App::with_sessions(vec![make_session("s1", "p1")]);
handle_key_event(&mut app, press(KeyCode::Char('r')));
// restore in sessions tab shows error status
assert!(app.status_message.unwrap().contains("Trash tab"));
}test_handle_t_requests_empty_trash function · rust · L1061-L1070 (10 LOC)src/main.rs
fn test_handle_t_requests_empty_trash() {
let mut app = App::with_sessions(vec![]);
app.trash = vec![make_session("t1", "p1")];
app.current_tab = Tab::Trash;
handle_key_event(&mut app, press(KeyCode::Char('t')));
assert_eq!(
app.confirm_action,
Some(crate::app::ConfirmAction::EmptyTrash)
);
}test_handle_t_confirms_when_pending function · rust · L1073-L1080 (8 LOC)src/main.rs
fn test_handle_t_confirms_when_pending() {
let mut app = App::with_sessions(vec![]);
app.trash = vec![make_session("t1", "p1")];
app.current_tab = Tab::Trash;
app.confirm_action = Some(crate::app::ConfirmAction::EmptyTrash);
handle_key_event(&mut app, press(KeyCode::Char('t')));
assert!(app.trash.is_empty());
}test_handle_0_requests_trash_zero function · rust · L1085-L1093 (9 LOC)src/main.rs
fn test_handle_0_requests_trash_zero() {
let mut app = App::with_sessions(vec![make_session("s1", "p1")]);
app.sessions[0].messages.clear();
handle_key_event(&mut app, press(KeyCode::Char('0')));
assert_eq!(
app.confirm_action,
Some(crate::app::ConfirmAction::TrashZeroMessages)
);
}test_handle_y_confirms_delete_permanently function · rust · L1107-L1115 (9 LOC)src/main.rs
fn test_handle_y_confirms_delete_permanently() {
let mut app = App::with_sessions(vec![]);
app.trash = vec![make_session("t1", "p1")];
app.current_tab = Tab::Trash;
app.confirm_action = Some(crate::app::ConfirmAction::DeletePermanently("t1".to_string()));
handle_key_event(&mut app, press(KeyCode::Char('y')));
assert!(app.trash.is_empty());
assert!(!app.is_confirmation_pending());
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
test_handle_esc_closes_search function · rust · L1120-L1126 (7 LOC)src/main.rs
fn test_handle_esc_closes_search() {
let mut app = App::with_sessions(vec![]);
app.show_search = true;
app.search_query = "test".to_string();
handle_key_event(&mut app, press(KeyCode::Esc));
assert!(!app.show_search);
}test_handle_enter_closes_search function · rust · L1129-L1135 (7 LOC)src/main.rs
fn test_handle_enter_closes_search() {
let mut app = App::with_sessions(vec![]);
app.show_search = true;
app.search_query = "test".to_string();
handle_key_event(&mut app, press(KeyCode::Enter));
assert!(!app.show_search);
}test_handle_q_in_search_closes_search function · rust · L1140-L1146 (7 LOC)src/main.rs
fn test_handle_q_in_search_closes_search() {
let mut app = App::with_sessions(vec![]);
app.show_search = true;
let result = handle_key_event(&mut app, press(KeyCode::Char('q')));
assert!(result.is_none()); // should NOT quit
assert!(!app.show_search);
}test_handle_e_export function · rust · L1160-L1166 (7 LOC)src/main.rs
fn test_handle_e_export() {
let tmp = tempfile::TempDir::new().unwrap();
let mut app = App::with_sessions(vec![make_session("s1", "p1")]);
app.config.export_path = tmp.path().to_string_lossy().to_string();
handle_key_event(&mut app, press(KeyCode::Char('e')));
assert!(app.status_message.unwrap().contains("Exported"));
}new function · rust · L23-L39 (17 LOC)src/models.rs
pub fn new(id: String, project_path: String) -> Self {
let project_name = project_path
.rsplit('/')
.next()
.unwrap_or(&project_path)
.to_string();
Self {
id,
project_name,
project_path,
created_at: chrono::Local::now().to_rfc3339(),
updated_at: chrono::Local::now().to_rfc3339(),
size: 0,
total_entries: 0,
messages: Vec::new(),
}
}display_name function · rust · L40-L48 (9 LOC)src/models.rs
pub fn display_name(&self) -> String {
let short_id = if self.id.len() > 8 {
&self.id[..8]
} else {
&self.id
};
format!("{} ({})", self.project_name, short_id)
}count_jsonl_entries function · rust · L50-L56 (7 LOC)src/models.rs
pub fn count_jsonl_entries(content: &str) -> usize {
content
.lines()
.filter(|line| serde_json::from_str::<serde_json::Value>(line).is_ok())
.count()
}parse_jsonl_messages function · rust · L57-L116 (60 LOC)src/models.rs
pub fn parse_jsonl_messages(content: &str) -> Vec<Message> {
let mut messages = Vec::new();
for line in content.lines() {
let json: serde_json::Value = match serde_json::from_str(line) {
Ok(v) => v,
Err(_) => continue,
};
let entry_type = json.get("type").and_then(|t| t.as_str()).unwrap_or("");
if entry_type != "user" && entry_type != "assistant" {
continue;
}
let msg = match json.get("message") {
Some(m) => m,
None => continue,
};
let role = msg
.get("role")
.and_then(|r| r.as_str())
.unwrap_or("unknown");
let content_val = match msg.get("content") {
Some(c) => c,
None => continue,
};
let text = if let Some(s) = content_val.as_str() {
s.to_string()
} else if let Some(arr) = content_val.as_array() {
arr.iter()
.filter_About: code-quality intelligence by Repobility · https://repobility.com
test_session_creation function · rust · L123-L129 (7 LOC)src/models.rs
fn test_session_creation() {
let session = Session::new("test-id".to_string(), "/home/g/my-project".to_string());
assert_eq!(session.id, "test-id");
assert_eq!(session.project_name, "my-project");
assert_eq!(session.messages.len(), 0);
assert_eq!(session.total_entries, 0);
}test_display_name function · rust · L132-L138 (7 LOC)src/models.rs
fn test_display_name() {
let session = Session::new(
"abcdef12-3456-7890-abcd-ef1234567890".to_string(),
"/home/g/auto-service".to_string(),
);
assert_eq!(session.display_name(), "auto-service (abcdef12)");
}test_parse_jsonl_user_message_string_content function · rust · L141-L148 (8 LOC)src/models.rs
fn test_parse_jsonl_user_message_string_content() {
let line =
r#"{"type":"user","message":{"role":"user","content":"hello world"},"uuid":"abc"}"#;
let messages = parse_jsonl_messages(line);
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].role, "user");
assert_eq!(messages[0].content, "hello world");
}test_parse_jsonl_assistant_message_array_content function · rust · L151-L157 (7 LOC)src/models.rs
fn test_parse_jsonl_assistant_message_array_content() {
let line = r#"{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"I will help"},{"type":"thinking","thinking":"hmm"}]},"uuid":"def"}"#;
let messages = parse_jsonl_messages(line);
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].role, "assistant");
assert_eq!(messages[0].content, "I will help");
}test_parse_jsonl_skips_non_message_types function · rust · L160-L167 (8 LOC)src/models.rs
fn test_parse_jsonl_skips_non_message_types() {
let lines = r#"{"type":"file-history-snapshot","messageId":"abc","snapshot":{}}
{"type":"progress","data":{"type":"hook_progress"}}
{"type":"user","message":{"role":"user","content":"actual message"},"uuid":"xyz"}"#;
let messages = parse_jsonl_messages(lines);
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].content, "actual message");
}test_parse_jsonl_multiple_text_blocks function · rust · L177-L182 (6 LOC)src/models.rs
fn test_parse_jsonl_multiple_text_blocks() {
let line = r#"{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"part one"},{"type":"text","text":"part two"}]},"uuid":"abc"}"#;
let messages = parse_jsonl_messages(line);
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].content, "part one\npart two");
}test_count_jsonl_entries function · rust · L192-L203 (12 LOC)src/models.rs
fn test_count_jsonl_entries() {
let content = r#"{"type":"file-history-snapshot","messageId":"abc","snapshot":{}}
{"type":"progress","data":{"type":"hook_progress"}}
{"type":"user","message":{"role":"user","content":"hello"},"uuid":"x"}
{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"hi"}]},"uuid":"y"}
{"type":"queue-operation","operation":"dequeue","timestamp":"2026-01-01T00:00:00Z"}"#;
let total = count_jsonl_entries(content);
assert_eq!(
total, 5,
"Should count all valid JSONL entries, not just user/assistant"
);
}test_parse_jsonl_content_neither_string_nor_array function · rust · L227-L235 (9 LOC)src/models.rs
fn test_parse_jsonl_content_neither_string_nor_array() {
let line = r#"{"type":"user","message":{"role":"user","content":42},"uuid":"abc"}"#;
let messages = parse_jsonl_messages(line);
assert_eq!(
messages.len(),
0,
"Should skip entry where content is a number"
);
}Repobility · severity-and-effort ranking · https://repobility.com
test_parse_jsonl_missing_role_uses_unknown function · rust · L238-L244 (7 LOC)src/models.rs
fn test_parse_jsonl_missing_role_uses_unknown() {
let line = r#"{"type":"user","message":{"content":"hello"},"uuid":"abc"}"#;
let messages = parse_jsonl_messages(line);
assert_eq!(messages.len(), 1);
assert_eq!(messages[0].role, "unknown");
assert_eq!(messages[0].content, "hello");
}slug_to_path function · rust · L10-L36 (27 LOC)src/store.rs
fn slug_to_path(slug: &str) -> Option<PathBuf> {
let slug = slug.strip_prefix('-').unwrap_or(slug);
let parts: Vec<&str> = slug.split('-').collect();
let mut path = PathBuf::from("/");
let mut i = 0;
while i < parts.len() {
let mut found = false;
// Try longest segment combination first (greedy)
for j in (i + 1..=parts.len()).rev() {
let candidate = parts[i..j].join("-");
let test_path = path.join(&candidate);
if test_path.is_dir() {
path = test_path;
i = j;
found = true;
break;
}
}
if !found {
return None;
}
}
Some(path)
}new function · rust · L44-L54 (11 LOC)src/store.rs
pub fn new() -> Self {
let base = if let Ok(dir) = std::env::var("CLAUDE_DATA_DIR") {
PathBuf::from(dir)
} else {
dirs::home_dir().expect("home dir").join(".claude")
};
Self {
projects_path: base.join("projects"),
trash_path: base.join("trash"),
}
}with_base function · rust · L57-L62 (6 LOC)src/store.rs
pub fn with_base(base: PathBuf) -> Self {
Self {
projects_path: base.join("projects"),
trash_path: base.join("trash"),
}
}load_sessions function · rust · L65-L109 (45 LOC)src/store.rs
pub fn load_sessions(&self) -> Result<Vec<Session>> {
let mut sessions = Vec::new();
if !self.projects_path.exists() {
return Ok(sessions);
}
for project_entry in fs::read_dir(&self.projects_path)? {
let project_entry = project_entry?;
let project_path = project_entry.path();
if !project_path.is_dir() {
continue;
}
let project_slug = project_path
.file_name()
.and_then(|n| n.to_str())
.unwrap_or("unknown")
.to_string();
let resolved_path = slug_to_path(&project_slug)
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|| project_slug.clone());
for file_entry in fs::read_dir(&project_path)? {
let file_entry = file_entry?;
let file_path = file_entry.path();
if file_path.extension().and_thcount_session_files function · rust · L110-L132 (23 LOC)src/store.rs
pub fn count_session_files(&self) -> usize {
if !self.projects_path.exists() {
return 0;
}
let mut count = 0;
if let Ok(entries) = fs::read_dir(&self.projects_path) {
for entry in entries.flatten() {
let path = entry.path();
if path.is_dir() {
if let Ok(files) = fs::read_dir(&path) {
for file in files.flatten() {
if file.path().extension().and_then(|e| e.to_str()) == Some("jsonl") {
count += 1;
}
}
}
}
}
}
count
}load_sessions_with_progress function · rust · L133-L187 (55 LOC)src/store.rs
pub fn load_sessions_with_progress<F>(&self, mut on_progress: F) -> Result<Vec<Session>>
where
F: FnMut(usize, usize),
{
if !self.projects_path.exists() {
return Ok(Vec::new());
}
let total = self.count_session_files();
let file_paths: Vec<(PathBuf, String, String)> = {
let mut paths = Vec::new();
for project_entry in fs::read_dir(&self.projects_path)? {
let project_entry = project_entry?;
let project_path = project_entry.path();
if !project_path.is_dir() {
continue;
}
let project_slug = project_path
.file_name()
.and_then(|n| n.to_str())
.unwrap_or("unknown")
.to_string();
let resolved_path = slug_to_path(&project_slug)
.map(|p| p.to_string_lossy().to_string())
load_session_from_jsonl function · rust · L188-L236 (49 LOC)src/store.rs
fn load_session_from_jsonl(
&self,
path: &Path,
project_name: &str,
project_path: &str,
) -> Result<Session> {
let session_id = path
.file_stem()
.and_then(|n| n.to_str())
.map(|s| s.to_string())
.context("invalid jsonl filename")?;
let metadata = fs::metadata(path)?;
let file_size = metadata.len();
let modified = metadata
.modified()
.ok()
.and_then(|t| {
let datetime: chrono::DateTime<chrono::Local> = t.into();
Some(datetime.to_rfc3339())
})
.unwrap_or_default();
let created = metadata
.created()
.ok()
.and_then(|t| {
let datetime: chrono::DateTime<chrono::Local> = t.into();
Some(datetime.to_rfc3339())
})
.unwrap_or_default();
let content = fs::read_to_string(path)All rows scored by the Repobility analyzer (https://repobility.com)
load_trash function · rust · L237-L272 (36 LOC)src/store.rs
pub fn load_trash(&self) -> Result<Vec<Session>> {
if !self.trash_path.exists() {
return Ok(Vec::new());
}
let mut sessions = Vec::new();
for project_entry in fs::read_dir(&self.trash_path)? {
let project_entry = project_entry?;
let project_path = project_entry.path();
if !project_path.is_dir() {
continue;
}
let project_slug = project_path
.file_name()
.and_then(|n| n.to_str())
.unwrap_or("unknown")
.to_string();
let resolved_path = slug_to_path(&project_slug)
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|| project_slug.clone());
for file_entry in fs::read_dir(&project_path)? {
let file_entry = file_entry?;
let file_path = file_entry.path();
if file_path.extension().and_then(|e| e.to_smove_to_trash function · rust · L282-L289 (8 LOC)src/store.rs
pub fn move_to_trash(&self, project_name: &str, session_id: &str) -> Result<()> {
let src = self.get_session_file_path(project_name, session_id);
let dst_dir = self.trash_path.join(project_name);
fs::create_dir_all(&dst_dir)?;
let dst = dst_dir.join(format!("{}.jsonl", session_id));
fs::rename(&src, &dst)?;
Ok(())
}restore_session_file function · rust · L292-L301 (10 LOC)src/store.rs
pub fn restore_session_file(&self, session: &Session) -> Result<()> {
let src = self.trash_path
.join(&session.project_name)
.join(format!("{}.jsonl", session.id));
let dst_dir = self.projects_path.join(&session.project_name);
fs::create_dir_all(&dst_dir)?;
let dst = dst_dir.join(format!("{}.jsonl", session.id));
fs::rename(&src, &dst)?;
Ok(())
}empty_trash function · rust · L304-L309 (6 LOC)src/store.rs
pub fn empty_trash(&self) -> Result<()> {
if self.trash_path.exists() {
fs::remove_dir_all(&self.trash_path)?;
}
Ok(())
}create_test_store function · rust · L317-L322 (6 LOC)src/store.rs
fn create_test_store() -> (TempDir, SessionStore) {
let tmp = TempDir::new().unwrap();
let store = SessionStore::with_base(tmp.path().to_path_buf());
(tmp, store)
}test_empty_dir_returns_empty function · rust · L325-L330 (6 LOC)src/store.rs
fn test_empty_dir_returns_empty() {
let (tmp, store) = create_test_store();
fs::create_dir_all(tmp.path().join("projects")).unwrap();
let sessions = store.load_sessions().unwrap();
assert!(sessions.is_empty());
}test_loads_sessions_from_project_subdirs function · rust · L340-L363 (24 LOC)src/store.rs
fn test_loads_sessions_from_project_subdirs() {
let (tmp, store) = create_test_store();
let project_dir = tmp.path().join("projects/-home-g-myproject");
fs::create_dir_all(&project_dir).unwrap();
let jsonl_content = r#"{"type":"user","message":{"role":"user","content":"hello"},"uuid":"a1"}
{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"hi there"}]},"uuid":"a2"}
{"type":"progress","data":{}}
"#;
let mut f = fs::File::create(project_dir.join("abc-123.jsonl")).unwrap();
f.write_all(jsonl_content.as_bytes()).unwrap();
let sessions = store.load_sessions().unwrap();
assert_eq!(sessions.len(), 1);
assert_eq!(sessions[0].id, "abc-123");
assert_eq!(sessions[0].project_name, "-home-g-myproject");
assert_eq!(sessions[0].messages.len(), 2);
assert_eq!(sessions[0].messages[0].role, "user");
assert_eq!(sessions[0].messages[0].content, "hello");
test_multiple_sessions_in_one_project function · rust · L366-L379 (14 LOC)src/store.rs
fn test_multiple_sessions_in_one_project() {
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":"msg"},"uuid":"x"}"#;
fs::write(project_dir.join("session-1.jsonl"), line).unwrap();
fs::write(project_dir.join("session-2.jsonl"), line).unwrap();
let sessions = store.load_sessions().unwrap();
assert_eq!(sessions.len(), 2);
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
test_skips_non_jsonl_files function · rust · L382-L393 (12 LOC)src/store.rs
fn test_skips_non_jsonl_files() {
let (tmp, store) = create_test_store();
let project_dir = tmp.path().join("projects/-home-g-project");
fs::create_dir_all(&project_dir).unwrap();
fs::write(project_dir.join("not-a-session.txt"), "hello").unwrap();
fs::create_dir_all(project_dir.join("some-subdir")).unwrap();
let sessions = store.load_sessions().unwrap();
assert!(sessions.is_empty());
}test_sessions_sorted_by_updated_at_desc function · rust · L396-L413 (18 LOC)src/store.rs
fn test_sessions_sorted_by_updated_at_desc() {
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":"msg"},"uuid":"x"}"#;
fs::write(project_dir.join("old-session.jsonl"), line).unwrap();
std::thread::sleep(std::time::Duration::from_millis(50));
fs::write(project_dir.join("new-session.jsonl"), line).unwrap();
let sessions = store.load_sessions().unwrap();
assert_eq!(sessions.len(), 2);
assert_eq!(sessions[0].id, "new-session");
assert_eq!(sessions[1].id, "old-session");
}test_count_session_files function · rust · L416-L431 (16 LOC)src/store.rs
fn test_count_session_files() {
let (tmp, store) = create_test_store();
let p1 = tmp.path().join("projects/project-a");
let p2 = tmp.path().join("projects/project-b");
fs::create_dir_all(&p1).unwrap();
fs::create_dir_all(&p2).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();
fs::write(p2.join("s3.jsonl"), line).unwrap();
fs::write(p2.join("not-a-session.txt"), "ignore").unwrap();
assert_eq!(store.count_session_files(), 3);
}