Skip to content

Simplify the frontend: dead code, shared test helpers and godfile splits - #798

Open
Finesssee wants to merge 25 commits into
mainfrom
simplify/frontend
Open

Finesssee wants to merge 25 commits into
mainfrom
simplify/frontend

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR simplifies the frontend (lane D of the simplification program) and should not change behavior. It lands audit levers FE-01 to FE-11 and FE-13, and splits six godfiles so each piece is under 800 lines. Persisted formats, DTO shapes, settings tab ids and user-facing strings do not change.

Lever Change
FE-02, FE-06, FE-13 Tests share a SettingsSnapshot fixture, rate-window and usage-snapshot builders, and locale/event vi.mock factories
FE-11 Deletes unused exports, one per commit: chart geometry helpers, mergeValidCurrencyRates, FALLBACK_CURRENCY_RATES, MenuSummary, providerDisplayDetailTitle, paceCategoryKey
FE-07 Deletes 5 unused invoke wrappers in lib/tauri.ts
FE-08 Provider icons load through import.meta.glob, and registry ids are derived from the icon table
FE-05 Deletes 217 unused locale keys from keys.ts, rust/src/locale.rs and all 10 .ftl files
FE-04 Adds SettingToggle and SettingSelect rows (32 toggles, 12 selects)
FE-09 Adds a shared Codex account store hook (useCodexAccountsState)
FE-10 Adds a useTauriEvent hook for plain event subscriptions
FE-01 Deletes 146 dead CSS rules (950 lines)
FE-03 Deletes 214 shadowed declarations, merges the duplicate * rule, and deletes 51 base declarations that tray-qualified rules always override

Godfile splits:

File Split
styles.css Became an @import list of 9 per-surface stylesheets under src/styles/, in the original cascade order (largest 772 lines). test/styles.ts inlines the imports.
i18n/keys.ts Split into i18n/keyGroups/{core,shell,providerText}.ts, spread into ALL_LOCALE_KEYS in the original key order
types/bridge.ts Now a type-only barrel over types/bridge/{settings,usage,providers,codexAccounts}.ts, with DTO text unchanged. One commit first drops the second, identical ProviderSummary declaration.
TrayPanel.test.tsx, MenuCard.test.tsx, FloatBar.test.tsx Each split by topic into two files, with shared mocks and harness modules in src/test/

check-locale script change. scripts/check-locale-drift.mjs now resolves the ...TOPIC_KEYS spreads in ALL_LOCALE_KEYS: it follows each spread's import in keys.ts and reads the array from that topic file. It still exits 1 on drift. I proved this by adding a fake key FakeDriftProbeKey to keyGroups/providerText.ts, which failed with DRIFT DETECTED rust=1199 ts=1200, and then reverting it.

LOC (loc.py, HEAD vs origin/main 3226d2f)

Raw prod Raw test SLOC prod SLOC test
origin/main 200063 121427 167935 108189
HEAD 198590 120147 166627 106955
Delta -1473 -1280 -1308 -1234

