Skip to content

Commit 9023554

Browse files
only21milcodexclaude
authored
fix(usage): explain price edits blocked by model mappings (#23768)
Co-authored-by: GPT-6.1 Sol <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 060c332 commit 9023554

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎apps/web/src/components/usage/usagePriceTable.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@ describe("price table edits", () => {
120120
),
121121
).toBe("Map to a different model.");
122122
});
123+
124+
it("requires clearing a mapping before a price edit can apply to every environment", () => {
125+
const mapped = target("mapped", {}, { example: "example-model" });
126+
const priced = target("priced", { example: price });
127+
const edit = draft({ inputCostPerMillionTokens: "3", outputCostPerMillionTokens: "8" });
128+
expect(usagePriceTableErrors([mapped, priced], [edit]).get(edit.id)).toBe(
129+
'mapped maps this model. Remove it from "Apply to" or clear its mapping first.',
130+
);
131+
expect(usagePriceTableChanges(mapped, [edit]).changes).toEqual([]);
132+
133+
const cleared = { ...edit, alias: "" };
134+
expect(usagePriceTableErrors([mapped, priced], [cleared]).size).toBe(0);
135+
expect(usagePriceTableChanges(mapped, [cleared]).changes).toEqual([
136+
{ model: "example", alias: null },
137+
{ model: "example", price: { inputCostPerMillionTokens: 3, outputCostPerMillionTokens: 8 } },
138+
]);
139+
expect(usagePriceTableChanges(priced, [cleared]).changes).toEqual([
140+
{ model: "example", price: { inputCostPerMillionTokens: 3, outputCostPerMillionTokens: 8 } },
141+
]);
142+
});
123143
});
124144

125145
describe("model mapping validation", () => {

‎apps/web/src/components/usage/usagePriceTable.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ export function usagePriceTableChanges(
7878
}
7979
const alias = (draft.alias ?? currentAlias ?? "").trim();
8080
if (alias !== "") {
81+
if (draft.alias === undefined && Object.keys(draft.values).length > 0) {
82+
errors.set(
83+
draft.id,
84+
`${target.label} maps this model. Remove it from "Apply to" or clear its mapping first.`,
85+
);
86+
continue;
87+
}
8188
if (model === "") errors.set(draft.id, "Enter a model ID.");
8289
else if (alias === model) errors.set(draft.id, "Map to a different model.");
8390
else {

0 commit comments

Comments
 (0)