Skip to content

Add local Codex session analytics drilldowns#622

Open
Undertone0809 wants to merge 4 commits intosteipete:mainfrom
Undertone0809:codex/codex-session-analytics-v1
Open

Add local Codex session analytics drilldowns#622
Undertone0809 wants to merge 4 commits intosteipete:mainfrom
Undertone0809:codex/codex-session-analytics-v1

Conversation

@Undertone0809
Copy link
Copy Markdown

@Undertone0809 Undertone0809 commented Mar 30, 2026

What changed

  • add local Codex session analytics backed by rollout JSONL instead of remote dashboard data
  • add persisted analytics window presets (10 / 20 / 50 / 100), token usage parsing, and summary/tool diagnostics
  • restructure the Session Analytics UI into a compact overview with nested drilldown submenus, add a top-tools donut chart, and remove row chevrons from analytics items
image image

Why

  • this gives CodexBar a local process-oriented analytics view for Codex sessions without depending on OpenAI dashboard cookies
  • the earlier inline-detail layout made the analytics submenu too tall and clipped in practice; nested drilldowns keep the primary menu scannable and stable

User impact

  • Codex users can inspect recent sessions, tool behavior, failures, long-running calls, and token breakdowns from local data
  • users can change the analytics window size from the menu and keep that preference across launches

Validation

  • pnpm check
  • swift test --filter CodexSessionAnalyticsLoaderTests
  • swift test --filter SettingsStoreCoverageTests
  • swift test --filter "codex menu includes session analytics submenu when snapshot is present"
  • swift test --filter "codex session analytics submenu exposes empty state without local data"
  • ./Scripts/compile_and_run.sh

@Undertone0809 Undertone0809 marked this pull request as ready for review March 30, 2026 11:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08b2c5fb14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let submenu = NSMenu()
submenu.autoenablesItems = false
submenu.delegate = self
self.populateSessionAnalyticsSubmenu(submenu)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh analytics submenu on every open

This submenu is populated only once at creation time, so subsequent opens reuse stale NSMenuItem content and never call requestCodexSessionAnalyticsRefreshIfStale again. In practice, when no unrelated store/settings invalidation occurs (for example with manual refresh), newly written rollout files are not reflected in Session Analytics until some other action rebuilds the parent menu or the user changes window size, which makes the drilldown silently outdated.

Useful? React with 👍 / 👎.

@Undertone0809 Undertone0809 changed the title [codex] Add local Codex session analytics drilldowns Add local Codex session analytics drilldowns Mar 30, 2026
@Undertone0809
Copy link
Copy Markdown
Author

Undertone0809 commented Mar 30, 2026

This update fixes a performance problem: once the local .codex history gets large, opening CodexBar or hovering into Session Analytics could end up scanning a lot of rollout files and reading a lot of JSONL data, which made the menu feel slow. Even after making the submenu lazy, opening analytics could still hit that expensive path, so the real issue was not the UI itself but that data loading was still happening right in the interaction path.

The fix was to move that work out of the interaction path. Session analytics are now stored in a local cached index, loaded at startup, and served from memory when the menu or hover UI opens. If local .codex data changes, the app marks analytics as stale and refreshes them incrementally in the background instead of recalculating everything when the user opens the menu. That means the user sees data immediately, and the refresh happens quietly behind the scenes.

@Undertone0809
Copy link
Copy Markdown
Author

@steipete What do you think of this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant