From 7696a5560f594eb6c46d3aaddc126c769cca912c Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Tue, 31 Mar 2026 23:13:10 -0700 Subject: [PATCH] fix(claudbg-j9az): populate model from DB in TUI session list Co-Authored-By: Claude Sonnet 4.6 --- ...el-column-always-blank-in-sessions-list.md | 5 +++-- src/tui/run.rs | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.beans/claudbg-j9az--tui-model-column-always-blank-in-sessions-list.md b/.beans/claudbg-j9az--tui-model-column-always-blank-in-sessions-list.md index f88cad2..0a0d947 100644 --- a/.beans/claudbg-j9az--tui-model-column-always-blank-in-sessions-list.md +++ b/.beans/claudbg-j9az--tui-model-column-always-blank-in-sessions-list.md @@ -1,10 +1,11 @@ --- # claudbg-j9az title: 'TUI: model column always blank in sessions list' -status: todo +status: in-progress type: bug +priority: normal created_at: 2026-04-01T06:10:52Z -updated_at: 2026-04-01T06:10:52Z +updated_at: 2026-04-01T06:12:23Z --- The Model column in the TUI session-list screen is always empty. Root cause: when building SessionListItem in src/tui/run.rs the model field is set to String::new(), and the DB enrichment query (SELECT session_id, project_path, message_count FROM sessions) does not fetch the model column. The model field does exist in the sessions DB table. Fix: add model to the enrichment SELECT and populate item.model during the enrichment loop. diff --git a/src/tui/run.rs b/src/tui/run.rs index 70dc542..c3d0550 100644 --- a/src/tui/run.rs +++ b/src/tui/run.rs @@ -226,8 +226,9 @@ pub fn run_tui() -> Result<()> { // Enrich session list with data from the DB cache (message counts and // fallback project paths for sessions whose JSONL first line has no cwd). // Best-effort: silently skip if the DB is missing or unreadable. - let db_enrichment: HashMap = tokio::task::block_in_place(|| { - tokio::runtime::Handle::current().block_on(async { + let db_enrichment: HashMap = tokio::task::block_in_place( + || { + tokio::runtime::Handle::current().block_on(async { let db_path = crate::db::connection::default_db_path(); let db = match crate::db::connection::open_db(&db_path, false).await { Ok(d) => d, @@ -239,7 +240,7 @@ pub fn run_tui() -> Result<()> { }; let mut rows = match conn .query( - "SELECT session_id, COALESCE(project_path, ''), message_count FROM sessions", + "SELECT session_id, COALESCE(project_path, ''), message_count, COALESCE(model, '') FROM sessions", (), ) .await @@ -247,7 +248,7 @@ pub fn run_tui() -> Result<()> { Ok(r) => r, Err(_) => return HashMap::new(), }; - let mut map: HashMap = HashMap::new(); + let mut map: HashMap = HashMap::new(); while let Ok(Some(row)) = rows.next().await { let sid: String = match row.get(0) { Ok(v) => v, @@ -255,17 +256,22 @@ pub fn run_tui() -> Result<()> { }; let project: String = row.get(1).unwrap_or_default(); let count: i64 = row.get(2).unwrap_or(0); - map.insert(sid, (project, count as usize)); + let model: String = row.get(3).unwrap_or_default(); + map.insert(sid, (project, count as usize, model)); } map }) - }); + }, + ); for item in &mut state.sessions { - if let Some((db_project, db_count)) = db_enrichment.get(&item.full_id) { + if let Some((db_project, db_count, db_model)) = db_enrichment.get(&item.full_id) { if item.project.is_empty() && !db_project.is_empty() { item.project = db_project.clone(); } item.msg_count = *db_count; + if item.model.is_empty() && !db_model.is_empty() { + item.model = db_model.clone(); + } } }