mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add an account Summary tab to Analytics (#45769)
## What changed - Make Summary the initial Analytics tab, showing profile identity, token totals, streaks, activity insights, and most-used plugins and skills. - Move daily, weekly, and cumulative token activity charts into Summary. Replace the usage menu's separate views with “View analytics”; `/usage weekly` and the other explicit modes open Summary with the requested view, while reopening from the menu retains navigation. - Load account profiles independently of other reports, preserve missing values separately from zero, and reject responses when the active account changes. Refresh retries profile failures. - Adapt Summary to narrow terminals and compact large chart totals and axis labels. Show the account email without its ID in the Analytics header. - Flush queued transcript history before opening an overlay so startup output stays in the transcript. ## Testing Add profile decoding and account identity tests, Summary layout and navigation snapshots, refresh and cancellation coverage, and regression tests for retained navigation and transcript history when opening Analytics. GitOrigin-RevId: 6dbe6c4c98209000d8b4bc18a4e01b98fab5991a
This commit is contained in:
@@ -8,6 +8,7 @@ mod painting;
|
||||
use self::layout::Layout;
|
||||
use self::painting::Band;
|
||||
use super::data;
|
||||
use super::data::compact_amount as tick;
|
||||
use super::render::parts;
|
||||
use crate::analytics::models::AccountAnalyticsDay;
|
||||
use crate::analytics::models::AccountAnalyticsUnit;
|
||||
@@ -110,8 +111,7 @@ pub(super) fn chart(
|
||||
&[Band::Positive][..]
|
||||
};
|
||||
let peak = axis_max(peak(days, categories), unit);
|
||||
let label_width =
|
||||
tick(peak, unit).width().max(tick(peak / 2.0, unit).width()) + bands.len() - 1 + 2;
|
||||
let label_width = tick(peak).width().max(tick(peak / 2.0).width()) + bands.len() - 1 + 2;
|
||||
let layout = Layout::new(days.len(), cursor, width, height, label_width, bands);
|
||||
let renderer = Renderer {
|
||||
days,
|
||||
@@ -164,20 +164,13 @@ struct Renderer<'a> {
|
||||
fn amount(value: f64, unit: AccountAnalyticsUnit) -> String {
|
||||
match unit {
|
||||
AccountAnalyticsUnit::RelativeUsage => data::amount(value),
|
||||
AccountAnalyticsUnit::Count | AccountAnalyticsUnit::Tokens => data::amount(value.round()),
|
||||
AccountAnalyticsUnit::Count | AccountAnalyticsUnit::Tokens => {
|
||||
data::compact_amount(value.round())
|
||||
}
|
||||
AccountAnalyticsUnit::Credits => data::credit_amount(value),
|
||||
}
|
||||
}
|
||||
|
||||
fn tick(value: f64, unit: AccountAnalyticsUnit) -> String {
|
||||
match unit {
|
||||
AccountAnalyticsUnit::Credits => data::amount(value),
|
||||
AccountAnalyticsUnit::RelativeUsage
|
||||
| AccountAnalyticsUnit::Count
|
||||
| AccountAnalyticsUnit::Tokens => amount(value, unit),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "plot_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user