mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +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:
1 parent
8f0d2459ac
commit
9bd49c9dcc
122 files changed
+3685
-1980
No files matched your search
@@ -0,0 +1,76 @@
|
||||
//! Account profile loading and the Summary's year-view interaction.
|
||||
//! Aggregation changes reuse the loaded profile; account refresh replaces all profile data.
|
||||
|
||||
use super::AnalyticsView;
|
||||
use super::activity_chart::TokenActivityView;
|
||||
use super::client::Live;
|
||||
use super::data::Load;
|
||||
use super::sections::Section;
|
||||
use crate::keymap::ListAction;
|
||||
use codex_backend_client::AccountProfile;
|
||||
|
||||
pub(super) const VIEWS: [TokenActivityView; 3] = [
|
||||
TokenActivityView::Daily,
|
||||
TokenActivityView::Weekly,
|
||||
TokenActivityView::Cumulative,
|
||||
];
|
||||
|
||||
impl Live {
|
||||
pub(super) async fn profile(&self) -> Result<Option<AccountProfile>, String> {
|
||||
let session = self.session().await?;
|
||||
let profile = session
|
||||
.backend
|
||||
.request(|client| async move { client.get_account_profile().await })
|
||||
.await;
|
||||
session.backend.ensure_identity().await?;
|
||||
profile.map(Some).map_err(super::client::request_error)
|
||||
}
|
||||
}
|
||||
|
||||
impl AnalyticsView {
|
||||
pub(crate) fn select_summary(&mut self, view: Option<TokenActivityView>) {
|
||||
self.section = Section::Summary;
|
||||
self.zoomed = true;
|
||||
self.scroll_offset = 0;
|
||||
self.group_picker = None;
|
||||
if let Some(view) = view {
|
||||
self.sections[Section::Summary].group = VIEWS
|
||||
.iter()
|
||||
.position(|item| *item == view)
|
||||
.unwrap_or_default();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn load_summary(&mut self) {
|
||||
if let (Some((_, _, frame)), Some(live)) = (&self.connection, &self.live) {
|
||||
let live = std::sync::Arc::clone(live);
|
||||
self.profile = Load::start(async move { live.profile().await }, frame.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn summary_action(&mut self, action: Option<ListAction>) {
|
||||
let step = match action {
|
||||
Some(ListAction::MoveUp) => Some(-1),
|
||||
Some(ListAction::MoveDown) => Some(1),
|
||||
Some(ListAction::PageUp) => Some(-(self.viewport_height as isize)),
|
||||
Some(ListAction::PageDown) => Some(self.viewport_height as isize),
|
||||
Some(ListAction::JumpTop) => {
|
||||
self.scroll_offset = 0;
|
||||
Some(0)
|
||||
}
|
||||
Some(ListAction::JumpBottom) => {
|
||||
self.scroll_offset = usize::MAX;
|
||||
Some(0)
|
||||
}
|
||||
Some(ListAction::Cancel) => {
|
||||
self.is_done = true;
|
||||
None
|
||||
}
|
||||
Some(ListAction::MoveLeft | ListAction::MoveRight | ListAction::Accept) | None => None,
|
||||
};
|
||||
if let Some(step) = step {
|
||||
self.scroll_offset = self.scroll_offset.saturating_add_signed(step);
|
||||
self.follow_selection = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user