feat: Add local Codex Workspaces analytics - #2453
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 4:12 AM ET / 08:12 UTC. ClawSweeper reviewWhat this changesThis branch adds a local Codex Workspaces analytics feature with Settings controls, a menu submenu, a persistent inspector, model/session dashboards, CSV export, localization, and the associated local indexing support. Merge readiness⛔ Blocked until real behavior proof is added - 15 items remain Keep this draft open: it is intentionally staged behind the still-open foundation PR, and the remaining UI branch has two P1 correctness/privacy blockers plus missing after-fix UI proof. The requested preference-inheritance behavior also needs an explicit product decision before this becomes merge-ready. Priority: P2 Review scores
Verification
How this fits togetherCodexBar reads local Codex usage artifacts into its cost-usage layer, then presents provider usage in the menu bar and Settings. This change adds a Workspaces path that turns locally indexed sessions, projects, and model totals into a menu submenu and a detailed native inspector. flowchart LR
A[Local Codex session logs] --> B[Usage scanner and local cache]
C[Codex thread catalog] --> B
B --> D[Workspaces snapshot]
D --> E[Usage store refresh scheduler]
E --> F[Menu Workspaces submenu]
E --> G[Settings controls]
E --> H[Inspector: overview, sessions, models]
H --> I[CSV export]
Decision needed
Why: This changes the default behavior seen by existing users and cannot be selected safely from implementation evidence alone. Before merge
Findings
Agent review detailsSecurityNeeds attention: The proposed UI can expose a raw workspace path despite the existing personal-information hiding setting. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land and validate the non-UI foundation first, then rebase this branch to a UI-only diff that schedules refreshes, redacts displayed paths, localizes all dashboard strings, removes the release-note edit, and includes redacted fresh-bundle proof for the finished user flows. Do we have a high-confidence way to reproduce the issue? No. The two P1 paths are clear from the submitted code-review evidence, but no fresh-bundle run of this draft was available to demonstrate the failures end to end. Is this the best way to solve the issue? No. The staged split is the right direction, but this branch must first become a UI-only rebase on the merged foundation and address its refresh, privacy, localization, and release-note blockers. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cc8da27cec92. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca5b1f3a46
ℹ️ 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".
| await self.refreshTokenUsage(provider, force: force) | ||
| self.tokenRefreshSequenceProvider = nil | ||
| } | ||
| await self.refreshCodexLocalProjectUsage(force: force) |
There was a problem hiding this comment.
Route token refreshes through the Workspaces scheduler
When a menu- or window-triggered Workspaces refresh is already in flight, this direct call enters refreshCodexLocalProjectUsage, increments codexLocalProjectUsageRequestGeneration, and then returns because codexLocalProjectUsageRefreshInFlight is true. The active scan subsequently fails its generation guard and discards its result, while no pending refresh is queued, leaving the snapshot empty or stale until another trigger; schedule/coalesce this refresh instead of invoking it directly.
Useful? React with 👍 / 👎.
| if project.id == CodexLocalProjectRootResolver.chatsProjectId { | ||
| return L("codex_workspaces_chats_description") | ||
| } | ||
| return project.path ?? L("codex_workspaces_chats_description") |
There was a problem hiding this comment.
Redact workspace paths when personal information is hidden
When “Hide personal information” is enabled and a project path contains an email address, this submenu still returns and renders the raw path. That bypasses the setting's explicit promise to obscure email addresses in menu UI, so managed home directories such as /Users/name@example.com/... remain exposed; apply PersonalInfoRedactor or suppress the path before presenting it.
Useful? React with 👍 / 👎.
|
|
||
| private var title: some View { | ||
| HStack(alignment: .firstTextBaseline, spacing: 5) { | ||
| Text("Model usage").font(.headline) |
There was a problem hiding this comment.
Localize the Models dashboard strings
The default-enabled Models tab uses raw English literals here and throughout the new dashboard, while none of those literals (including “Model usage”) exist in any Localizable.strings file. Selecting a supported non-English app language therefore leaves this entire new surface in English; route the user-facing strings through L(...) and add them to the localization catalogs.
Useful? React with 👍 / 👎.
Staged proposal
This pull request is now the draft UI follow-up for Codex Workspaces. The scanner/cache/sidecar foundation has been extracted into:
codex/workspaces-foundation5c571d71ed6c557a217b7c457cb15f605f13d9b4cc8da27cec92029a6435bfee4a703a719290234e#2453 intentionally remains a draft until #2456 is reviewed and merged. After that merge, this branch will merge the updated
main, resolve overlapping core files in favor of the foundation, and retain only the menu, inspector, settings, presentation, accessibility, localization, and UI-specific test surface.Why the rollout is staged
The original combined change covered local scanner compatibility, two persisted artifacts, indexing, analytics, menu integration, and a native inspector. Splitting it gives the compatibility-sensitive foundation an independently testable merge boundary before the product UI is reviewed.
The foundation contains:
This follow-up will contain:
UsageStoreintegration.No additional cache version, sidecar schema, parser hash, or CI-policy change will be introduced in the UI follow-up.
Validation correction
The branch now restores the required-test contract in
ca5b1f3a:required + deferred + skippedmacOS tests keep the aggregate gate incomplete/failing.The 13 reported Spend Dashboard issues were investigated with an exact A/B comparison:
cc8da27ca29ca8765c571d71The failures were pre-existing wall-clock-sensitive/incomplete synthetic fixtures, not a demonstrated Workspaces production regression. The foundation makes those fixtures deterministic with a fixed clock and explicit USD currency while leaving production Spend Dashboard grouping, completeness, pricing, and cache behavior unchanged.
Foundation proof
All local gates below ran in a clean detached worktree at exact SHA
5c571d71without Keychain reads, browser imports, account probes, or network-dependent provider checks:make testmake checkgit diff --checkInspectible redacted real-workspace evidence is attached to #2456:
That evidence demonstrates cold schema-5 creation, v10 preservation and v11 creation, a warm incremental refresh, sidecar tables/counts, and same-scope complete → missing/corrupt catalog transitions that retain last-good project/session totals while reporting degraded source status.
Only sanitized copies were published. Paths, titles, session IDs, database rows, tokens, keys, identities, hostnames, IP addresses, and exported contents were excluded or redacted; the final log passed path/secret-pattern scans and the screenshot was inspected at full resolution.
Product decision requested
The proposed compatibility behavior for the UI follow-up is:
Maintainer approval of this staged boundary and inheritance default is required before #2453 is considered merge-ready.
Remaining gates for #2453
mainand reduce this PR’s current diff to UI integration.make test,make check, andgit diff --checkat the exact final UI SHA.This PR does not claim merge readiness while those items remain.