Skip to content

fix(spend): name and rank session rows - #4020

Merged
steipete merged 2 commits into
steipete:mainfrom
urda:urda/spend-session-rows
Sep 26, 2026
Merged

steipete merged 2 commits into
steipete:mainfrom
urda:urda/spend-session-rows

Conversation

@urda

@urda urda commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Usage & Spend Sessions tab showed the same "Codex / " pair on every row. You could not tell sessions apart or see when they happened. Since #3353 moved this list into Settings, the row title holds the provider name and the subtitle holds the model, so the date shows only when the model is missing. The list also stopped at the 12 most recent sessions.

The data to fix this already exists:

  • The Codex cost cache stores each session's project path, but the session builder dropped it.
  • Codex keeps thread names in session_index.jsonl (and state_*.sqlite), and CodexThreadMetadataReader already reads them for agent sessions.

Changes

  • CostUsageSessionBreakdown gets three optional fields: projectPath, projectName, title. They default to nil, so existing call sites do not change.
  • The Codex session builder keeps the canonical project path, with the same rule as the Projects rows.
  • The fetcher adds thread names after the cost scan with CodexThreadMetadataReader. It skips the lookup when the sessions root is not inside a Codex home.
  • Session rows show the thread name, then the project, model, and date. An untitled session shows Session <short id>, like the menu Conversations list.
  • Rows rank by cost, like Projects (unpriced last), with a rank column. The list keeps the top 50 and collapses after 8 with Show all.
  • Hide personal information masks the thread name to the short session ID and drops the project. The model and date stay.
  • The dashboard snapshot fingerprint includes the title and project path, so a renamed thread re-renders.

Notes for review

  • Parser hash bump: the change in CostUsageScanner+Projects.swift regenerates CodexParserHash, so the Codex cost cache rescans once after upgrade.
  • Sort order: the order changes from newest first to most expensive first. This matches Projects and the "where did the money go" use of this panel.
  • Cap: "Show all (N)" counts the capped 50 rows, not every session in the range.
  • Gatekeeper anchors moved by a fixed offset per file (CostUsageFetcher.swift, SpendDashboardController.swift, SpendDashboardModel.swift).
  • shortSessionID is now nonisolated so that the nonisolated row identity can use it.

Screenshot

Synthetic fixture render from SpendDashboardScreenshotRenderTests (CODEXBAR_SPEND_PROOF_DIR):

Validation

  • make check: 0 violations.
  • make test: 129 of 129 groups passed on the first pass. (Local run with --build-system native because of an Xcode 27 actool issue on my machine.)
  • New tests:
    • SpendDashboardSessionRowTests: cost ranking, unpriced last, 50-row cap, name and project carry-through, privacy masking, short-ID fallback.
    • CostUsageFetcherTests: a fixture session_index.jsonl name and a rollout cwd reach the snapshot, and the lookup skips roots outside a Codex home.
  • All tests use synthetic files. No live accounts, credentials, or Keychain reads.

Follow-ups (not in this PR)

  • The menu Conversations list could show the new title.
  • Claude sessions do not appear in this tab yet.
usage-spend-sessions

Show the Codex thread name, project, and date on each Usage & Spend
session row instead of the provider name. Rank sessions by cost like
Projects, keep up to 50, and collapse after 8 with Show all. Hide
personal information masks the name to the short session ID and drops
the project.
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 26, 2026, 1:04 PM ET / 17:04 UTC (Revision 2).

ClawSweeper review

What this changes

The branch gives Usage & Spend session rows thread and project names, dates, cost ranking, privacy masking, an expandable 50-row limit, and supporting tests and documentation.

Merge readiness

⛔ Blocked before merge - 2 items remain

Current main still shows generic session rows, so this PR remains useful. The latest commit addresses the prior relative SQLite home finding with a focused test. The remaining merge blocker is proof from a freshly built app using real local Codex sessions.

