Skip to content

Add Pi token usage provider - #3246

Open
Yuxin-Qiao wants to merge 48 commits into
steipete:mainfrom
Yuxin-Qiao:feat/pi-provider-tokscale
Open

Add Pi token usage provider#3246
Yuxin-Qiao wants to merge 48 commits into
steipete:mainfrom
Yuxin-Qiao:feat/pi-provider-tokscale

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Add Pi as an opt-in local-history provider with its own menu, dashboard source, icon, widget choice, and documentation. Thanks @Yuxin-Qiao for the original implementation; the maintainer follow-up repairs the shared accounting and filesystem boundaries on this same PR.

Pi combines supported Anthropic and OpenAI Codex Pi/OMP session usage. Standalone Claude and unscoped Codex keep their existing inclusive reports. Combined Usage & Spend and Overview views instead select retained native-only values when a visible Pi source owns the same history, so every contribution is counted once. Native account-scoped Codex remains Pi-free. Pi is a local source, not an extra subscription.

The live-session and historical readers now share Pi root selection. Historical caches and publications carry root identity and completeness; explicit missing or invalid roots fail closed, absent default history is unavailable, and malformed/truncated/unsupported records cannot become falsely complete history. Project/global settings, custom agent directories, OMP profiles and eligible XDG roots have isolated regression coverage. A valid custom Pi settings directory does not require a companion OMP installation.

The icon uses a font-free transparent glyph so macOS template rendering retains the Pi mark. Documentation explains the assistant-message list-price estimator, unsupported billing components, standalone CLI behavior, and widget coverage limitations.

Maintainer verification

  • Candidate commit: 6f5e173d9020e6f49f73e34de615d5f4468a386a. The integration commit fa1ab1d9fe9427df40977ab1e6c872773468bd92 preserves the original contributor commit as a merge parent. Two small follow-ups fix Linux hashing imports and repeated cache persistence.
  • Integration-focused run on fa1ab1d9fe9 with the repository's canonical --no-parallel setting: 224 tests in 20 suites, plus four portable tests executed on macOS, passed. The production-view render test also passed. Coverage includes accounting/visibility, native accounts, root/cache contracts, backend/day-specific partial evidence, malformed records and boolean counters/timestamps, publication ownership, cached startup, and provider architecture.
  • Final make check: passed, zero violations across 2,045 Swift files.
  • Full make test on 6f5e173d902: passed all 963 selections across 81 groups in 1,976.1 seconds. Eighty groups passed initially; one cache-test group reached the normal 180-second limit and recovered when all twelve selections passed individually through the existing runner. There were no full-group retries, source/assertion changes, or deadline increases; non-timeout retries stayed disabled. Earlier interrupted candidate runs are not full-pass claims.
  • Independent source review: clean, no actionable P0–P2 findings after repairing the five accepted findings at their shared owners. The generated social-card PNG was visually reviewed separately from the complete source/test/documentation/SVG/HTML review.
  • The portability follow-up passed 69 focused tests and four portable tests on macOS, final make check, and a clean independent review of the four-line diff.
  • The first hosted CI run exposed an unconditional CryptoKit import on Linux. The existing Swift Crypto dependency is now selected there, matching the repository's established pattern. Replacement CI run 33123394523 builds on Linux, including a successful musl job, but its x64/ARM test jobs exposed a saved-cache reload failure. The x64 run executed 455 tests in 63 suites with four failed cache-coverage assertions; the corresponding in-memory parser assertions passed. Remaining obsolete jobs were canceled.
  • The cache follow-up replaces the manual file swap with one atomic write to the final cache path. It passed 61 focused tests and five portable tests on macOS, make check, explicit portable format/lint, and a clean independent review. The new regression reads the actual JSON after both first and replacement saves, checks changed values, and rejects stray temporary files. These macOS results are not a native Linux pass.
  • Final CI run 33124888635: all eight jobs passed on 6f5e173d9020e6f49f73e34de615d5f4468a386a, including native Linux x64/ARM64 builds, tests and CLI smoke checks, musl build, both macOS test shards, lint, and the aggregate gate. The cache repair is now verified on native Linux.

Tests use synthetic history, isolated stores, and Keychain/file-access safeguards. The rendered light/dark menus, dashboard, Overview and widget use production views and the same synthetic accounting fixture: standalone Claude $12/120K tokens, Pi $5/50K, combined $15/150K with native Claude $10/100K. Widget publication is also tested through the in-memory save boundary.

One earlier broad focused run used parallel execution and hit the dashboard test's 30-second wait while a main-actor architecture audit occupied roughly 32 seconds. With the repository's existing serial test setting, that same publication test passed in 1.8 seconds and the entire focused set passed. No deadline, assertion, or source change was made to hide the timeout.

