fix(claudbg-j9az): populate model from DB in TUI session list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Elijah Voigt 2 months ago
parent 0940c6f523
commit 7696a5560f

@ -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.

@ -226,7 +226,8 @@ 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<String, (String, usize)> = tokio::task::block_in_place(|| {
let db_enrichment: HashMap<String, (String, usize, String)> = 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 {
@ -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<String, (String, usize)> = HashMap::new();
let mut map: HashMap<String, (String, usize, String)> = 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();
}
}
}

Loading…
Cancel
Save