From 3245b2b7463eae8f33618d890c1642dd0d24cc7e Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Fri, 26 Jun 2026 18:57:08 +0800 Subject: [PATCH] fix(model-pricing): refresh tiered expression editor when switching models (#5752) Switching models in the pricing editor kept the previous model's tiers and prices in the expression panel: TieredPricingEditor seeds its internal visual/raw state only on mount, and the initRef guard never re-ran on prop changes, so only the model name updated. Bump a reload token in the same effect that seeds billingExpr and use it as the editor's key, so a freshly loaded model remounts the editor and re-parses its expression. The token changes in lockstep with billingExpr, and user edits (which only touch state) do not trigger it. Closes #5750 --- .../features/system-settings/models/model-pricing-sheet.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/default/src/features/system-settings/models/model-pricing-sheet.tsx b/web/default/src/features/system-settings/models/model-pricing-sheet.tsx index 0f4e8fd4..bd8ed0b9 100644 --- a/web/default/src/features/system-settings/models/model-pricing-sheet.tsx +++ b/web/default/src/features/system-settings/models/model-pricing-sheet.tsx @@ -153,6 +153,7 @@ export const ModelPricingEditorPanel = forwardRef< }) const [billingExpr, setBillingExpr] = useState('') const [requestRuleExpr, setRequestRuleExpr] = useState('') + const [editorReloadToken, setEditorReloadToken] = useState(0) const isEditMode = !!editData const form = useForm({ @@ -214,6 +215,7 @@ export const ModelPricingEditorPanel = forwardRef< setPromptPrice(nextLaneState.promptPrice) setLanePrices(nextLaneState.prices) setLaneEnabled(nextLaneState.enabled) + setEditorReloadToken((token) => token + 1) }, [editData, form]) const setFormValue = (field: keyof ModelPricingFormValues, value: string) => { @@ -638,6 +640,7 @@ export const ModelPricingEditorPanel = forwardRef<