These are offscreen render and publication proofs, not installed-app or installed WidgetKit proofs. All automated gates are green, but packaged runtime validation remains a maintainer-owned hold and this PR is not yet merged. No contributor change request is needed. No live account or credential probe, release, or installed-widget claim is included.

Focused verification command
env -u CODEXBAR_ALLOW_TEST_KEYCHAIN_ACCESS \
  CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 \
  CODEXBAR_TEST_CODEX_FILE_ISOLATION=1 \
  CODEXBAR_TEST_RETRY_NON_TIMEOUT_FAILURES=0 LIVE_GEMINI_FETCH=0 \
  swift test --no-parallel --filter 'PiRecordValidationTests|PiPartitionCoverageTests|PiRootSelectionContractTests|PiHistoryCoverageTests|PiHistoryScopeLinuxTests|PiProviderTests|PiSessionCostScannerTests|PiSessionCostCompatibilityTests|PiSpendAccountingTests|PiPublicationTests|PiNativeAccountingTests|CostUsageFetcherTests|CostUsageFetcherCacheSnapshotTests|CostUsageFetcherUnknownModelPricingTests|OverviewSpendSummaryTests|SpendDashboardModelTests|SpendDashboardPublicationTests|ProviderArchitectureGatekeeperTests|ProviderIconResourcesTests|UsageStoreCachedTokenHydrationTests|PiFamilySessionTests.*custom session directories|MenuLayoutScreenshotRenderTests.test_renderPiAccountingProof'

The render test additionally used an owned temporary output directory through CODEXBAR_PI_PROOF_DIR.

Visual proof

All images contain synthetic data rendered through production views on integration commit fa1ab1d9fe9. Its final rerender is byte-identical to the inspected attachments. The subsequent Linux import and cache-write corrections change no rendering code or synthetic accounting values.

Dashboard before and after icon/source-label cleanup

Before: the first integrated render already includes the accounting repair, but incorrectly calls Pi a subscription and loses the template glyph. This is not the original contributor commit or an installed-app screenshot.

Dashboard before maintainer icon and source-label cleanup

After: the same synthetic amounts, with correct source labels and a visible Pi template glyph.

Dashboard after maintainer icon and source-label cleanup

Combined Overview and Pi cost-only widget in dark appearance

Combined Overview with one subscription and one local source

Pi cost-only production widget view with synthetic data

@clawsweeper

clawsweeper Bot commented Aug 27, 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.

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

Copy link
Copy Markdown

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: c3732c325e

