feat: sync ecc2 cost tracker metrics

This commit is contained in:
Affaan Mustafa
2026-04-09 06:22:20 -07:00
parent cf9c68846c
commit 08f61f667d
8 changed files with 352 additions and 13 deletions

View File

@@ -673,17 +673,20 @@ async fn main() -> Result<()> {
}
}
Some(Commands::Sessions) => {
sync_runtime_session_metrics(&db, &cfg)?;
let sessions = session::manager::list_sessions(&db)?;
for s in sessions {
println!("{} [{}] {}", s.id, s.state, s.task);
}
}
Some(Commands::Status { session_id }) => {
sync_runtime_session_metrics(&db, &cfg)?;
let id = session_id.unwrap_or_else(|| "latest".to_string());
let status = session::manager::get_status(&db, &id)?;
println!("{status}");
}
Some(Commands::Team { session_id, depth }) => {
sync_runtime_session_metrics(&db, &cfg)?;
let id = session_id.unwrap_or_else(|| "latest".to_string());
let team = session::manager::get_team_status(&db, &id, depth)?;
println!("{team}");
@@ -890,6 +893,15 @@ fn resolve_session_id(db: &session::store::StateStore, value: &str) -> Result<St
.ok_or_else(|| anyhow::anyhow!("Session not found: {value}"))
}
fn sync_runtime_session_metrics(
db: &session::store::StateStore,
cfg: &config::Config,
) -> Result<()> {
db.refresh_session_durations()?;
db.sync_cost_tracker_metrics(&cfg.cost_metrics_path())?;
Ok(())
}
fn build_message(
kind: MessageKindArg,
text: String,