@devries-cameron20 / t3code-1 / commits / 5099695673
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): price dialog no longer flags a model before a price is entered (#25755)

Julius Marminge committed Nov 11, 2026 at 15:32 UTC 509969567349cd2975aa477e8806a95925ebd1f6
2 files changed +96 -3
apps/web/src/components/usage/UsagePriceOverrides.browser.test.tsx new
+85
@@ -0,0 +1,85 @@
1 +import { describe, expect, it, vi } from "vite-plus/test";
2 +import { page, userEvent } from "vite-plus/test/browser";
3 +
4 +import { render } from "../../../test/render";
5 +
6 +const ENVIRONMENT_ID = vi.hoisted(() => "workstation");
7 +
8 +vi.mock(import("~/state/presentation"), async (original) => {
9 + const { Atom } = await import("effect/reactivity");
10 + const actual = await original();
11 + const presentation = {
12 + entry: { target: { label: "workstation" } },
13 + connection: { phase: "connected" },
14 + serverConfig: {
15 + environment: { capabilities: { usagePriceOverrides: true, usageModelAliases: true } },
16 + },
17 + };
18 + return {
19 + ...actual,
20 + environmentPresentations: {
21 + ...actual.environmentPresentations,
22 + presentationsAtom: Atom.make(new Map([[ENVIRONMENT_ID, presentation]])) as never,
23 + },
24 + };
25 +});
26 +vi.mock(import("~/state/server"), async (original) => {
27 + const { Atom } = await import("effect/reactivity");
28 + const actual = await original();
29 + const settings = Atom.make({ usagePriceOverrides: {}, usageModelAliases: {} });
30 + return {
31 + ...actual,
32 + serverEnvironment: {
33 + ...actual.serverEnvironment,
34 + settingsValueAtom: (() => settings) as never,
35 + },
36 + };
37 +});
38 +vi.mock(import("~/state/session"), async (original) => {
39 + const { AsyncResult, Atom } = await import("effect/reactivity");
40 + const actual = await original();
41 + const session = Atom.make(
42 + AsyncResult.success({ authenticated: true, scopes: ["settings:write"] }),
43 + );
44 + return {
45 + ...actual,
46 + environmentSession: {
47 + ...actual.environmentSession,
48 + sessionStateAtom: (() => session) as never,
49 + },
50 + };
51 +});
52 +vi.mock(import("~/state/use-atom-command"), async (original) => ({
53 + ...(await original()),
54 + useAtomCommand: (() => vi.fn()) as never,
55 +}));
56 +
57 +import { UsagePriceOverrides } from "./UsagePriceOverrides";
58 +
59 +const renderPrices = (initialModel?: string) =>
60 + render(
61 + <UsagePriceOverrides
62 + usage={[]}
63 + initialSelectedEnvironmentIds={null}
64 + initialModel={initialModel}
65 + onOpenChange={() => {}}
66 + />,
67 + );
68 +
69 +describe("UsagePriceOverrides", () => {
70 + it("waits for a price before flagging an unpriced model's new row", async () => {
71 + await using _screen = await renderPrices("glm-5.3");
72 + const modelId = page.getByLabelText("New model ID");
73 + await expect.element(modelId).toHaveValue("glm-5.3");
74 +
75 + expect(page.getByRole("alert").elements()).toEqual([]);
76 + await expect.element(modelId).not.toHaveAttribute("aria-invalid");
77 + await expect.element(page.getByRole("button", { name: "Save changes" })).toBeDisabled();
78 +
79 + await userEvent.type(page.getByLabelText("Input price for glm-5.3"), "2");
80 + await expect
81 + .element(page.getByRole("alert"))
82 + .toHaveTextContent("Output is required on workstation.");
83 + await expect.element(page.getByRole("button", { name: "Save changes" })).toBeDisabled();
84 + });
85 +});
apps/web/src/components/usage/UsagePriceOverrides.tsx
+11 -3
@@ -158,6 +158,8 @@ export function UsagePriceOverrides({
158 ];
159 const stagedDrafts = drafts.filter((draft) => !isEmptyUsagePriceDraft(draft));
160 const errors = usagePriceTableErrors(selected, stagedDrafts);
161 + // New rows still block Save, but show a price error only once a price or mapping is typed.
162 + const awaitingPrice = new Set<string>();
163 for (const draft of stagedDrafts) {
164 if (!draft.isNew) continue;
165 if (draft.model.trim() === "") errors.set(draft.id, "Enter a model ID.");
@@ -167,6 +169,11 @@ export function UsagePriceOverrides({
169 drafts.some((other) => other.id !== draft.id && other.model.trim() === draft.model.trim()))
170 )
171 errors.set(draft.id, "This model already has a row. Edit its prices there.");
172 + else if (
173 + (draft.alias ?? "").trim() === "" &&
174 + Object.values(draft.values).every((value) => value.trim() === "")
175 + )
176 + awaitingPrice.add(draft.id);
177 }
178 const failedDestinations =
179 attempt?.destinations.filter(
@@ -390,6 +397,7 @@ export function UsagePriceOverrides({
397 rows.map((row) => {
398 const aliasCell = usageAliasCell(selected, row.model);
399 const alias = (row.alias ?? aliasCell.value).trim();
400 + const error = awaitingPrice.has(row.id) ? undefined : errors.get(row.id);
401 return (
402 <TableRow key={row.id} data-row-id={row.id}>
403 <TableCell className="whitespace-normal">
@@ -405,7 +413,7 @@ export function UsagePriceOverrides({
413 }}
414 aria-label="New model ID"
415 aria-invalid={
408 - (row.model.trim() !== "" && errors.has(row.id)) || undefined
416 + (row.model.trim() !== "" && error !== undefined) || undefined
417 }
418 list="usage-price-models"
419 placeholder="Model ID"
@@ -426,11 +434,11 @@ export function UsagePriceOverrides({
434 {row.model}
435 </span>
436 )}
429 - {errors.has(row.id) &&
437 + {error !== undefined &&
438 (row.model.trim() !== "" ||
439 Object.values(row.values).some((value) => value !== "")) ? (
440 <p role="alert" className="mt-1 text-xs text-destructive">
433 - {errors.get(row.id)}
441 + {error}
442 </p>
443 ) : null}
444 </TableCell>