ℹ️ 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 piDaily: CostUsageDailyReport = try await CostUsageScanExecutor.run { checkCancellation in
try PiSessionCostScanner.loadDailyReportCancellable(
// Provider-specific by design: this call reads Pi's local aggregate session ledger.
provider: .pi,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Deduplicate Pi spend from Claude totals

When Pi and Claude are both enabled with cost usage, this branch publishes Claude-priced Pi rows under Pi, while the existing loadLocalTokenScanResult path still merges those same rows into Claude at CostUsageFetcher.swift:726-740; SpendDashboardModel then sums provider totals at line 522, so Claude-backed Pi tokens and spend are counted twice. Assign these rows to only one dashboard source or explicitly deduplicate the overlap.

Useful? React with 👍 / 👎.


// Provider-specific by design: Pi has an independent aggregate token-cost history over its local JSONL logs.
if provider == .pi {
var piOptionsOnly = overridePiScannerOptions ?? PiSessionCostScanner.Options()

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 Resolve configured Pi session roots

For users who relocate sessions through PI_CODING_AGENT_SESSION_DIR, PI_CODING_AGENT_DIR, Pi's sessionDir setting, or OMP profiles, constructing default options here ignores the supplied environment and scans only ~/.pi/agent/sessions and ~/.omp/agent/sessions. The existing root logic in PiFamilySessionScanner.swift:631-698 already recognizes these supported layouts, but the new token provider will report no sessions for them unless equivalent roots are passed into PiSessionCostScanner.Options.

Useful? React with 👍 / 👎.

@steipete steipete left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maintainer update

I have repaired items 1–3 directly on this PR, preserving @Yuxin-Qiao's contributor credit. The integration is in fa1ab1d9fe9427df40977ab1e6c872773468bd92, with Linux portability and cache-persistence follow-ups through 6f5e173d9020e6f49f73e34de615d5f4468a386a. Regression coverage now exercises disjoint combined totals, native account isolation, selected filesystem scope, cache identity, and incomplete history. Independent review is clean, and both native Linux build/test/smoke jobs pass.

Final verification and the remaining installed-app/widget proof are maintainer-owned. No further contributor changes are requested. The current commands, results, CI links, and proof limitations are recorded in the PR description; this review remains blocking until the remaining verification is complete.

Original source review — historical findings, now repaired

Thanks @Yuxin-Qiao. Reusing the existing scanner and provider descriptors is a sensible starting point, but this needs changes before merge. I checked c3732c3 against main b4694bd and followed the actual shared-spend callers.

  1. Prevent overlapping Claude/Pi totals. The new Pi report merges the Anthropic and OpenAI Codex Pi ledgers, while CostUsageFetcher still merges Anthropic Pi rows into Claude by default. UsageStore.loadTokenUsageSnapshot leaves that default enabled, and the shared spend model sums the distinct Claude and Pi source inputs. With both enabled and visible, the same Anthropic Pi event contributes twice. Native account-scoped Codex dashboard scans explicitly exclude Pi, so this is not a claim that every Codex view doubles usage. Define whether Pi is a non-additive view of the existing ledger or a disjoint additive source, and prove exactly-once combined totals with Pi plus Claude, including non-Pi Claude usage and source visibility changes. Hiding all Claude usage or subtracting aggregate totals would lose the required attribution.

  2. Honor the selected filesystem scope. The new fetcher branch does not pass its supplied environment into root resolution; default scanner options read the ambient user's .pi/.omp directories. Agent Sessions already recognizes configured Pi roots and supplied HOME, so relocated history can appear there but be absent from the new provider—or the provider can inspect the wrong default root. Resolve an explicit supported root context and tie cache identity to it. Cover configured versus ambient roots, supplied HOME and OMP profile boundaries using isolated fixtures; do not broaden scanning to every profile as a fallback.

  3. Do not claim established history without coverage evidence. The branch unconditionally sets historyCoverageIsEstablished: true, but the reused scanner returns empty discovery for some missing/unreadable roots and skips malformed/truncated records/read failures. Its report currently covers only the two recognized backends. Carry scan-completeness evidence into the snapshot and distinguish confirmed empty from unavailable/partial history. Add negative fixtures, not just an assertion that the flag is true. Keep this at the scanner/report boundary; it should not become another provider-specific publication workaround.

The submitted tests exercise the isolated aggregate and registration, not these combined-source and failure cases. This review is source-based; I have not run this PR's tests or independently verified its reported CI/runtime results. Once the accounting contract is settled and those regressions are covered, the cost-only menu/widget behavior still needs packaged runtime proof. Keeping the provider opt-in does not resolve the overlap or scope issues.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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 Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 11, 2026, 6:57 AM ET / 10:57 UTC (Revision 60).

ClawSweeper review

What this changes

Adds an opt-in Pi local-history provider across the app, CLI, spend dashboard, and widget, with shared session discovery, estimated costs, and cache provenance.

Merge readiness

Blocked before merge - 6 items remain

This remains a useful, distinct provider addition. Two prior provenance defects persist, and the process-cap repair only covers identical commands. The recorded maintainer-owned runtime verification hold also remains unresolved.

Priority: P2
Reviewed head: 882d0a49ad402299795686f53efbd3654c6c1b7c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Substantial implementation and focused coverage provide useful signal, but three source-backed defects and incomplete runtime proof prevent readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The four inspected screenshots demonstrate synthetic production-view presentation on fa1ab1d, but do not exercise current process discovery, retained-history cache transitions, or installed app/widget publication. The recorded review assigns the remaining verification to steipete. 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 🦐 gold shrimp (3/6) 3 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The four inspected screenshots demonstrate synthetic production-view presentation on fa1ab1d, but do not exercise current process discovery, retained-history cache transitions, or installed app/widget publication. The recorded review assigns the remaining verification to steipete. 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 10 items Shared roots retain only one selector: The merge combines availability flags but keeps only existing.retentionKey ?? candidate.retentionKey. Multiple settings files selecting one directory cannot all survive cache serialization and later revalidation.
Retained metadata loses to existing paths: appendingPreviousSessionRoots skips retained entries when their paths already exist in the current roots, including at lines 518, 530, and 544. A default root therefore prevents restoration of required/live or unresolved metadata; complete scans subsequently remove absent cached contributions.
Process-cap repair remains partial: Context identity includes the entire command and argv, then truncates to maxProcessCount. Different model arguments can consume separate slots despite selecting the same history root. The added regression covers repeated identical commands only.
Findings 3 actionable findings [P2] Preserve every selector when merging shared roots
[P2] Merge retained metadata into existing default roots
[P2] Deduplicate root selectors before applying the process cap
Security None None.

How this fits together

CodexBar reads local Pi and OMP session logs to estimate token usage and spending. Root discovery and cached accounting feed provider menus, combined spending views, CLI output, and widget snapshots.

flowchart TD
  A[Live processes and settings] --> B[Resolve session stores]
  B --> C[Read Pi and OMP logs]
  D[Retained cache provenance] --> B
  C --> E[Estimate usage and costs]
  E --> D
  E --> F[Separate Pi and native totals]
  F --> G[Menus dashboard CLI and widget]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The four inspected screenshots demonstrate synthetic production-view presentation on fa1ab1d, but do not exercise current process discovery, retained-history cache transitions, or installed app/widget publication. The recorded review assigns the remaining verification to steipete. 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.
  • Preserve every selector when merging shared roots (P2) - This prior finding remains unresolved. If two projects' settings select the same custom directory, this merge retains only the first settings key. After both processes exit, removing that first selector makes cache revalidation drop the shared root even when the second settings file still selects it; the next complete scan removes its cached usage. Retain and revalidate all selectors associated with the root.
  • Merge retained metadata into existing default roots (P2) - This prior finding remains unresolved. Cache a live explicit selector targeting the default Pi directory, then let the process exit. Ambient discovery already contains that path, so this guard discards the retained required/live metadata and leaves it optional. If the directory becomes unavailable, the scanner treats it as known-empty and deletes cached usage. Merge retained strictness, completeness, and provenance into an existing root instead of skipping it.
  • Deduplicate root selectors before applying the process cap (P2) - The latest commit fixes repeated identical commands, but the prior cap defect remains for commands that differ without selecting different stores. With a cap of two, two newer pi --model ... commands in one project consume both slots and still exclude an older pi --session-dir ... process. The key includes complete argv and command text, and truncation carries no incomplete-discovery signal, so the cost scanner can publish complete-looking totals without that custom history. Deduplicate root-relevant selections or propagate truncation as incomplete.
  • Resolve merge risk (P1) - The v8-to-v9 cache transition forces a history rebuild for existing users; fresh-install and upgrade behavior with real stores has not been demonstrated on the current candidate.
  • Complete next step (P2) - Resolve the three remaining discovery/provenance findings and have steipete complete the recorded runtime and upgrade verification before lifting the merge hold.

Findings

  • [P2] Preserve every selector when merging shared roots — Sources/CodexBarCore/PiFamilySessionScanner.swift:434-439
  • [P2] Merge retained metadata into existing default roots — Sources/CodexBarCore/PiSessionCostScanner.swift:543-549
  • [P2] Deduplicate root selectors before applying the process cap — Sources/CodexBarCore/LocalAgentSessionScanner.swift:252-253
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +2,725/−672 (net +2,053); tests +2,838/−194 (net +2,644) The stated scope includes provider integration, shared discovery, accounting, and cache compatibility, extending beyond provider registration.

Merge-risk options

Maintainer options:

  1. Repair provenance and verify cache upgrades (recommended)
    Finish the shared discovery repairs and demonstrate fresh and upgraded history publication before the maintainer lifts the existing hold.

Technical review

Best possible solution:

Preserve all root selectors and availability metadata through discovery and cache reload, report bounded discovery honestly, and verify fresh and upgraded installations before lifting the recorded runtime hold.

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

Yes, the remaining patch defects have concrete source-level triggers involving shared selectors, retained default roots, and capped process contexts; no runtime reproduction was executed.

Is this the best way to solve the issue?

The existing scanner and provider framework are appropriate, but the current implementation needs lossless provenance merging and explicit handling of incomplete discovery.

Full review comments:

  • [P2] Preserve every selector when merging shared roots — Sources/CodexBarCore/PiFamilySessionScanner.swift:434-439
    This prior finding remains unresolved. If two projects' settings select the same custom directory, this merge retains only the first settings key. After both processes exit, removing that first selector makes cache revalidation drop the shared root even when the second settings file still selects it; the next complete scan removes its cached usage. Retain and revalidate all selectors associated with the root.
    Confidence: 0.98
  • [P2] Merge retained metadata into existing default roots — Sources/CodexBarCore/PiSessionCostScanner.swift:543-549
    This prior finding remains unresolved. Cache a live explicit selector targeting the default Pi directory, then let the process exit. Ambient discovery already contains that path, so this guard discards the retained required/live metadata and leaves it optional. If the directory becomes unavailable, the scanner treats it as known-empty and deletes cached usage. Merge retained strictness, completeness, and provenance into an existing root instead of skipping it.
    Confidence: 0.98
  • [P2] Deduplicate root selectors before applying the process cap — Sources/CodexBarCore/LocalAgentSessionScanner.swift:252-253
    The latest commit fixes repeated identical commands, but the prior cap defect remains for commands that differ without selecting different stores. With a cap of two, two newer pi --model ... commands in one project consume both slots and still exclude an older pi --session-dir ... process. The key includes complete argv and command text, and truncation carries no incomplete-discovery signal, so the cost scanner can publish complete-looking totals without that custom history. Deduplicate root-relevant selections or propagate truncation as incomplete.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4cfb60692bdd.

Labels

Label justifications:

  • P2: This useful provider addition has bounded history-accounting defects without evidence of an urgent deployed outage.
  • merge-risk: 🚨 compatibility: The branch changes shared Pi history discovery and persistent cache interpretation used by existing Claude/Codex reports.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The four inspected screenshots demonstrate synthetic production-view presentation on fa1ab1d, but do not exercise current process discovery, retained-history cache transitions, or installed app/widget publication. The recorded review assigns the remaining verification to steipete. 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.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The four inspected screenshots demonstrate synthetic production-view presentation on fa1ab1d, but do not exercise current process discovery, retained-history cache transitions, or installed app/widget publication. The recorded review assigns the remaining verification to steipete.

Evidence

What I checked:

  • Shared roots retain only one selector: The merge combines availability flags but keeps only existing.retentionKey ?? candidate.retentionKey. Multiple settings files selecting one directory cannot all survive cache serialization and later revalidation. (Sources/CodexBarCore/PiFamilySessionScanner.swift:439, 882d0a49ad40)
  • Retained metadata loses to existing paths: appendingPreviousSessionRoots skips retained entries when their paths already exist in the current roots, including at lines 518, 530, and 544. A default root therefore prevents restoration of required/live or unresolved metadata; complete scans subsequently remove absent cached contributions. (Sources/CodexBarCore/PiSessionCostScanner.swift:544, 882d0a49ad40)
  • Process-cap repair remains partial: Context identity includes the entire command and argv, then truncates to maxProcessCount. Different model arguments can consume separate slots despite selecting the same history root. The added regression covers repeated identical commands only. (Sources/CodexBarCore/LocalAgentSessionScanner.swift:253, 882d0a49ad40)
  • Prior findings checked against the previous head: The two provenance-owner files are unchanged since the immediately preceding review. GitHub's commit endpoint confirms the latest commit changes process-context collection, its regression, and architecture anchors. (882d0a49ad40)
  • Maintainer explicitly owns the verification hold: The live review by steipete remains CHANGES_REQUESTED and assigns final installed-app/widget verification to the maintainer, with no further contributor changes requested in that disposition. Its recorded validation concerns earlier candidates, not the current head.
  • Four visual artifacts inspected: All four prepared images were opened locally. They show the corrected Pi glyph, synthetic $15/150K combined totals, one subscription plus one local source, and a Pi widget view. The captured body identifies these as offscreen production-view renders on fa1ab1d, explicitly excluding installed-app and installed-widget proof. (fa1ab1d9fe94)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ngutman: 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.

  • Finish all three discovery/provenance repairs with isolated regressions for selector removal, process exit, cache reload, and non-root command differences.
  • Have the recorded owner provide current-candidate real-history, fresh-install/cache-upgrade, and installed app/widget evidence; screenshots or recordings are preferred for visible behavior, with terminal traces or logs for accounting.
  • Redact private paths, identifiers, endpoints, and credentials; update the PR body for automatic re-review, or ask a maintainer to comment @clawsweeper re-review.

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 (59 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-11T08:43:27.627Z sha eca903f :: needs real behavior proof before merge. :: [P2] Merge same-dialect roots before discarding duplicate paths | [P2] Merge retained provenance when a default root already exists | [P2] Include live process roots in startup source detection
  • reviewed 2026-09-11T08:59:49.574Z sha 911d5d2 :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots
  • reviewed 2026-09-11T09:10:32.543Z sha 911d5d2 :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots | [P2] Honor live OMP profiles during ambient root discovery
  • reviewed 2026-09-11T09:34:22.420Z sha 47a2bdd :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots
  • reviewed 2026-09-11T10:07:04.202Z sha 3239a16 :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots
  • reviewed 2026-09-11T10:15:57.580Z sha 3239a16 :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots | [P1] Preserve legacy history when the default XDG store exists
  • reviewed 2026-09-11T10:37:32.963Z sha fbdfd55 :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots
  • reviewed 2026-09-11T10:46:51.775Z sha fbdfd55 :: needs real behavior proof before merge. :: [P2] Preserve every selector when merging shared roots | [P2] Merge retained metadata into existing default roots | [P2] Preserve distinct history roots before applying the process cap

steipete added a commit to Yuxin-Qiao/CodexBar that referenced this pull request Aug 27, 2026
Integrate the Pi provider and preserve standalone Claude/Codex reports while
counting selected Pi history exactly once in combined spend surfaces.
Bind scans, caches and publications to validated roots and coverage, share
Pi settings resolution, and retain native Codex account isolation.

Add isolated regression and production-view proof, repair template icon and
local-source labels, and document the estimator's accounting limits.

Refs steipete#3246
Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 Urgent regression or broken agent/channel workflow affecting real users now. labels Aug 27, 2026
@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/pi-provider-tokscale branch from 6f5e173 to 9723a64 Compare September 2, 2026 10:59

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

Copy link
Copy Markdown

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: 9723a6497c

ℹ️ 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".

@@ -0,0 +1 @@
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="48" fill="#7C3AED"/><text x="50" y="62" text-anchor="middle" font-family="Helvetica, Arial, sans-serif" font-size="42" font-weight="700" fill="white">π</text></svg> No newline at end of file

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 Preserve the Pi glyph in the template icon

ProviderBrandIcon.image(for:) marks every provider SVG as a template image, but this asset composites opaque white text over an opaque purple circle. Template rendering uses the resulting alpha mask, which is only a solid circle, so the π disappears anywhere the provider brand icon is displayed. Encode the glyph and surrounding shape using transparency, preferably with paths rather than font-dependent SVG text.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Sep 2, 2026
Yuxin-Qiao and others added 5 commits September 3, 2026 02:48
Use a final-path atomic write and cover repeated cache saves with a portable roundtrip regression.

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/pi-provider-tokscale branch from 365a2a7 to 2df0447 Compare September 2, 2026 18:48

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

Copy link
Copy Markdown

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: 2df04477d3

ℹ️ 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".

Comment thread Sources/CodexBarCore/CostUsageFetcher.swift Outdated

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

Copy link
Copy Markdown

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: 3d04206180

ℹ️ 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".

Comment on lines +234 to +237
guard workingDirectory != nil ||
PiFamilySessionScanner.hasAbsoluteSessionDirectorySelector(
in: process,
environment: environment)

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 Preserve OMP profiles when CWD lookup fails

When an OMP process uses --profile work and its CWD cannot be read, this guard drops the process context because only an absolute --session-dir is accepted. OMP profile resolution is CWD-independent when HOME is available, so the later cost scan instead auto-discovers every profile and can include usage from unrelated profiles. Retain --profile contexts without a CWD and resolve them using the existing OMP profile resolver.

Useful? React with 👍 / 👎.

Comment on lines +34 to +35
tokenCost: ProviderTokenCostConfig(
supportsTokenCost: true,

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 Classify Pi as a local spend source

When Pi is enabled in Overview, this token-cost source enters the spend dashboard as a normal native input, and SpendDashboardController.publishCurrentState assigns every such input the .subscription role; SpendDashboardPublication.subscriptionCount therefore includes Pi in the text “%d of %d subscriptions have spend.” A Claude-plus-Pi setup is consequently reported as two subscriptions even though Pi is only a local-history estimator. Add a local-source classification or exclude Pi from subscription coverage counts.

Useful? React with 👍 / 👎.

@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/pi-provider-tokscale branch from 3d04206 to c8fb54e Compare September 10, 2026 21:26

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

Copy link
Copy Markdown

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: a420f904d5

ℹ️ 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 retentionKey = fields.count >= 5 && !fields[4].isEmpty ? String(fields[4]) : nil
// A settings file is a replacement point: if it now resolves to another root, the
// prior root belonged to the superseded selector and must not be carried forward.
if let retentionKey, currentRetentionKeys.contains(retentionKey) { continue }

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 Preserve retained roots that share a settings key

When the global Pi settings file uses a relative sessionDir, each live process resolves that same file against its own CWD, producing different roots with the identical settings:<file> retention key. After those processes exit, ambient resolution contributes one current key and this check drops every cached live root sharing it without comparing paths, so a complete scan removes valid historical usage from the other projects. Fresh evidence beyond the settings-replacement fix is this many-roots-to-one-key collision; include the resolving CWD in the key for relative settings or otherwise distinguish retained roots from a genuinely superseded value.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 88fab5e422

ℹ️ 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".

Comment on lines +1073 to +1074
if safeEnvironment["OMP_PROFILE"] == nil,
safeEnvironment["PI_PROFILE"] == nil

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 Resolve selected profiles from the direct sessions layout

When PI_PROFILE selects a profile stored in the supported ~/.omp/profiles/<profile>/sessions layout, this condition disables profile discovery, while OMPSessionRootResolver.namedProfileRoots checks only <profile>/agent/sessions for non-XDG profiles. The valid store is therefore omitted and the nonexistent legacy root makes the historical scan incomplete; selected profiles should resolve both layouts just as automatic profile discovery does.

Useful? React with 👍 / 👎.

Comment on lines +1084 to +1086
for parent in profileParents {
urls.append(contentsOf: Self.profileSessionRoots(in: parent))
let resolution = Self.profileSessionRoots(in: parent)
urls.append(contentsOf: resolution.roots)

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 Discover profiles beneath the configured OMP directory

When PI_CONFIG_DIR points to a custom OMP configuration directory and no profile is explicitly selected, this discovery loop still receives only the hard-coded ~/.omp/profiles and XDG parents. Profiles beneath <HOME>/<PI_CONFIG_DIR>/profiles are never scanned, while unrelated profiles under ~/.omp can be included, so Pi cost history uses the wrong root set; derive this parent from the same configured root used by OMPSessionRootResolver.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 26c6696325

ℹ️ 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".

Comment thread Sources/CodexBar/UsageStore.swift Outdated
self.tokenFailureGates[provider.instanceID]?.recordSuccess()
self.persistWidgetSnapshot(reason: "token-usage")
cursorCookieHeaderOverride: cursorCookieHeaderOverride,
includePiSessions: true)

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 Honor Pi ownership in regular provider snapshots

When Pi and Claude or ambient Codex are both enabled, this hard-coded true ignores shouldIncludePiSessionsInTokenSnapshot and publishes Pi/OMP rows in the regular Claude/Codex snapshot; provider cards consume that snapshot directly while the Pi card separately publishes the same logs, duplicating and misattributing usage. Fresh evidence after the earlier ownership fix is that the final refresh path explicitly restored unconditional Pi inclusion; pass the ownership policy here or publish the stored native projection to provider-specific surfaces.

AGENTS.md reference: AGENTS.md:L47-L47

Useful? React with 👍 / 👎.

let role: SpendSourcePublication.Role = switch input?.sourceKind {
case .openCodex: .enrichment
case .localHistory: .localHistory
case .native, nil: .subscription

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 Classify empty Pi rows as local history

When Pi is configured but its scan is confirmed empty, loading, or unavailable, there is no ProviderInput, so input?.sourceKind is nil and this branch classifies the Pi source as a subscription. Fresh evidence after the local-history classification change is that only input-backed Pi rows receive .localHistory; the empty/unavailable Pi row still inflates subscriptionCount (for example, Claude plus empty Pi is reported as two subscriptions). Derive Pi's role from provider when the input is absent.

Useful? React with 👍 / 👎.

Comment on lines 1383 to 1385
case .readableDirectory:
roots.append(xdgLayout)
continue

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 Scan both OMP profile layouts during discovery

When an automatically discovered OMP profile contains both profiles/<name>/sessions and the legacy profiles/<name>/agent/sessions—for example during or after a layout migration—the continue after adding the direct layout prevents the legacy layout from being returned. Historical usage remaining there is omitted even though explicitly selected profiles preserve both layouts; inspect and append both existing directories during automatic discovery as well.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 43a1071537

ℹ️ 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".

output.append(SessionRoot(
url: url,
missingIsKnownEmpty: fields[1] == "known-empty",
resolutionIsComplete: false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the advertised scope aligned with the retained report

When a retained settings file becomes malformed or temporarily unreadable, this changes scopeFingerprint(options:) to an unresolved fingerprint, which refreshPiHistoryScope records as current. The subsequent scan sees the changed, incomplete scope, restores cacheBeforeScan, and returns the old resolved fingerprint; tokenAccountingScopeIsCurrent therefore rejects every retained Pi/Claude/Codex result, so the history this branch intends to preserve disappears until the settings file is repaired. Advertise the cached scope while serving the retained report, or otherwise keep these fingerprints equivalent.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 15ef441e50

ℹ️ 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".

Comment on lines +381 to +384
let xdgDataHome = Self.environmentURL(
environment["XDG_DATA_HOME"],
baseDirectory: baseDirectory,
fileManager: fileManager)

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 Restore the default XDG profile directory

On macOS and Linux, when XDG_DATA_HOME is unset, this new resolver omits the standard ~/.local/share/omp/profiles directory because environmentURL(nil, ...) returns nil. The previous discovery path used the still-present xdgDataHome helper, which falls back to ~/.local/share; consequently, automatic Pi cost scans and source detection now miss OMP sessions stored in default-XDG profiles and can publish an established but undercounted snapshot.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 13b7c5322e

ℹ️ 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".

for root in roots {
let canonical = Self.canonicalURL(root.url)
guard seenDialectRoots.insert(canonical.path).inserted else { continue }
guard seen.insert(canonical.path).inserted else { continue }

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 Merge root strictness when dialects share a path

When an OMP process explicitly selects the Pi default path (for example, omp --session-dir /Users/me/.pi/agent/sessions), the Pi dialect adds that path first as an optional known-empty default, and this global deduplication then discards OMP's required/live version of the same root. If the directory later disappears or is temporarily unmounted, the scan is considered complete and cached usage is deleted instead of retained as unavailable. Deduplicate by merging provenance so any explicit occurrence makes the shared root required.

Useful? React with 👍 / 👎.

Comment on lines +21 to +22
let subscriptionProviders = includedProviders.filter { $0.sourceKind != .localHistory }
let providerCount = max(max(0, providerCount), subscriptionProviders.count)

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 Exclude Pi from fallback subscription totals

When the spend publication is not initialized or its ownership fingerprint is stale, overviewSpendSubscriptionCount falls back to the raw enabled-provider count, so a Claude-plus-Pi setup supplies 2 here. Filtering the loaded rows cannot reduce that value because this max preserves it, and Overview temporarily reports “1 of 2 subscriptions” even though Pi is a local-history source. The fallback count also needs to exclude Pi rather than relying solely on publication roles.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 11, 2026

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

Copy link
Copy Markdown

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: eca903f281

ℹ️ 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".

var seenDialectRoots = Set<String>()
for root in roots {
let canonical = Self.canonicalURL(root.url)
guard seenDialectRoots.insert(canonical.path).inserted else { continue }

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 Merge duplicate roots within each dialect

When two same-dialect Pi processes resolve to the same path, this guard discards the later root before appendCostRoot can merge its provenance. Fresh evidence beyond the earlier shared Pi/OMP-root fix is that same-dialect duplicates still bypass that merger: for example, a plain pi process ordered before pi --session-dir ~/.pi/agent/sessions loses the required/live flags, while two project settings pointing to one shared root retain only the first settings key. A later missing root or removal of the first selector can therefore erase valid cached history despite the other explicit selector; pass duplicates through the provenance merge instead of dropping them here.

Useful? React with 👍 / 👎.

Comment on lines +89 to +91
let piRoots = PiFamilySessionRootResolver.costSessionRootURLs(
environment: piEnvironment,
baseDirectory: piBaseDirectory)

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 Include live project roots in Pi source detection

On a Pi-only installation whose sessions are selected solely by a live process's project .pi/settings.json or command-line --session-dir, this resolves roots using only CodexBar's own working directory and supplies no process contexts. Fresh evidence beyond the earlier auto-detection fix is that the actual cost path uses LocalAgentSessionScanner.piSessionProcessContexts, but this startup detector cannot reach those same roots; with empty default stores it returns false, so applyTokenCostDefaultIfNeeded leaves token-cost usage disabled and the new provider shows no history until the user enables it manually.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 911d5d218f

ℹ️ 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".

Comment on lines +979 to +983
let resolution = Self.ompSessionRootResolution(
process: defaultProcess,
cwd: cwdURL.path,
environment: environment)
roots.append(contentsOf: resolution.roots)

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 Suppress profile discovery when a live profile is selected

When a live OMP process uses --profile work but CodexBar's own environment has no profile selector, the process-context pass resolves work, then this unconditional default-process pass resolves each CWD without that flag; ompSessionRootResolution consequently auto-discovers every stored profile and includes unrelated profile usage in Pi totals. Fresh evidence beyond the prior missing-CWD finding is that this also happens when CWD lookup succeeds. Skip ambient OMP profile discovery when explicit process profiles are present, while still combining profiles selected by multiple live contexts.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 47a2bdd592

ℹ️ 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".

Comment on lines +309 to +311
let directRoot = canonicalProfileRoot.appendingPathComponent("sessions", isDirectory: true)
if Self.isDirectory(directRoot, fileManager: fileManager) {
roots.append(directRoot)

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 Preserve direct layout for live OMP profile scans

When a live OMP process selects a profile stored as profiles/<name>/sessions/*.jsonl, this adds the direct directory as an untyped URL; ompSessionRootResolution later wraps every returned URL with .projectDirectories, so records inspects only child directories instead of the JSONL files directly in this root. The cost scanner still finds these files recursively, but live-session discovery falls back to pid:<pid> and loses the transcript, session ID, title, and activity metadata. Fresh evidence after the earlier direct-profile resolution fix is that the root is now found while its layout is discarded; carry .direct through the resolver.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: 3239a16afb

ℹ️ 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".

Comment on lines +130 to +135
if Self.isDirectory(xdgSessions, fileManager: fileManager),
let root = Self.sessionRoot(
agentRoot: xdgDataHome.appendingPathComponent("omp", isDirectory: true),
fileManager: fileManager)
{
return [root]

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 Keep both default OMP stores during XDG migration

When ~/.local/share/omp/sessions exists—now detected even when XDG_DATA_HOME is unset—this early return discards the already resolved ~/.omp/agent/sessions root (or the root selected through PI_CONFIG_DIR). Users retaining sessions in both layouts during a migration consequently lose all legacy rows from Pi token and cost totals, and source detection can undercount them; return and deduplicate both roots as the named-profile resolver does.

Useful? React with 👍 / 👎.

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

Copy link
Copy Markdown

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: fbdfd558ba

ℹ️ 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".

Comment on lines +218 to +222
let processes = Array(AgentSessionCorrelation.newestProcessesFirst(
// Provider-specific by design: only Pi processes provide project roots for Pi history resolution.
AgentPSOutputParser.agentProcesses(from: allProcesses)
.filter { AgentPSOutputParser.provider(for: $0) == .pi })
.prefix(max(0, self.config.maxProcessCount)))

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 Preserve all distinct roots before applying the process cap

When more than maxProcessCount Pi/OMP processes are running, this truncates the process list before contexts are deduplicated or their distinct roots are resolved. For example, 64 newer processes using the default store can crowd out an older process with a unique --session-dir; because these contexts are the only way an app or CLI running outside that project discovers the custom store, the cost scan publishes a complete-looking snapshot that omits its history. Deduplicate root-relevant contexts before imposing a limit, or propagate that truncation as an incomplete scan.

Useful? React with 👍 / 👎.

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

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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