Skip to content

Port upstream 0.67.0: add twelve preferred currencies from one shared catalog (stacked on #609) - #679

Closed
Finesssee wants to merge 8 commits into
codex/port-0.64.1-preferred-currencyfrom
port/micro-0.67.0-preferred-currencies
Closed

Finesssee wants to merge 8 commits into
codex/port-0.64.1-preferred-currencyfrom
port/micro-0.67.0-preferred-currencies

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #609 (preferred display currency). Adds twelve currencies to the preferred-display-currency catalog: NZD, SEK, NOK, DKK, PLN, BRL, MXN, ZAR, THB, IDR, VND, UAH, appended after TRY in that order with upstream fallback rates. Picker labels are now CODE (symbol) for every entry (e.g. VND (₫), TRY (₺), USD ($)), matching upstream pickerLabel.

Picker order, symbols, and offline rates now come from one catalog: CURRENCIES in rust/src/currency.rs. The frontend imports a generated module (apps/desktop-tauri/src/lib/currencyCatalog.generated.ts) instead of the two hand-maintained lists #609 added. A Rust test regenerates the module text and fails if the checked-in file differs (UPDATE_CURRENCY_CATALOG=1 cargo test -p codexbar currency_catalog rewrites it), so the two sides cannot drift.

Live rate refresh already filters to supported codes (parse_exchange_rates, clean_rates), so live rates for the new codes follow from the catalog with no other change.

Display formatting: formatDisplayCurrency no longer forces maximumFractionDigits: 2; Intl.NumberFormat now uses each currency's own minor units. This keeps zero-decimal currencies (VND, JPY, KRW) from showing fractional units. Note that ICU treats IDR as a 2-decimal currency, so IDR keeps two decimals.

Upstream reference

  • Release: CodexBar 0.67.0, preferred currency catalog extension.
  • Tag-pinned (v0.67.0): Sources/CodexBarCore/CurrencyExchange.swift (currencies table, pickerLabel); PreferencesGeneralPane.swift (PreferredCurrencyOption); tests UsageFormatterTests.swift, SettingsStoreCoverageTests.swift.
  • Rates in the table are copied verbatim from the tagged currencies table (open.er-api.com, 2026-09-24).

Ported / Deferred

Ported: catalog extension, CODE (symbol) labels, single source of truth, USD-pivot conversion for each new code, normalize_preferred_currency acceptance, picker order, zero-decimal formatting.

Deferred: nothing from the spec. The upstream Swift requiresLiveRates / UserDefaults caching has no local delta (already covered by #609's currency-rates.json cache).

Validation

All cargo commands on +1.98.0, E-core wrapper, slot-2.

  • cargo +1.98.0 fmt --all: clean
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: pass
  • cargo +1.98.0 test -p codexbar currency: 15 passed (includes new order/rate/pivot/normalize/live-parse tests and the generated-catalog sync test)
  • cargo +1.98.0 test -p codexbar (full): 2143 passed, 0 failed, 1 ignored
  • cargo +1.98.0 test -p codexbar-desktop-tauri currency: 3 passed
  • vitest run (full): 68 files, 413 tests passed (includes lib/currency.test.ts, GeneralTab.test.tsx picker order and labels)
  • pnpm run lint: no findings in touched files (existing warnings elsewhere unchanged)
  • pnpm run build: pass

Affected areas

  • Settings UI (preferred currency picker options and labels)
  • Config file / settings persistence (accepted preferredCurrencyCode values)
  • Provider-specific behavior (cost display conversion only)
  • Tray panel
  • CLI
  • Installer / release packaging
  • Startup / background behavior
  • Documentation

UI proof

Pending: coordinator will capture CUA proof on a fresh build (Settings > General preferred currency picker showing the new options, one selection such as VND applied to a cost amount).

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear review

Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude

  • Low, rust/src/currency.rs:62: unused public picker_label helper, and render_typescript_catalog public only for its sync test. Fix: remove the helper, make the renderer test-only.
  • Low, rust/src/currency.rs:73: the TypeScript catalog generator interpolated strings without escaping. Fix: serialize code and symbol with serde_json.
  • Low, currencyCatalog.generated.ts:2: regeneration hint used POSIX env syntax that fails in PowerShell. Fix: PowerShell form in the header and the sync-test hint.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear review follow-up

All 3 findings fixed (commit "Address thermo review"); none left open. No user-visible change (Rust cleanup plus a comment header).

Commands run: cargo +1.98.0 fmt --all --check, cargo +1.98.0 clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings, cargo +1.98.0 test --manifest-path rust/Cargo.toml --lib currency (15 passed, including the catalog sync test). Tauri crate and frontend logic untouched, so not rerun.

@Finesssee

Finesssee commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

CUA proof

Build commit: fc9a0c1 (PR head). Debug build via pnpm --dir apps/desktop-tauri run tauri:build:debug, driven with cua-driver (background UIA only, window on a secondary monitor).

Proof-only patches (never committed, restored after the build): root Cargo.toml [patch.crates-io] dirs = <local proof shim> so the profile lives under an isolated CODEXBAR_PROOF_HOME, plus the matching Cargo.lock entry. No source changes; picker and settings only, so no mock server.

Commands: CODEXBAR_PROOF_MODE=settings:general bash launch.sh (isolated home, empty provider homes, seeded Codex snapshot), then cua-driver call get_window_state / click by element token.

# Assertion Result
0 No real email/account from the host machine visible PASS
1 Theme stays dark under Auto (system) PASS
2 Preferred currency list is AUTO then 28 options as CODE (symbol) in catalog order, ending TRY (₺), NZD ($), SEK (kr), NOK (kr), DKK (kr), PLN (zł), BRL (R$), MXN ($), ZAR (R), THB (฿), IDR (Rp), VND (₫), UAH (₴) (read from the UIA list items) PASS
3 Selecting VND (₫) updates the picker, and after a full relaunch the picker still shows VND (₫) PASS

Screenshots (local, not committed), in %LOCALAPPDATA%\Win-CodexBar\port-audit\proof\679\shots\: 01-general.png (AUTO, dark), 03-vnd-selected.png, 04-relaunch-persisted.png. The open dropdown list is a native popup outside the window capture, so assertion 2 is from the UIA tree rather than a screenshot (02-picker-open.png shows the focused picker).

Not covered: converted cost rendering with live rates (unit tests cover conversion and zero-decimal formatting).

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Lane validation + #609 rebase 2026-10-02 (worktree W:/wcb-wt/lane-b, head fbec727):

Merged current #609 head (1c24b7b, the thermo rework: Rust-owned currency model, single sanitizer, cache-backed tray conversion, typed PreferredCurrency, single settings subscription) into this branch as eedd635, then reconciled with the catalog work:

  • rust/src/currency.rs: PreferredCurrency::parse and sanitize_rates now derive supported codes from the single CURRENCIES catalog (28 entries: original 16 + the twelve 0.67.0 additions NZD, SEK, NOK, DKK, PLN, BRL, MXN, ZAR, THB, IDR, VND, UAH with upstream fallback rates and symbols appended after TRY), so the catalog is the one source of truth feeding picker order/labels, offline rates, sanitizing, and conversion.
  • Desktop command: get_currency_rates serves supportedCodes from CURRENCIES (server-generated list the 609-shape frontend expects) while the frontend picker reads CURRENCY_PICKER_OPTIONS from currencyCatalog.generated.ts (generated from the Rust table, checked by the catalog sync test). Both paths agree with zero hand-maintained lists.
  • Tray path keeps the 609 cache-backed conversion (no disk read per render).
  • Frontend conversion tests extended to the added codes: per-code USD-pivot conversion via Intl-expected strings, zero-decimal formatting (VND/JPY), and a three-currency sum through the pivot.

Validation: cargo fmt --check clean; clippy -D warnings clean for all changed files (the 3 pre-existing main drift sites outside the diff as recorded in QUEUE.md); cargo test codexbar 2145/0 fail (1 ignored, includes the new added_currencies_* and catalog-sync tests); desktop tests 466/1 fail = known #684 bootstrap host-settings baseline; pnpm check-locale 881 OK; vitest 413/413 (68 files); pnpm build clean.

Branch pushed as fast-forward fc9a0c1..fbec727. UI status: the picker options change is UI-affecting; a browser-use proof of the Settings > General picker is queued after the #739 proof (one proof at a time under the lock).

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Follow-up: b0f0060 stops tracking the two local proof-shim backup files (Cargo.lock.bak-proof / Cargo.toml.bak-proof) that commit 4a43934 accidentally swept in. Untracked only — the working files remain local. Branch tip is now b0f0060; no code changes.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Proof plan: PR #679 twelve preferred currencies (upstream 0.67.0 item 15)

Build commit: b0f0060 (port/micro-0.67.0-preferred-currencies; includes the bak-proof cleanup). Exe reused from the #739 kit bin (rebuilt at this head; pnpm run tauri:build:debug, target W:\cargo-target\lane-b). Proof-only patch: dirs shim via [patch.crates-io] — never committed.

Environment

  • CODEXBAR_PROOF_HOME isolated; settings seeded with preferred_currency_code=SEK (non-default); CDP 9352; browser-use over CDP only (no OS input, no focus); proof-window-guard running.

Assertions (browser-use, all PASS at capture)

A0 Privacy: page scan — no emails/personal tokens.
A1 Picker catalog: 29 options total (AUTO + 28 codes). The 12 added codes all present, in upstream order after TRY: NZD, SEK, NOK, DKK, PLN, BRL, MXN, ZAR, THB, IDR, VND, UAH. Labels are CODE (symbol): "NZD ($)", "SEK (kr)", "NOK (kr)", "DKK (kr)".
A2 Selection round-trip: seeded SEK rendered selected on load; switching to NOK via the React value setter updates the select and the change event fires.
A3 Bridge source of truth: get_settings_snapshot reports preferred=NOK after the switch; get_currency_rates returns merged rates containing SEK and NOK for 28 supported codes (SEK 10.044997, NOK 9.630461 — live-refreshed rates, offline fallback available). Switching back to AUTO through the picker clears the preference in the bridge.
A4 Theme: body rgb(28,28,30) / colorScheme dark — dark under auto.
Screenshots: shots/ (a3-nok-bridge.png plus 01–04 from the earlier pass at this head).

Finesssee added a commit that referenced this pull request Oct 2, 2026
…from one shared catalog (stacked on #609; resolves presentation conflicts toward the release layout — currency display wiring tracked as an integration finding)
Finesssee added a commit that referenced this pull request Oct 2, 2026
@Finesssee Finesssee closed this in 78f6cba Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant