use crate::budget::estimator::TokenEstimator;

#[derive(Debug, Clone, Default)]
pub struct SessionMetrics {
    pub commands_run: usize,
    pub tokens_before_total: usize,
    pub tokens_after_total: usize,
}

impl SessionMetrics {
    pub fn record(&mut self, tokens_before: usize, tokens_after: usize) {
        self.commands_run += 1;
        self.tokens_before_total += tokens_before;
        self.tokens_after_total += tokens_after;
    }

    pub fn savings_pct(&self) -> f64 {
        TokenEstimator::savings_pct(self.tokens_before_total, self.tokens_after_total)
    }

    pub fn tokens_saved(&self) -> usize {
        self.tokens_before_total
            .saturating_sub(self.tokens_after_total)
    }
}