loc.py counts src/test/* as prod. The six new harness and mocks modules hold test code that moved out of the three split test files, and they add 676 raw lines to that bucket. With them counted as test, the raw delta is -2149 prod and -604 test.

Test inventory

  • Vitest: 748 cases before, 744 after. The 4 removed cases tested deleted code with no production caller: MenuSummary ×2, providerDisplayDetailTitle ×1 and paceCategory ×1. Before the split, after the split and in the final tree, the case names match exactly, ignoring file paths.
  • Cargo: no test removed. The cargo test -- --list output contains every name in the before list.

Commands

Command Result
pnpm exec tsc --noEmit -p . pass
pnpm exec vitest run 105 files, 744 passed
pnpm run lint (oxlint) exit 0; no new warnings (only existing ones in files this PR doesn't change)
pnpm run build pass. Built CSS was byte-identical before and after the styles.css split.
pnpm run check-locale OK, 1199 keys
cargo fmt --all no changes
cargo clippy --workspace --all-targets -- -D warnings pass
cargo test -p codexbar 3750 passed, 1 ignored
cargo test -p codexbar-desktop-tauri 639 passed
scripts/local-check.ps1 -Slice ci not run: the workstation's no-permanent-delete hook blocks it. Its steps above ran one at a time. Not covered: the CircleCI helper tests, release-doctor, the worktree-storage audit and the executable verifier.

Behavior-risk notes

  • CSS deletions (FE-01, FE-03): these rely on parse-time analysis, so I checked them against computed styles in the running app (see Proof).
  • FE-10: useTauriEvent drops events that arrive after cleanup while listen is still resolving. Before, the settings-changed handler could still run in that window.
  • FE-09: the hook's listen effect now runs before the menu's onLayoutChange effect.
  • ProviderSummary: the deleted declaration was identical to the one kept, so the type is unchanged.
  • Codex accounts section: reload loading and action acting are now separate flags. Before, a codex-accounts-updated reload that finished mid-action re-enabled the buttons, so a second action could start concurrently. Now the buttons stay disabled until both finish.

Proof

Debug desktop builds of origin/main 3226d2f and this branch 14ade1c, captured with the proof kit; windows ran on the secondary monitor. The logs are under W:\pstack-logs\Win-CodexBar\simplify\laneD\. Run directories are under %LOCALAPPDATA%\Win-CodexBar\port-audit\proof-kit\runs\.

  • Computed-style dump (styledump.py): every element's computed style and the DOM in 200 states (tray panel, every Settings tab, every provider detail pane and the float bar, in dark and light).
    • Element counts match in all 200 states.
    • Before vs before: 6 differences, all in one provider-detail title width.
    • Before vs after: 24 differences (style-diff-after.txt). All are explained in tray-inline-proof.txt:
      • Tray states: the leftover inline styles from overlapping tray auto-fit runs, which is an existing race on main. It appeared in 4 of 4 launches of both builds.
      • With the same inline styles applied, the 8 tray states show 0 differences.
      • provider-11: a seeded credentials path holds the run directory name, which wraps differently.
  • Whole-app suite (suite.py + report.py, with the CUA driver daemon running):
    • Before: runs\suite-20261010-145829\report.html, 445 ok, 0 FAIL, 14 info.
    • After: runs\suite-20261010-151131\report.html, 445 ok, 0 FAIL, 14 info. The sorted list of result names (values removed) matches the before run exactly. Logs: laneD\suite-before2.log and laneD\suite-after2.log.

Follow-ups (not in this PR)

  • useTrayPanelLayout: overlapping auto-fit runs leave measurement inline styles on the tray panel.
  • FE-12 waits for Port the Groq console usage path #793.
  • FE-09 does not share a Claude accounts hook, because the menu and settings section load differently. It also does not add a shared AccountRow, because the row markup differs.
  • FE-03 left 42 duplicate-selector groups unmerged, because a rule of equal specificity sits between the copies.
  • Lane C: the Rust commands get_spend_contract, get_codex_workspaces_snapshot, codex_accounts_list and codex_account_snapshots no longer have a frontend caller, and the get_provider_catalog command registration is orphaned too (Rust still calls the function internally).
  • Atlas Cloud "Available balance" has shown in English in every locale since Integrate the 0.60.4–0.70.0 port as v0.70.0 (release/v0.70.0) #735 rewired callers to localizeProviderLabel. This PR deletes the dead providerDisplayDetailTitle helper and its AtlasCloudAvailableBalance key, so a later fix adds a mapping to localizeProviderLabel plus the key again.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b17e12f7-682a-42bd-b32c-ea79c90f2060

📥 Commits

Reviewing files that changed from the base of the PR and between 522699d and 14ade1c.


📒 Files selected for processing (100)
  • apps/desktop-tauri/scripts/check-locale-drift.mjs
  • apps/desktop-tauri/src/App.test.tsx
  • apps/desktop-tauri/src/components/AgentSessions.test.tsx
  • apps/desktop-tauri/src/components/ClaudeAccountUsage.test.tsx
  • apps/desktop-tauri/src/components/ClaudeAccountsMenu.test.tsx
  • apps/desktop-tauri/src/components/CodexAccountsMenu.tsx
  • apps/desktop-tauri/src/components/FormControls.tsx
  • apps/desktop-tauri/src/components/GrokAccountsMenu.test.tsx
  • apps/desktop-tauri/src/components/MenuCard.chartRefresh.test.tsx
  • apps/desktop-tauri/src/components/MenuCard.paceAndCost.test.tsx
  • apps/desktop-tauri/src/components/MenuCard.test.tsx
  • apps/desktop-tauri/src/components/MenuSurface.test.tsx
  • apps/desktop-tauri/src/components/MenuSurface.tsx
  • apps/desktop-tauri/src/components/ProviderGrid.test.tsx
  • apps/desktop-tauri/src/components/ShortcutCapture.test.tsx
  • apps/desktop-tauri/src/components/charts/chartGeometry.ts
  • apps/desktop-tauri/src/components/providerGridUtils.test.ts
  • apps/desktop-tauri/src/components/providers/providerIcons.ts
  • apps/desktop-tauri/src/floatbar/FloatBar.display.test.tsx
  • apps/desktop-tauri/src/floatbar/FloatBar.test.tsx
  • apps/desktop-tauri/src/floatbar/FloatBar.tsx
  • apps/desktop-tauri/src/floatbar/SettingsSection.test.tsx
  • apps/desktop-tauri/src/floatbar/SettingsSection.tsx
  • apps/desktop-tauri/src/hooks/useClaudeReconciliation.ts
  • apps/desktop-tauri/src/hooks/useCodexAccountsState.ts
  • apps/desktop-tauri/src/hooks/useFormattedResetTime.test.tsx
  • apps/desktop-tauri/src/hooks/useLocale.test.tsx
  • apps/desktop-tauri/src/hooks/useProviders.test.tsx
  • apps/desktop-tauri/src/hooks/useSettings.ts
  • apps/desktop-tauri/src/hooks/useTauriEvent.ts
  • apps/desktop-tauri/src/hooks/useUpdateState.ts
  • apps/desktop-tauri/src/i18n/LocaleProvider.tsx
  • apps/desktop-tauri/src/i18n/keyGroups/core.ts
  • apps/desktop-tauri/src/i18n/keyGroups/providerText.ts
  • apps/desktop-tauri/src/i18n/keyGroups/shell.ts
  • apps/desktop-tauri/src/i18n/keys.ts
  • apps/desktop-tauri/src/lib/currency.ts
  • apps/desktop-tauri/src/lib/providerLabels.test.ts
  • apps/desktop-tauri/src/lib/providerLabels.ts
  • apps/desktop-tauri/src/lib/providerOrder.test.ts
  • apps/desktop-tauri/src/lib/tauri.ts
  • apps/desktop-tauri/src/lib/usageWindows.test.ts
  • apps/desktop-tauri/src/styles.css
  • apps/desktop-tauri/src/styles/menu-card.css
  • apps/desktop-tauri/src/styles/menu-popover.css
  • apps/desktop-tauri/src/styles/parity-menu.css
  • apps/desktop-tauri/src/styles/parity-overrides.css
  • apps/desktop-tauri/src/styles/parity-settings.css
  • apps/desktop-tauri/src/styles/provider-details.css
  • apps/desktop-tauri/src/styles/providers-tab.css
  • apps/desktop-tauri/src/styles/tokens-and-forms.css
  • apps/desktop-tauri/src/styles/tray-panel.css
  • apps/desktop-tauri/src/surfaces/TrayPanel.period.test.tsx
  • apps/desktop-tauri/src/surfaces/TrayPanel.test.tsx
  • apps/desktop-tauri/src/surfaces/TrayPanel.window.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/SwitcherShortcutsSection.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/credentials/CodexAccountsSection.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/credentials/GrokAccountsSection.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/AboutTab.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/AboutTab.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/AdvancedTab.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/AdvancedTab.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/DisplayTab.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/DisplayTab.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/GeneralTab.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/PreferencesTransferSection.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/ProvidersTab.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/tabs/UsageSpendTab.test.tsx
  • apps/desktop-tauri/src/surfaces/tray/paceCategory.test.ts
  • apps/desktop-tauri/src/surfaces/tray/paceCategory.ts
  • apps/desktop-tauri/src/test/fixtures.ts
  • apps/desktop-tauri/src/test/floatBarHarness.tsx
  • apps/desktop-tauri/src/test/floatBarMocks.ts
  • apps/desktop-tauri/src/test/menuCardHarness.tsx
  • apps/desktop-tauri/src/test/menuCardMocks.ts
  • apps/desktop-tauri/src/test/mocks/event.ts
  • apps/desktop-tauri/src/test/mocks/locale.ts
  • apps/desktop-tauri/src/test/styles.ts
  • apps/desktop-tauri/src/test/trayPanelHarness.tsx
  • apps/desktop-tauri/src/test/trayPanelMocks.ts
  • apps/desktop-tauri/src/types/bridge.ts
  • apps/desktop-tauri/src/types/bridge/codexAccounts.ts
  • apps/desktop-tauri/src/types/bridge/providers.ts
  • apps/desktop-tauri/src/types/bridge/settings.ts
  • apps/desktop-tauri/src/types/bridge/usage.ts
  • rust/src/locale.rs
  • rust/src/locale/en-US.ftl
  • rust/src/locale/es-MX.ftl
  • rust/src/locale/ja-JP.ftl
  • rust/src/locale/ko-KR.ftl
  • rust/src/locale/pt-BR.ftl
  • rust/src/locale/ru-RU.ftl
  • rust/src/locale/tests.rs
  • rust/src/locale/tr-TR.ftl
  • rust/src/locale/uk-UA.ftl
  • rust/src/locale/zh-CN.ftl
  • rust/src/locale/zh-TW.ftl

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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