From 46488ecd93e1cecd575fbaec2c42862972508459 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 5 Apr 2026 17:34:39 +0800 Subject: [PATCH] fix: set default auto-query interval to 5min and fix number input clearing - Change default autoQueryInterval from 0 (disabled) to 5 minutes for new usage scripts (Token Plan, Balance, and general templates) - Fix controlled number inputs (timeout & interval) that couldn't be cleared: defer validation to onBlur so users can delete and retype --- src/components/UsageScriptModal.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/UsageScriptModal.tsx b/src/components/UsageScriptModal.tsx index 19529f933..257a2333c 100644 --- a/src/components/UsageScriptModal.tsx +++ b/src/components/UsageScriptModal.tsx @@ -238,6 +238,7 @@ const UsageScriptModal: React.FC = ({ language: "javascript" as const, code: "", timeout: 10, + autoQueryInterval: 5, codingPlanProvider: autoDetected, }; } @@ -249,6 +250,7 @@ const UsageScriptModal: React.FC = ({ language: "javascript" as const, code: "", timeout: 10, + autoQueryInterval: 5, }; } @@ -257,6 +259,7 @@ const UsageScriptModal: React.FC = ({ language: "javascript" as const, code: PRESET_TEMPLATES[TEMPLATE_TYPES.GENERAL], timeout: 10, + autoQueryInterval: 5, }; }); @@ -1061,7 +1064,10 @@ const UsageScriptModal: React.FC = ({ onChange={(e) => setScript({ ...script, - timeout: validateTimeout(e.target.value), + timeout: + e.target.value === "" + ? (("" as unknown) as number) + : Number(e.target.value), }) } onBlur={(e) => @@ -1085,14 +1091,15 @@ const UsageScriptModal: React.FC = ({ min={0} max={1440} value={ - script.autoQueryInterval ?? script.autoIntervalMinutes ?? 0 + script.autoQueryInterval ?? script.autoIntervalMinutes ?? 5 } onChange={(e) => setScript({ ...script, - autoQueryInterval: validateAndClampInterval( - e.target.value, - ), + autoQueryInterval: + e.target.value === "" + ? (("" as unknown) as number) + : Number(e.target.value), }) } onBlur={(e) =>