Skip to content

Commit 794ebef

Browse files
fix(web): revert an emptied provider health field instead of committing it
An empty field is not a value. Committing it as "disabled" also let a stepper press on a cleared field persist twice: once from the blur and once from the step. Reverting to the saved value keeps one commit per interaction; typing 0 or stepping down still disables probes. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 022743c commit 794ebef

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎apps/web/src/components/settings/ProviderHealthIntervalField.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ interface ProviderHealthIntervalFieldProps {
2323
/**
2424
* Keeps typing local and normalizes on commit (blur, Enter, or a stepper
2525
* click), so a partially typed value below the minimum is never persisted as
26-
* "disabled" mid-edit.
26+
* "disabled" mid-edit. An empty field reverts to the saved value instead of
27+
* committing, which also keeps a stepper press on a cleared field to a single
28+
* commit.
2729
*/
2830
export function ProviderHealthIntervalField({
2931
valueSeconds,
@@ -47,6 +49,10 @@ export function ProviderHealthIntervalField({
4749
className="w-32"
4850
onValueChange={setDraft}
4951
onValueCommitted={(next) => {
52+
if (next === null) {
53+
setDraft(valueSeconds);
54+
return;
55+
}
5056
const seconds = normalizeProviderHealthIntervalSeconds(next, valueSeconds);
5157
setDraft(seconds);
5258
if (seconds !== valueSeconds) onCommit(Duration.seconds(seconds));

‎apps/web/src/components/settings/SettingsPanels.logic.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ describe("normalizeProviderHealthIntervalSeconds", () => {
301301
expect(normalizeProviderHealthIntervalSeconds(15, 0)).toBe(min);
302302
});
303303

304-
it("treats an empty or negative value as disabled", () => {
305-
expect(normalizeProviderHealthIntervalSeconds(null, min)).toBe(0);
304+
it("treats a negative value as disabled", () => {
306305
expect(normalizeProviderHealthIntervalSeconds(-5, min)).toBe(0);
307306
});
308307
});

‎apps/web/src/components/settings/SettingsPanels.logic.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export const PROVIDER_HEALTH_INTERVAL_MIN_SECONDS = durationToSeconds(
321321
* value typed into the gap snaps in the direction the user was moving.
322322
*/
323323
export function normalizeProviderHealthIntervalSeconds(
324-
value: number | null,
324+
value: number,
325325
previousSeconds: number,
326326
): number {
327327
const seconds = normalizeIntervalSeconds(value);

0 commit comments

Comments
 (0)