Priority: P2
Reviewed head: e0041c805d58534ec353f5f903cddf99d40e5544

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch and focused tests are useful, but its synthetic evidence leaves the required real app behavior unproven.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The changed cost fetcher and settings rows are covered by synthetic session files and a synthetic UI render; no after-fix run of a freshly built app reading real local Codex sessions is shown. A redacted screenshot or recording could show the result; redact paths, keys, and other private details. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. The change adds in-memory row fields and a cache rescan, with no stored-data schema change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed cost fetcher and settings rows are covered by synthetic session files and a synthetic UI render; no after-fix run of a freshly built app reading real local Codex sessions is shown. A redacted screenshot or recording could show the result; redact paths, keys, and other private details. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. The change adds in-memory row fields and a cache rescan, with no stored-data schema change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main behavior: The fetched main revision still displays the provider name and either the model or date in session rows.
Introduced behavior: The pinned merge-base-to-head diff carries titles and projects into ranked dashboard rows and masks them for private display.
Prior finding addressed: The current fetch path resolves relative SQLite homes from each session's original working directory; the new test covers two rollouts whose canonical project path is shared.
Findings None None.
Security None None.

How this fits together

CodexBar scans local Codex session files and cost history to build the Usage & Spend dashboard. The settings view turns those session records into ranked rows while applying the privacy setting.

flowchart LR
A[Local Codex sessions] --> B[Cost scan]
C[Thread index and database] --> D[Session metadata lookup]
B --> E[Dashboard rows]
D --> E
F[Privacy setting] --> E
E --> G[Ranked session list]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed cost fetcher and settings rows are covered by synthetic session files and a synthetic UI render; no after-fix run of a freshly built app reading real local Codex sessions is shown. A redacted screenshot or recording could show the result; redact paths, keys, and other private details. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. The change adds in-memory row fields and a cache rescan, with no stored-data schema change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Add redacted after-fix proof from a freshly built CodexBar app showing real local Codex sessions named and ranked in Usage & Spend, including the privacy setting.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and test growth production +138 lines, tests +412 lines The production growth supports session metadata and presentation, with substantially more focused test coverage.

Technical review

Best possible solution:

Land the bounded dashboard change once a freshly built CodexBar app demonstrates named, ranked, and privacy-masked rows from real local Codex sessions.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main renders the provider name for each session and caps the newest-first list at 12. The review did not run the app.

Is this the best way to solve the issue?

Yes. The branch reuses the existing Codex thread metadata reader and dashboard row model, and the latest test covers the previously identified relative SQLite path case.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5890d052a3be.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded improvement to the spend dashboard's session identification and ordering.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed cost fetcher and settings rows are covered by synthetic session files and a synthetic UI render; no after-fix run of a freshly built app reading real local Codex sessions is shown. A redacted screenshot or recording could show the result; redact paths, keys, and other private details. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. The change adds in-memory row fields and a cache rescan, with no stored-data schema change. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Yuxin-Qiao: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • urda: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted after-fix proof from the freshly built app using real local Codex sessions.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-26T11:12:28.257Z sha f705fee :: needs real behavior proof before merge. :: [P2] Resolve relative SQLite homes for each session

Resolve relative SQLite homes from the original rollout directory and format session subtitles with the dashboard calendar. Cover privacy masking, deterministic ranking, unchanged totals, and synthetic renders; simplify title and rank copies. Follow up on steipete#4020 while preserving the contributor commit.
@steipete
steipete merged commit 9c4bd43 into steipete:main Sep 26, 2026
9 checks passed
@urda
urda deleted the urda/spend-session-rows branch September 26, 2026 18:31
@steipete

Copy link
Copy Markdown
Owner

Merged as yours, @urda, with your commit intact; the maintainer commit on your branch fixed two things the review found (a relative CODEX_SQLITE_HOME now resolves against the rollout's working directory, and subtitle dates use the dashboard's calendar so a UTC dashboard doesn't show the previous day on a Los Angeles Mac) and added privacy and ranking tests. Titles stay masked under Hide personal info. Ships in 0.67.1. Thanks!

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

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants