GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): restoring a saved model mapping clears its typed prices (#4… · patroza/t3code@f82de65

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/usage
    • UsagePriceOverrides.browser.test.tsx
    • UsagePriceOverrides.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/usage/UsagePriceOverrides.browser.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/usage/UsagePriceOverrides.browser.test.tsx
+35-1Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ vi.mock(import("~/state/presentation"), async (original) => {
2626
vi.mock(import("~/state/server"), async (original) => {
2727
const { Atom } = await import("effect/reactivity");
2828
const actual = await original();
29-
const settings = Atom.make({ usagePriceOverrides: {}, usageModelAliases: {} });
29+
const settings = Atom.make({
30+
usagePriceOverrides: {
31+
"priced-model": { inputCostPerMillionTokens: 1, outputCostPerMillionTokens: 4 },
32+
},
33+
usageModelAliases: { "my-preview": "gpt-4o" },
34+
});
3035
return {
3136
...actual,
3237
serverEnvironment: {
@@ -97,4 +102,33 @@ describe("UsagePriceOverrides", () => {
97102
await expect.element(modelId).toHaveAttribute("aria-invalid", "true");
98103
await expect.element(page.getByRole("button", { name: "Save changes" })).toBeDisabled();
99104
});
105+
106+
it("leaves no pending change when a mapping goes back to its saved model", async () => {
107+
await using _screen = await renderPrices();
108+
const mapTo = page.getByLabelText("Map my-preview to model");
109+
await userEvent.clear(mapTo);
110+
await userEvent.type(page.getByLabelText("Input price for my-preview"), "2");
111+
await userEvent.type(mapTo, "gpt-4o");
112+
113+
await expect
114+
.element(page.getByRole("button", { name: "Discard changes" }))
115+
.not.toBeInTheDocument();
116+
expect(page.getByRole("alert").elements()).toEqual([]);
117+
await expect
118+
.element(page.getByRole("button", { name: "Apply to All environments" }))
119+
.toBeEnabled();
120+
});
121+
122+
it("keeps typed prices when a priced model's new mapping is cleared", async () => {
123+
await using _screen = await renderPrices();
124+
const input = page.getByLabelText("Input price for priced-model");
125+
await userEvent.clear(input);
126+
await userEvent.type(input, "2");
127+
const mapTo = page.getByLabelText("Map priced-model to model");
128+
await userEvent.type(mapTo, "gpt-4o");
129+
await userEvent.clear(mapTo);
130+
131+
await expect.element(input).toHaveValue("2");
132+
await expect.element(page.getByRole("button", { name: "Save changes" })).toBeEnabled();
133+
});
100134
});
Collapse file

‎apps/web/src/components/usage/UsagePriceOverrides.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/usage/UsagePriceOverrides.tsx
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,12 @@ export function UsagePriceOverrides({
232232
const editAlias = (row: UsagePriceDraft, value: string) => {
233233
const { alias: _alias, ...rest } = row;
234234
const original = usageAliasCell(selected, row.model, messages);
235-
updateOrDropDraft(matchesSaved(row, original, value) ? rest : { ...rest, alias: value });
235+
updateOrDropDraft(
236+
matchesSaved(row, original, value)
237+
? // A restored mapping hides the price inputs, so their typed values go too.
238+
{ ...rest, values: value === "" ? rest.values : {} }
239+
: { ...rest, alias: value },
240+
);
236241
};
237242
const save = async (retry = false) => {
238243
if (pending) return;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.