Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
736ee58
Share one SettingsSnapshot test fixture
Finesssee Oct 10, 2026
2524ffe
Share rate-window test builder
Finesssee Oct 10, 2026
672e8e1
Share provider usage snapshot test builder
Finesssee Oct 10, 2026
59c9434
Share locale and event vi.mock factories
Finesssee Oct 10, 2026
49fe562
Delete unused chart geometry exports
Finesssee Oct 10, 2026
650cb60
Delete unused mergeValidCurrencyRates
Finesssee Oct 10, 2026
efceeba
Delete FALLBACK_CURRENCY_RATES, unused after mergeValidCurrencyRates
Finesssee Oct 10, 2026
146d586
Delete unused MenuSummary and its test
Finesssee Oct 10, 2026
03b5064
Delete unused providerDisplayDetailTitle and its test
Finesssee Oct 10, 2026
eed954b
Delete unused paceCategoryKey and its test
Finesssee Oct 10, 2026
f8efab9
Delete five unused bridge invoke wrappers
Finesssee Oct 10, 2026
8a3f27f
Load provider icons with import.meta.glob and derive registry ids
Finesssee Oct 10, 2026
590cd43
Delete unused locale keys
Finesssee Oct 10, 2026
256d5bb
Add SettingToggle and SettingSelect rows for settings tabs
Finesssee Oct 10, 2026
0ba940d
Share Codex account store hook
Finesssee Oct 10, 2026
7bb8c70
Add useTauriEvent hook for plain event subscriptions
Finesssee Oct 10, 2026
bee303d
Delete dead CSS rules
Finesssee Oct 10, 2026
061c6f4
Delete shadowed CSS declarations
Finesssee Oct 10, 2026
64b9cb2
Merge the duplicate universal CSS rule
Finesssee Oct 10, 2026
41024f4
Delete base CSS declarations overridden by tray rules
Finesssee Oct 10, 2026
7618782
Split styles.css into per-surface stylesheets
Finesssee Oct 10, 2026
ba71725
Split locale keys into topic arrays
Finesssee Oct 10, 2026
d2033dc
Drop the duplicate ProviderSummary declaration
Finesssee Oct 10, 2026
dddff9d
Split bridge DTOs into area files behind the barrel
Finesssee Oct 10, 2026
14ade1c
Split tray panel, menu card and float bar tests by topic
Finesssee Oct 10, 2026
23fdd2f
Merge origin/main into simplify/frontend
factory-droid[bot] Oct 17, 2026
9cbfa6b
Merge remote-tracking branch 'origin/main' into simplify/frontend
factory-droid[bot] Oct 17, 2026
9694639
Use main MenuCard test mock wiring after the test split merge
factory-droid[bot] Oct 17, 2026
15eae72
Restore main locale bundle and FTL files
factory-droid[bot] Oct 17, 2026
d77e11d
Re-split main styles into the partial layout
factory-droid[bot] Oct 17, 2026
5ddab6b
Remove tests for tray and card behavior main removed
Oct 17, 2026
e61bfa1
Read the panel background from the split tray-panel stylesheet
Oct 17, 2026
5188e6b
Correct split stylesheet comments and trim settings fixtures
Oct 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions apps/desktop-tauri/scripts/check-locale-drift.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,39 @@ const tsBlockMatch = tsSrc.match(
if (!tsBlockMatch) {
die(2, "could not locate `export const ALL_LOCALE_KEYS` in keys.ts");
}
// The block holds `"Key"` literals and `...TOPIC_KEYS` spreads of arrays
// imported from i18n/keyGroups/*.ts; resolve both in order.
const tsKeys = [];
const tsKeyRe = /"(\w+)"/g;
while ((m = tsKeyRe.exec(tsBlockMatch[1])) !== null) {
tsKeys.push(m[1]);
const entryRe = /"(\w+)"|\.\.\.([A-Z_]+)/g;
while ((m = entryRe.exec(tsBlockMatch[1])) !== null) {
if (m[1]) {
tsKeys.push(m[1]);
continue;
}
const name = m[2];
const importMatch = tsSrc.match(
new RegExp(`import\\s*\\{\\s*${name}\\s*\\}\\s*from\\s*"(\\./[^"]+)"`),
);
if (!importMatch) {
die(2, `could not resolve the import of ${name} in keys.ts`);
}
let groupSrc;
try {
groupSrc = readFileSync(resolve(dirname(tsPath), `${importMatch[1]}.ts`), "utf8");
} catch (err) {
die(2, `failed to read ${importMatch[1]}.ts: ${err.message}`);
}
const groupMatch = groupSrc.match(
new RegExp(`export const ${name}\\s*=\\s*\\[([\\s\\S]*?)\\]\\s*as const;`),
);
if (!groupMatch) {
die(2, `could not locate \`export const ${name}\` in ${importMatch[1]}.ts`);
}
let k;
while ((k = tsKeyRe.exec(groupMatch[1])) !== null) {
tsKeys.push(k[1]);
}
}
if (tsKeys.length === 0) {
die(2, "parsed zero entries from ALL_LOCALE_KEYS");
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop-tauri/src-tauri/src/shell/flyout_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ mod tests {

#[test]
fn panel_fill_matches_the_css_panel_background() {
let css = include_str!("../../../src/styles.css");
let css = include_str!("../../../src/styles/tray-panel.css");
let tauri::utils::config::Color(r, g, b, a) = PANEL_FILL;
assert_eq!(a, 0xFF);
assert!(css.contains(&format!("--mac-panel-bg: #{r:02x}{g:02x}{b:02x};")));
Expand Down
8 changes: 5 additions & 3 deletions apps/desktop-tauri/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { SettingsSnapshot } from "./types/bridge";
import { render, waitFor } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";

Expand Down Expand Up @@ -59,7 +60,8 @@ vi.mock("./hooks/useSurfaceSnapshot", () => ({

import App from "./App";
import { buildBundle } from "./test/localeHarness";
import type { BootstrapState, SettingsSnapshot } from "./types/bridge";
import type { BootstrapState } from "./types/bridge";
import { makeSettings } from "./test/fixtures";

function settings(overrides: Partial<SettingsSnapshot> = {}): SettingsSnapshot {
return {
Expand Down Expand Up @@ -151,7 +153,7 @@ function bootstrap(): BootstrapState {
return {
contractVersion: "v1",
providers: [],
settings: settings(),
settings: makeSettings(),
};
}

Expand All @@ -161,7 +163,7 @@ describe("App window-label routing", () => {
webviewWindowMocks.label = "main";
surfaceMocks.snapshot = { mode: "hidden", target: { kind: "summary" } };
tauriMocks.getBootstrapState.mockResolvedValue(bootstrap());
tauriMocks.getSettingsSnapshot.mockResolvedValue(settings());
tauriMocks.getSettingsSnapshot.mockResolvedValue(makeSettings());
tauriMocks.checkForUpdates.mockResolvedValue({
status: "idle",
version: null,
Expand Down
4 changes: 1 addition & 3 deletions apps/desktop-tauri/src/components/AgentSessions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ vi.mock("../lib/tauri", () => ({
focusAgentSession: api.focusAgentSession,
}));
// t(key) returns the key, so provider labels assert against locale-key names.
vi.mock("../hooks/useLocale", () => ({
useLocale: () => ({ t: (key: string) => key, language: "english" }),
}));
vi.mock("../hooks/useLocale", () => import("../test/mocks/locale"));

import AgentSessions from "./AgentSessions";
import type { AgentSession } from "../types/bridge";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it, vi } from "vitest";
import type { ClaudeAccount } from "../types/bridge";
import ClaudeAccountUsage from "./ClaudeAccountUsage";

vi.mock("../hooks/useLocale", () => ({ useLocale: () => ({ t: (key: string) => key }) }));
vi.mock("../hooks/useLocale", () => import("../test/mocks/locale"));
const t = (key: string) => key;
const account: ClaudeAccount = {
id: "one:org", email: "one@example.test", organization: null, plan: "max", isActive: false, isSaved: true,
Expand Down
78 changes: 78 additions & 0 deletions apps/desktop-tauri/src/components/FormControls.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type React from "react";
import { createContext, useContext, useId } from "react";
import type { SettingsSnapshot, SettingsUpdate } from "../types/bridge";

// A Field's label and description ids, so the control inside it gets an
// accessible name without every call site passing `ariaLabel`.
Expand Down Expand Up @@ -161,6 +162,83 @@ export function Field({
);
}

// ── settings-bound rows ──────────────────────────────────────────────

export interface SettingsControl {
settings: SettingsSnapshot;
set: (patch: SettingsUpdate) => void;
saving: boolean;
}

type SettingKey<T> = {
[K in keyof SettingsUpdate & keyof SettingsSnapshot]-?: NonNullable<SettingsUpdate[K]> extends T
? K
: never;
}[keyof SettingsUpdate & keyof SettingsSnapshot];

/** A leading Field + Toggle that writes one boolean setting; an unset value reads as off. */
export function SettingToggle({
ctl,
field,
label,
description,
checked,
disabled,
ariaLabel,
}: {
ctl: SettingsControl;
field: SettingKey<boolean>;
label: string;
description?: string;
checked?: boolean;
disabled?: boolean;
ariaLabel?: string;
}) {
return (
<Field label={label} description={description} leading>
<Toggle
checked={checked ?? ctl.settings[field] ?? false}
ariaLabel={ariaLabel}
disabled={disabled ?? ctl.saving}
onChange={(v) => ctl.set({ [field]: v })}
/>
</Field>
);
}

/** A Field + Select that writes one string setting; an unset value selects "". */
export function SettingSelect({
ctl,
field,
label,
description,
options,
value,
disabled,
ariaLabel,
}: {
ctl: SettingsControl;
field: SettingKey<string>;
label: string;
description?: string;
options: { value: string; label: string }[];
value?: string;
disabled?: boolean;
ariaLabel?: string;
}) {
return (
<Field label={label} description={description}>
<Select
value={value ?? ctl.settings[field] ?? ""}
disabled={disabled ?? ctl.saving}
ariaLabel={ariaLabel}
options={options}
onChange={(v) => ctl.set({ [field]: v })}
/>
</Field>
);
}

// ── grouped section (macOS grouped Form look) ───────────────────────

/** A bold section title, a rounded box of rows with dividers, and an optional footer. */
Expand Down
32 changes: 5 additions & 27 deletions apps/desktop-tauri/src/components/MenuCard.chartRefresh.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,26 @@ vi.mock("../lib/tauri", async (importOriginal) => ({
...(await importOriginal<typeof import("../lib/tauri")>()),
...tauriMocks,
}));
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn().mockResolvedValue(() => {}) }));
vi.mock("@tauri-apps/api/event", () => import("../test/mocks/event"));

import { LocaleProvider } from "../i18n/LocaleProvider";
import { makeRateWindow, makeUsageSnapshot } from "../test/fixtures";
import { buildBundle } from "../test/localeHarness";
import type { ProviderUsageSnapshot } from "../types/bridge";
import MenuCard from "./MenuCard";

const window0 = {
usedPercent: 10,
remainingPercent: 90,
windowMinutes: null,
resetsAt: null,
resetDescription: null,
isExhausted: false,
reservePercent: null,
reserveDescription: null,
reserveWillLastToReset: false,
reserveEtaSeconds: null,
};
const window0 = makeRateWindow(10, { reserveWillLastToReset: false, reserveEtaSeconds: null });

function snapshot(updatedAt: string): ProviderUsageSnapshot {
return {
providerId: "claude",
return makeUsageSnapshot("claude", {
displayName: "Claude",
primary: window0,
selectedMetric: window0,
secondary: null,
modelSpecific: null,
tertiary: null,
extraRateWindows: [],
cost: null,
planName: null,
accountEmail: null,
sourceLabel: "oauth",
updatedAt,
error: null,
errorState: "unknown",
pace: null,
accountOrganization: null,
trayStatusLabel: null,
fetchDurationMs: null,
};
});
}

function card(updatedAt: string) {
Expand Down
4 changes: 1 addition & 3 deletions apps/desktop-tauri/src/components/ProviderGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import ProviderGrid from "./ProviderGrid";
import { providerPlaceholder } from "../lib/trayProviders";

vi.mock("../hooks/useLocale", () => ({
useLocale: () => ({ t: (key: string) => key, language: "english" }),
}));
vi.mock("../hooks/useLocale", () => import("../test/mocks/locale"));

const providers = [
providerPlaceholder("codex", "Codex"),
Expand Down
4 changes: 1 addition & 3 deletions apps/desktop-tauri/src/components/ShortcutCapture.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ vi.mock("../lib/tauri", () => ({
setUiLanguage: vi.fn(),
}));

vi.mock("@tauri-apps/api/event", () => ({
listen: vi.fn().mockResolvedValue(() => {}),
}));
vi.mock("@tauri-apps/api/event", () => import("../test/mocks/event"));

import { LocaleProvider } from "../i18n/LocaleProvider";
import { ShortcutCapture } from "./ShortcutCapture";
Expand Down
20 changes: 0 additions & 20 deletions apps/desktop-tauri/src/components/charts/chartGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export const WIDTH = 280;
export const DATE_EDGE_PADDING = 36;
export const BAR_GAP = 2;
export const PLOT_WIDTH = WIDTH - DATE_EDGE_PADDING * 2;
export const AXIS_MAX_X = WIDTH / 2;
const SCROLLABLE_BAR_WIDTH = 1.5;

export function shouldRenderCenterMax(count: number): boolean {
Expand All @@ -29,25 +28,6 @@ export function getBarCenter(index: number, count: number, width = WIDTH): numbe
return getBarX(index, count, width) + getBarWidth(count, width) / 2;
}

export interface BarGeometry {
barWidth: number;
showCenterMax: boolean;
x: (index: number) => number;
center: (index: number) => number;
}

export function getBarGeometry(count: number, width = WIDTH): BarGeometry {
const barWidth = getBarWidth(count, width);
const x = (index: number) => getBarX(index, count, width);

return {
barWidth,
showCenterMax: shouldRenderCenterMax(count),
x,
center: (index: number) => x(index) + barWidth / 2,
};
}

export function getLineX(index: number, count: number): number {
if (count <= 1) return DATE_EDGE_PADDING;
return DATE_EDGE_PADDING + (index / (count - 1)) * PLOT_WIDTH;
Expand Down
45 changes: 5 additions & 40 deletions apps/desktop-tauri/src/components/providerGridUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,20 @@
import { describe, expect, it } from "vitest";

import { makeRateWindow, makeUsageSnapshot } from "../test/fixtures";
import type { ProviderUsageSnapshot } from "../types/bridge";

import { prioritizeProviders, switcherWeeklyPercent } from "./providerGridUtils";

function provider(id: string): ProviderUsageSnapshot {
return {
providerId: id,
displayName: id,
primary: {
usedPercent: 0,
remainingPercent: 100,
windowMinutes: null,
resetsAt: null,
resetDescription: null,
isExhausted: false,
reservePercent: null,
reserveDescription: null,
reserveWillLastToReset: false,
reserveEtaSeconds: null,
},
selectedMetric: {
usedPercent: 0,
remainingPercent: 100,
windowMinutes: null,
resetsAt: null,
resetDescription: null,
isExhausted: false,
reservePercent: null,
reserveDescription: null,
reserveWillLastToReset: false,
reserveEtaSeconds: null,
},
return makeUsageSnapshot(id, {
primary: makeRateWindow(0, { reserveWillLastToReset: false, reserveEtaSeconds: null }),
selectedMetric: makeRateWindow(0, { reserveWillLastToReset: false, reserveEtaSeconds: null }),
primaryLabel: undefined,
secondary: null,
secondaryLabel: undefined,
modelSpecific: null,
tertiary: null,
extraRateWindows: [],
cost: null,
planName: null,
accountEmail: null,
sourceLabel: "oauth",
updatedAt: "2026-07-31T00:00:00Z",
error: null,
errorState: "ready",
pace: null,
accountOrganization: null,
trayStatusLabel: null,
fetchDurationMs: null,
};
});
}

function ids(list: ProviderUsageSnapshot[]): string[] {
Expand Down
Loading