Port upstream CodexBar 0.52.0-0.53.0 - #346
Conversation
|
Thermo-nuclear review: BLOCKING on 4 items.
Additional notes (non-blocking):
|
|
Thermo-nuclear review addressed in 1e1f6d6.\n\nBlocking items:\n1. Stacked churn: PR #345 is closed; #346 is retargeted to main, so 0.52+0.53 now land as one coherent SpendContract architecture.\n2. 1k-line cost_pricing.rs: extracted Claude routed/models.dev pricing into rust/src/core/claude_routed_pricing.rs. cost_pricing.rs is now 961 lines.\n3. Generic UsageSourceSection: renamed to GrokUsageSourceSection and updated the only consumer, making the Grok-specific contract explicit.\n4. Duplicate CustomRates formulas: cost() now delegates to cost_parts(); one pricing formula remains.\n\nNon-blocking notes also addressed:\n- replaced tuple-heavy native/imported spend destructuring with NativeSpendData + ResolvedSpendData helpers.\n- ModelAccumulator now uses Option/Option for known-vs-unknown total/cost instead of saw_total/saw_cost booleans.\n\nValidation:\n- cargo check --manifest-path rust/Cargo.toml: PASS\n- cargo check -p codexbar-desktop-tauri: PASS\n- cargo test --manifest-path rust/Cargo.toml spend_contract: 4/4 PASS\n- claude_bare_models_route_to_first_party_vendors: PASS\n- claude_explicit_unknown_vendor_fails_closed: PASS\n- TypeScript tsc --noEmit: PASS\n- Vitest: 43 files / 266 tests PASS\n- git diff --check: PASS |
1e1f6d6 to
581d943
Compare
Port of upstream steipete/CodexBar v0.53.0 (stacked on #345; read-only consumption of tagged sources, zero upstream contact per docs/PORTING.md).
Ported
spend_contract.rs:SpendContractwithCostProvenance(ListPriceEstimate/VendorMetered/Mixed/Unknown),CostCoverageCounts(priced/estimated/unpriced/unmetered),price_coverage_ratio. Partial totals show coverage, nothing unpriced masquerades as a bill.SpendTokenMix(input/output/cache_read/cache_creation/reasoning),SpendActivityCell(weekday/hour/conversations),ActivityHeatmapinUsageSpendTab.tsx.MetricCardrenders spend, coverage, conversations, token mix.CustomPricingloadscustom-pricing.jsonfrom config dir.CustomRateswith input/output/cache_read/cache_write per-million-token rates. Custom rates are authoritative over models.dev/built-in. Missing fields stay unknown, explicit zero is known-free.spend_contract/opencodex.rs: readsusage.jsonl, deduplicates byrequest_id, aggregates intoImportedSpendSourcewith models, daily, hourly activity, coverage. SQLite cache in CodexBar cache dir. Toggle in UsageSpendTab.UsageSourceSection.tsx: Auto / Grok CLI / SuperGrok OAuth / Browser cookies.set_provider_usage_sourceTauri command.SourceMode::parsevalidates againstavailable_sources().cli/toon.rs: TOON v4.1 JSON payload emission.cli/usage.rs:--formatflag acceptingtext/json/toon.cli/cost.rs: JSON output aligned with spend provenance, token mix, coverage, opt-in OpenCodex.LowPowerModePreferenceenum (Off/On/Automatic).auto_refresh.rs:system_battery_saver_enabled()reads Windows Battery Saver viaSystemStatusFlag.GeneralTab.tsx: Select dropdown replacing Toggle. Legacylow_power_modeboolean kept for settings.json migration (backed by tests).SpendContractOverviewwith provenance/coverage/conversations/token-mix metric cards.ContractModelsPanelreplacingModelsPanel.ProjectsPanelusingcontract.projects/contract.conversations. OpenCodex import + hide-native-Codex checkboxes.OverviewSpendSummarycomponent showing 30-day total spend across all providers in the tray panel header.spend_contract.rsuses chronoLocal/Utcfor consistent day bucketing.known_zero+history_coverage_establishedfields. Empty scans with established coverage reportknown_zero: true, unknown scans reportknown_cost_usd: None.Skipped (no Windows counterpart — macOS-only)
secure_file— different credential store, no interactive access gate.Deferred (evidence)
grok_api_v2.GrokBuildBilling/GetGrokCreditsConfigwith protobuf wire scanner. Win-CodexBar uses REST endpoint with JSON parsing. Behavior matches but implementation differs.available_sources()likeCookieSourceSectiondoes — noted as thermo-nuclear blocker.Verification
cargo fmt --all— cleancargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings— cleancargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings— cleancargo test --manifest-path rust/Cargo.toml --lib— passedcargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml— passedpnpm --dir apps/desktop-tauri test— passedpnpm --dir apps/desktop-tauri run build— passedscripts/local-check.ps1— not run: known StrictMode bug (Set-StrictMode -Version Latest+$ErrorActionPreference = "Stop"causes terminating errors on undefined variable references). Documented as gate limitation.tauri:build:debugcapture on the 0.53 branch. Surfaces: UsageSpendTab (SpendContract, heatmap, models, projects, OpenCodex toggle), TrayPanel (OverviewSpend), GeneralTab (low-power selector), Grok provider detail (UsageSourceSection).git diff --check— clean (no whitespace errors)Thermo-nuclear review
A thermo-nuclear code-quality review was performed. 4 blocking findings:
cost_pricing.rscrosses 1k lines — extract Claude routed pricingUsageSourceSectionhardcodes Grok options in generic-named componentCustomRates::cost()/cost_parts()formula duplicationPlus 2 non-blocking notes (tuple destructuring in
build_local_spend_contract_from_summary,ModelAccumulatorsaw_* bools vs Option).See review comment: #346 (comment)