The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Clean up input labels in AI usage limits (#73606)
Andrei Chernykh07f38db122c8
diff --git a/e2e/test/scenarios/metabot/ai-controls.cy.spec.ts b/e2e/test/scenarios/metabot/ai-controls.cy.spec.tsindex 75903777dbd..92d097c1eb2 100644--- a/e2e/test/scenarios/metabot/ai-controls.cy.spec.ts+++ b/e2e/test/scenarios/metabot/ai-controls.cy.spec.ts@@ -364,7 +364,7 @@ describe("AI controls > AI usage limits", () => {});// Type an instance limit value- cy.findByLabelText(/Total weekly instance limit/).type("500");+ cy.findByLabelText("Total weekly instance message limit").type("500");cy.wait("@updateInstanceLimit").then(({ request }) => {expect(request.body).to.deep.equal({ max_usage: 500 });});@@ -390,7 +390,7 @@ describe("AI controls > AI usage limits", () => {cy.wait("@getInstanceLimit");cy.findByRole("textbox", {- name: /Total monthly instance limit/,+ name: "Total monthly instance token limit",}).clear();cy.wait("@updateInstanceLimit").then(({ request }) => {expect(request.body).to.deep.equal({ max_usage: null });@@ -663,9 +663,7 @@ describe("AI Controls > Tenant usage limits", () => {cy.findByTestId("tenant-limits-tab").findByText("Test Corp").should("be.visible");- cy.findByLabelText(- "Max total monthly tokens for Test Corp (millions)",- ).type("10");+ cy.findByLabelText("Max total monthly tokens for Test Corp").type("10");cy.wait("@updateTenantLimit").its("response.statusCode").should("eq", 200);});diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.module.css b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.module.cssindex 5babd997a5a..8370897875c 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.module.css+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.module.css@@ -1,12 +1,8 @@-.SegmentedControlRoot {- align-self: flex-start;-}-.Label {padding-inline: 0.75rem;}-.InstanceTokenLimitInput {+.InstanceLimitInputWrapper {max-width: 15rem;}@@ -15,6 +11,7 @@line-height: 1rem;}-.QuotaMessageInputWrapper {- width: 100%;+.InputUnitSection {+ color: var(--mb-color-text-primary);+ padding-inline: 0.75rem;}diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.tsxindex 971de76bfaf..6184c466d71 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.tsx@@ -17,7 +17,7 @@ import {} from "./hooks";import {getInstanceLimitInputLabel,- getMaxUsageInputSuffix,+ getMaxUsageInputUnit,getQuotaMessageInputDescription,limitTypeOptions,resetPeriodOptions,@@ -49,26 +49,20 @@ export function GeneralLimitsSettingsSection() {return (<SettingsSection title={t`Settings and general limits`}><Stack gap="xl" align="flex-start">- <Stack gap="sm">+ <Stack gap="sm" align="flex-start"><Text fw="bold">{t`How do you want to limit AI usage?`}</Text><SegmentedControldata={limitTypeOptions}- classNames={{- root: S.SegmentedControlRoot,- label: S.Label,- }}+ classNames={{ label: S.Label }}value={limitType}onChange={handleLimitTypeChange}/></Stack>- <Stack gap="sm">+ <Stack gap="sm" align="flex-start"><Text fw="bold">{t`When should usage limits reset?`}</Text><SegmentedControldata={resetPeriodOptions}- classNames={{- root: S.SegmentedControlRoot,- label: S.Label,- }}+ classNames={{ label: S.Label }}value={limitPeriod}onChange={handleLimitPeriodChange}/>@@ -81,10 +75,13 @@ export function GeneralLimitsSettingsSection() {description={t`This is the maximum amount all users should be able to use in total.`}placeholder={t`Unlimited`}classNames={{- input: S.InstanceTokenLimitInput,+ wrapper: S.InstanceLimitInputWrapper,description: S.InputDescription,+ section: S.InputUnitSection,}}- suffix={getMaxUsageInputSuffix(limitType, instanceLimit)}+ rightSection={getMaxUsageInputUnit(limitType, instanceLimit)}+ rightSectionWidth="auto"+ rightSectionPointerEvents="none"min={0}decimalScale={0}value={instanceLimit != null ? instanceLimit : ""}@@ -98,10 +95,8 @@ export function GeneralLimitsSettingsSection() {label={t`Quota-reached message`}description={getQuotaMessageInputDescription(limitPeriod)}placeholder={t`You have reached your AI usage limit for the current period. Please contact your administrator.`}- classNames={{- description: S.InputDescription,- root: S.QuotaMessageInputWrapper,- }}+ w="100%"+ classNames={{ description: S.InputDescription }}value={quotaMessage || ""}onChange={(e) => handleQuotaMessageChange(e.target.value)}/>diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.unit.spec.tsxindex ecf034debd3..92167b7fbac 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GeneralLimitsSettingsSection.unit.spec.tsx@@ -83,7 +83,7 @@ describe("GeneralLimitsSettingsSection", () => {await waitFor(() => {expect(- screen.getByText(/Total monthly instance limit \(millions of tokens\)/),+ screen.getByText("Total monthly instance token limit"),).toBeInTheDocument();});});@@ -94,7 +94,7 @@ describe("GeneralLimitsSettingsSection", () => {await waitFor(() => {expect(- screen.getByText(/instance limit \(message count\)/),+ screen.getByText("Total monthly instance message limit"),).toBeInTheDocument();});});@@ -104,7 +104,7 @@ describe("GeneralLimitsSettingsSection", () => {await screen.findByText("How do you want to limit AI usage?");await waitFor(() => {- expect(screen.getByDisplayValue("500 million")).toBeInTheDocument();+ expect(screen.getByDisplayValue("500")).toBeInTheDocument();});});@@ -115,6 +115,24 @@ describe("GeneralLimitsSettingsSection", () => {expect(screen.getByPlaceholderText("Unlimited")).toBeInTheDocument();});+ it("shows 'million' unit beside the instance limit input when limit type is tokens", async () => {+ setup({ limitType: "tokens" });+ await screen.findByText("How do you want to limit AI usage?");++ await waitFor(() => {+ expect(screen.getByText("million")).toBeInTheDocument();+ });+ });++ it("shows 'messages' unit beside the instance limit input when limit type is messages", async () => {+ setup({ limitType: "messages" });+ await screen.findByText("How do you want to limit AI usage?");++ await waitFor(() => {+ expect(screen.getByText("messages")).toBeInTheDocument();+ });+ });+it("renders the quota-reached message input with saved value", async () => {setup({ quotaMessage: "You hit the limit!" });await screen.findByText("How do you want to limit AI usage?");@@ -133,7 +151,7 @@ describe("GeneralLimitsSettingsSection", () => {await userEvent.click(screen.getByText("By message count"));expect(- screen.getByText(/instance limit \(message count\)/),+ screen.getByText("Total monthly instance message limit"),).toBeInTheDocument();});@@ -144,7 +162,7 @@ describe("GeneralLimitsSettingsSection", () => {await userEvent.click(screen.getByText("Daily"));await waitFor(() => {- expect(screen.getByText(/daily.*instance limit/i)).toBeInTheDocument();+ expect(screen.getByText(/total daily instance/i)).toBeInTheDocument();});});});diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/AllUsersHigherAccessTooltipIcon.module.css b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/AllUsersHigherAccessTooltipIcon.module.cssindex b5859b1d7e0..6d02a7c1c40 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/AllUsersHigherAccessTooltipIcon.module.css+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/AllUsersHigherAccessTooltipIcon.module.css@@ -1,8 +1,9 @@.InfoIcon {- align-self: center;color: var(--mb-color-text-tertiary);cursor: pointer;flex-shrink: 0;- position: absolute;- right: -22px;+ /* Nudge for SVG glyph offset within its bounding box. */+ transform: translateY(1px);+ /* Parent input's right section disables pointer events; re-enable here. */+ pointer-events: auto;}diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.module.css b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.module.cssindex e972fc8088f..e2d9b85978b 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.module.css+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.module.css@@ -39,11 +39,12 @@color: var(--mb-color-text-primary);}-.LimitInput {- max-width: 10rem;+/* Caps input + right-section unit, hence wider than input-only would be. */+.LimitInputWrapper {+ max-width: 14rem;}-.InputWrapper {- display: inline-flex;- position: relative;+.InputUnitSection {+ color: var(--mb-color-text-primary);+ padding-inline: 0.75rem;}diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.tsxindex 3a558c1b722..439fed5fe5f 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.tsx@@ -5,7 +5,7 @@ import { isEmpty } from "underscore";import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";import { useMetadataToasts } from "metabase/metadata/hooks";-import { Box, NumberInput, Stack, Text } from "metabase/ui";+import { Box, Group, NumberInput, Stack, Text } from "metabase/ui";import { isDefaultGroup } from "metabase/utils/groups";import { useUpdateAIControlsGroupLimitMutation } from "metabase-enterprise/api";import type { GroupInfo } from "metabase-types/api";@@ -20,7 +20,7 @@ import {getDescription,getErrorMessage,getGroupLimitAriaLabel,- getMaxUsageInputSuffix,+ getMaxUsageInputUnit,sanitizeUsageLimitValue,} from "./utils";@@ -154,36 +154,43 @@ export function GroupLimitsTab(props: GroupLimitsTabProps) {<tr key={group.id} className={S.BodyRow}><td className={S.BodyCell}>{group.name}</td><td className={S.BodyCell}>- <div className={S.InputWrapper}>- <NumberInput- placeholder={placeholder}- value={inputValue}- onChange={(value) => handleChange(group, value)}- classNames={{ input: S.LimitInput }}- suffix={getMaxUsageInputSuffix(- limitType,- localLimitsMap?.[group.id],- )}- min={0}- decimalScale={0}- aria-label={getGroupLimitAriaLabel(- limitType,- group.name,- )}- error={- isOverInstanceLimit- ? t`Can't be higher than the instance limit`- : undefined- }- rightSection={- showAllUsersOverrideTooltip ? (+ <NumberInput+ placeholder={placeholder}+ value={inputValue}+ onChange={(value) => handleChange(group, value)}+ classNames={{+ wrapper: S.LimitInputWrapper,+ section: S.InputUnitSection,+ }}+ min={0}+ decimalScale={0}+ aria-label={getGroupLimitAriaLabel(+ limitType,+ group.name,+ )}+ error={+ isOverInstanceLimit+ ? t`Can't be higher than the instance limit`+ : undefined+ }+ rightSectionWidth="auto"+ rightSectionPointerEvents="none"+ rightSection={+ <Group gap="xs" wrap="nowrap" align="center">+ {showAllUsersOverrideTooltip && (<AllUsersHigherAccessTooltipIcongroupName={allUsersGroup.name}/>- ) : undefined- }- />- </div>+ )}+ <Text c="text-primary">+ {getMaxUsageInputUnit(+ limitType,+ localLimitsMap?.[group.id],+ )}+ </Text>+ </Group>+ }+ /></td></tr>);diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.unit.spec.tsxindex 9f0a00f40ef..fc8e58ae5de 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/GroupLimitsTab.unit.spec.tsx@@ -97,6 +97,18 @@ describe("GroupLimitsTab", () => {expect(screen.getByText(/Max messages per user/)).toBeInTheDocument();});+ it("shows 'million' unit beside each input when limitType is tokens", () => {+ setup({ limitType: "tokens" });++ expect(screen.getAllByText("million").length).toBe(defaultGroups.length);+ });++ it("shows 'messages' unit beside each input when limitType is messages", () => {+ setup({ limitType: "messages" });++ expect(screen.getAllByText("messages").length).toBe(defaultGroups.length);+ });+it("shows 'Group' column header for regular-groups variant", () => {setup({ variant: "regular-groups" });expect(screen.getByText("Group")).toBeInTheDocument();@@ -115,8 +127,8 @@ describe("GroupLimitsTab", () => {],});- expect(screen.getByDisplayValue("100 million")).toBeInTheDocument();- expect(screen.getByDisplayValue("50 million")).toBeInTheDocument();+ expect(screen.getByDisplayValue("100")).toBeInTheDocument();+ expect(screen.getByDisplayValue("50")).toBeInTheDocument();});it("shows 'Unlimited' placeholder when instance limit is null", () => {@@ -140,10 +152,10 @@ describe("GroupLimitsTab", () => {name: /Administrators/,});await userEvent.type(adminInput, "1");- expect(adminInput).toHaveValue("1 million");+ expect(adminInput).toHaveValue("1");await userEvent.clear(adminInput);await userEvent.type(adminInput, "10");- expect(adminInput).toHaveValue("10 million");+ expect(adminInput).toHaveValue("10");});it("shows error message when error is present", () => {diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/utils.ts b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/utils.tsindex d2e216b10f5..ef2f3feb8cd 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/utils.ts+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/GroupLimitsTab/utils.ts@@ -9,7 +9,7 @@ import type {export {SAVE_DEBOUNCE_MS,sanitizeUsageLimitValue,- getMaxUsageInputSuffix,+ getMaxUsageInputUnit,} from "../../utils";export type GroupLimitsTabProps = {@@ -32,8 +32,7 @@ export function getGroupLimitAriaLabel(groupName: string,) {if (limitType === "tokens") {- return c("{0} is the group name")- .t`Max tokens per user for ${groupName} (millions)`;+ return c("{0} is the group name").t`Max tokens per user for ${groupName}`;}return c("{0} is the group name").t`Max messages per user for ${groupName}`;@@ -45,9 +44,9 @@ const columnNameMap: Record<> = {get tokens() {return {- daily: t`Max tokens per user each day (millions)`,- weekly: t`Max tokens per user each week (millions)`,- monthly: t`Max tokens per user each month (millions)`,+ daily: t`Max tokens per user each day`,+ weekly: t`Max tokens per user each week`,+ monthly: t`Max tokens per user each month`,};},get messages() {diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.tsxindex 74b8afea663..658e6daa5d8 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.tsx@@ -26,7 +26,7 @@ import {getColumnName,getDescription,getInputLabel,- getMaxUsageInputSuffix,+ getMaxUsageInputUnit,sanitizeUsageLimitValue,} from "./utils";@@ -166,7 +166,10 @@ export function TenantLimitsTab(props: SpecificTenantsTabProps) {placeholder={placeholder}value={inputValue}onChange={(value) => handleChange(tenant, value)}- classNames={{ input: S.LimitInput }}+ classNames={{+ wrapper: S.LimitInputWrapper,+ section: S.InputUnitSection,+ }}error={isOverInstanceLimit? t`Can't be higher than the instance limit`@@ -179,10 +182,12 @@ export function TenantLimitsTab(props: SpecificTenantsTabProps) {limitType,limitPeriod,)}- suffix={getMaxUsageInputSuffix(+ rightSection={getMaxUsageInputUnit(limitType,localLimitsMap?.[tenant.id],)}+ rightSectionWidth="auto"+ rightSectionPointerEvents="none"/></td></tr>diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.unit.spec.tsxindex 66e655f0d45..d76b1ba362c 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/TenantLimitsTab.unit.spec.tsx@@ -84,6 +84,18 @@ describe("TenantLimitsTab", () => {expect(screen.getByText(/Max total.*messages/)).toBeInTheDocument();});+ it("shows 'million' unit beside each input when limitType is tokens", () => {+ setup({ limitType: "tokens" });++ expect(screen.getAllByText("million").length).toBe(defaultTenants.length);+ });++ it("shows 'messages' unit beside each input when limitType is messages", () => {+ setup({ limitType: "messages" });++ expect(screen.getAllByText("messages").length).toBe(defaultTenants.length);+ });+it("populates inputs from existing tenant limits", () => {setup({tenantLimits: [@@ -92,8 +104,8 @@ describe("TenantLimitsTab", () => {],});- expect(screen.getByDisplayValue("1 million")).toBeInTheDocument();- expect(screen.getByDisplayValue("10 million")).toBeInTheDocument();+ expect(screen.getByDisplayValue("1")).toBeInTheDocument();+ expect(screen.getByDisplayValue("10")).toBeInTheDocument();});it("shows 'Unlimited' placeholder when instance limit is null", () => {@@ -143,7 +155,7 @@ describe("TenantLimitsTab", () => {});await userEvent.type(acmeInput, "300");- expect(acmeInput).toHaveValue("300 million");+ expect(acmeInput).toHaveValue("300");});it("shows error when value exceeds the instance limit", async () => {diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/utils.ts b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/utils.tsindex 199c95795e2..c52f61cbd52 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/utils.ts+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/GroupLimitsSettingsSection/TenantLimitsTab/utils.ts@@ -10,7 +10,7 @@ import type {export {SAVE_DEBOUNCE_MS,sanitizeUsageLimitValue,- getMaxUsageInputSuffix,+ getMaxUsageInputUnit,} from "../../utils";export type SpecificTenantsTabProps = {@@ -36,11 +36,11 @@ export function getInputLabel(> = {tokens: {daily: c("{0} is the tenant name")- .t`Max total daily tokens for ${tenantName} (millions)`,+ .t`Max total daily tokens for ${tenantName}`,weekly: c("{0} is the tenant name")- .t`Max total weekly tokens for ${tenantName} (millions)`,+ .t`Max total weekly tokens for ${tenantName}`,monthly: c("{0} is the tenant name")- .t`Max total monthly tokens for ${tenantName} (millions)`,+ .t`Max total monthly tokens for ${tenantName}`,},messages: {daily: c("{0} is the tenant name")@@ -61,9 +61,9 @@ const columnNameMap: Record<> = {get tokens() {return {- daily: t`Max total daily token usage (millions)`,- weekly: t`Max total weekly token usage (millions)`,- monthly: t`Max total monthly token usage (millions)`,+ daily: t`Max total daily token usage`,+ weekly: t`Max total weekly token usage`,+ monthly: t`Max total monthly token usage`,};},get messages() {diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/utils.ts b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/utils.tsindex e828ae84f25..cca6e887a72 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/utils.ts+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotUsageLimitsPage/utils.ts@@ -68,16 +68,16 @@ const instanceLimitLabelMap: Record<> = {get tokens() {return {- daily: t`Total daily instance limit (millions of tokens)`,- weekly: t`Total weekly instance limit (millions of tokens)`,- monthly: t`Total monthly instance limit (millions of tokens)`,+ daily: t`Total daily instance token limit`,+ weekly: t`Total weekly instance token limit`,+ monthly: t`Total monthly instance token limit`,};},get messages() {return {- daily: t`Total daily instance limit (message count)`,- weekly: t`Total weekly instance limit (message count)`,- monthly: t`Total monthly instance limit (message count)`,+ daily: t`Total daily instance message limit`,+ weekly: t`Total weekly instance message limit`,+ monthly: t`Total monthly instance message limit`,};},};@@ -107,20 +107,20 @@ export function getQuotaMessageInputDescription(return messageDescriptionMap[limitPeriod];}-export function getMaxUsageInputSuffix(+export function getMaxUsageInputUnit(limitType: MetabotLimitType,value?: number | null,) {- if (limitType === "tokens" && !!value) {- return (- " " +- c("suffix after a numeral, e.g. '10 million'").ngettext(- msgid`million`,- `million`,- value,- )- );+ // Default to 2 so the unit reads as plural ("messages") for the placeholder.+ const count = value ?? 2;++ if (limitType === "tokens") {+ return c(+ "unit shown beside a token-count input, e.g. '10 million'",+ ).ngettext(msgid`million`, `million`, count);}- return undefined;+ return c(+ "unit shown beside a message-count input, e.g. '10 messages'",+ ).ngettext(msgid`message`, `messages`, count);}