diff --git a/apps/desktop-tauri/src-tauri/src/commands/provider_detail.rs b/apps/desktop-tauri/src-tauri/src/commands/provider_detail.rs index 418bd5c146..c2e8bcefd9 100644 --- a/apps/desktop-tauri/src-tauri/src/commands/provider_detail.rs +++ b/apps/desktop-tauri/src-tauri/src/commands/provider_detail.rs @@ -23,6 +23,12 @@ pub struct ProviderDetail { // Usage windows — reuse existing RateWindowSnapshot shape. pub session: Option, pub weekly: Option, + /// Provider-declared label for the session (primary) lane; None when the + /// provider uses the generic "Session" wording. + pub primary_label: Option, + /// Provider-declared label for the weekly (secondary) lane; None when the + /// provider uses the generic "Weekly" wording. + pub secondary_label: Option, pub model_specific: Option, pub tertiary: Option, /// Locale key naming the tertiary lane when it carries a semantic label @@ -97,6 +103,8 @@ pub(crate) fn build_provider_detail( last_updated: None, session: None, weekly: None, + primary_label: None, + secondary_label: None, model_specific: None, tertiary: None, tertiary_label_key: metadata.tertiary_label_key, @@ -165,7 +173,8 @@ pub fn get_provider_detail( super::usage_item_descriptors(Some(&snapshot), &settings, parsed_provider_id); detail.session = Some(snapshot.primary.clone()); detail.weekly = snapshot.secondary.clone(); - detail.model_specific = snapshot.model_specific.clone(); + detail.primary_label = snapshot.primary_label.clone(); + detail.secondary_label = snapshot.secondary_label.clone(); detail.tertiary = snapshot.tertiary.clone(); detail.extra_rate_windows = snapshot.extra_rate_windows.clone(); detail.inventory = snapshot.inventory.clone(); diff --git a/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.test.tsx b/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.test.tsx index 46f0e21cd2..da55e30256 100644 --- a/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.test.tsx +++ b/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.test.tsx @@ -123,4 +123,47 @@ describe("MenuBarMetricSection", () => { providerMetrics: { copilot: "extraUsage" }, }); }); + + it("offers the provider-declared lane labels in the metric picker", () => { + const base = provider(false); + base.id = "litellm"; + base.displayName = "LiteLLM"; + base.weekly = rateWindow(30); + base.primaryLabel = "Personal budget"; + base.secondaryLabel = "Team budget"; + + render( + key} + onChange={vi.fn()} + />, + ); + + expect(screen.getByRole("option", { name: "Personal budget" })).toBeInTheDocument(); + expect(screen.getByRole("option", { name: "Team budget" })).toBeInTheDocument(); + expect(screen.queryByRole("option", { name: "ProviderSessionLabel" })).not.toBeInTheDocument(); + expect(screen.queryByRole("option", { name: "ProviderWeeklyLabel" })).not.toBeInTheDocument(); + }); + + it("keeps the generic metric labels when the provider declares none", () => { + const base = provider(false); + base.weekly = rateWindow(30); + + render( + key} + onChange={vi.fn()} + />, + ); + + expect(screen.getByRole("option", { name: "Automatic" })).toBeInTheDocument(); + expect(screen.getByRole("option", { name: "ProviderSessionLabel" })).toBeInTheDocument(); + expect(screen.getByRole("option", { name: "ProviderWeeklyLabel" })).toBeInTheDocument(); + }); }); diff --git a/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.tsx b/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.tsx index 7bc89e0d7d..b50240df06 100644 --- a/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.tsx +++ b/apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.tsx @@ -78,11 +78,11 @@ function metricOptions( ): MetricOption[] { const options: MetricOption[] = [ { value: "automatic", label: t("Automatic") }, - { value: "session", label: t("ProviderSessionLabel") }, + { value: "session", label: provider.primaryLabel || t("ProviderSessionLabel") }, ]; if (provider.weekly) { - options.push({ value: "weekly", label: t("ProviderWeeklyLabel") }); + options.push({ value: "weekly", label: provider.secondaryLabel || t("ProviderWeeklyLabel") }); } if (provider.modelSpecific) { options.push({ value: "model", label: t("DetailWindowModelSpecific") }); diff --git a/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.test.tsx b/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.test.tsx index cf7ca9b884..ea09039e4a 100644 --- a/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.test.tsx +++ b/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.test.tsx @@ -146,4 +146,36 @@ describe("UsageSection", () => { expect(await screen.findByText(/Limit Reset Credits: 2 available/)).toBeInTheDocument(); expect(container.querySelector(".provider-usage-bar__track")).toBeNull(); }); + + it("shows provider-declared lane labels in settings bars", async () => { + const detail = provider(); + detail.weekly = rateWindow(30); + detail.primaryLabel = "Personal budget"; + detail.secondaryLabel = "Team budget"; + + render( + + key} /> + , + ); + + expect(await screen.findByText("Personal budget")).toBeInTheDocument(); + expect(screen.getByText("Team budget")).toBeInTheDocument(); + expect(screen.queryByText("ProviderSessionLabel")).not.toBeInTheDocument(); + expect(screen.queryByText("ProviderWeeklyLabel")).not.toBeInTheDocument(); + }); + + it("keeps the generic labels when the provider declares none", async () => { + const detail = provider(); + detail.weekly = rateWindow(30); + + render( + + key} /> + , + ); + + expect(await screen.findByText("ProviderSessionLabel")).toBeInTheDocument(); + expect(screen.getByText("ProviderWeeklyLabel")).toBeInTheDocument(); + }); }); diff --git a/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.tsx b/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.tsx index b2d24dbdfc..ae128a1553 100644 --- a/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.tsx +++ b/apps/desktop-tauri/src/surfaces/settings/providers/sections/UsageSection.tsx @@ -32,14 +32,14 @@ export function UsageSection({ provider, resetTimeRelative, t }: Props) { if (provider.session && isUsageItemVisible(provider.hiddenUsageItemIds, "primary")) { bars.push({ key: "session", - label: t("ProviderSessionLabel"), + label: provider.primaryLabel || t("ProviderSessionLabel"), rate: provider.session, }); } if (provider.weekly && isUsageItemVisible(provider.hiddenUsageItemIds, "secondary")) { bars.push({ key: "weekly", - label: t("ProviderWeeklyLabel"), + label: provider.secondaryLabel || t("ProviderWeeklyLabel"), rate: provider.weekly, }); } diff --git a/apps/desktop-tauri/src/types/bridge.ts b/apps/desktop-tauri/src/types/bridge.ts index 88754baa7d..97b6a4f3b7 100644 --- a/apps/desktop-tauri/src/types/bridge.ts +++ b/apps/desktop-tauri/src/types/bridge.ts @@ -957,6 +957,10 @@ export interface ProviderDetail { // Usage windows — mirror RateWindowSnapshot. session: RateWindowSnapshot | null; weekly: RateWindowSnapshot | null; + /** Provider-declared label for the session (primary) lane, e.g. "Personal budget". */ + primaryLabel?: string | null; + /** Provider-declared label for the weekly (secondary) lane, e.g. "Team budget". */ + secondaryLabel?: string | null; modelSpecific: RateWindowSnapshot | null; tertiary: RateWindowSnapshot | null; /** Locale key for the tertiary metric lane when it carries a semantic label (upstream F5). */