Skip to content

Commit 022743c

Browse files
fix(server): floor the health interval at the UI step, not the probe timeout
#12008 already stopped the Antigravity health probe from spawning its ACP server, so a 90 second floor no longer buys anything and would slow the performance preset for nothing. The floor is now the 30 second step the settings UI offers, enforced server-side for persisted and patched values, and the performance preset stays at one minute. The two provider-health fields now share one component that commits on blur, Enter, or a stepper click. Normalizing on every keystroke persisted "0" while a value such as 600 was still being typed. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 51b9839 commit 022743c

8 files changed

Lines changed: 91 additions & 72 deletions

File tree

‎apps/server/src/provider/makeManagedServerProvider.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ describe("makeManagedServerProvider", () => {
668668
schemaVersion: 1 as const,
669669
profile: "custom" as const,
670670
baseProfile: "balanced" as const,
671-
overrides: { providerHealthRefreshInterval: Duration.seconds(30) },
671+
overrides: { providerHealthRefreshInterval: Duration.seconds(5) },
672672
},
673673
};
674674
const serverSettingsLayer = Layer.succeed(
@@ -707,14 +707,14 @@ describe("makeManagedServerProvider", () => {
707707

708708
yield* Deferred.await(firstCheckStarted);
709709

710-
// The persisted 30s override is floored, so no tick fires at 30s.
711-
yield* TestClock.adjust("30 seconds");
710+
// The persisted 5s override is floored, so no tick fires at 5s.
711+
yield* TestClock.adjust("5 seconds");
712712
assert.strictEqual(yield* Ref.get(checkCalls), 1);
713713

714714
// The floored tick fires while the first probe is still running and is
715715
// skipped rather than queued behind it.
716716
yield* TestClock.adjust(
717-
Duration.subtract(MIN_PROVIDER_HEALTH_REFRESH_INTERVAL, Duration.seconds(30)),
717+
Duration.subtract(MIN_PROVIDER_HEALTH_REFRESH_INTERVAL, Duration.seconds(5)),
718718
);
719719
yield* Effect.yieldNow;
720720
assert.strictEqual(yield* Ref.get(checkCalls), 1);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import * as Duration from "effect/Duration";
2+
import { useState } from "react";
3+
4+
import {
5+
NumberField,
6+
NumberFieldDecrement,
7+
NumberFieldGroup,
8+
NumberFieldIncrement,
9+
NumberFieldInput,
10+
} from "../ui/number-field";
11+
import {
12+
normalizeProviderHealthIntervalSeconds,
13+
PROVIDER_HEALTH_INTERVAL_STEP_SECONDS,
14+
} from "./SettingsPanels.logic";
15+
16+
interface ProviderHealthIntervalFieldProps {
17+
readonly valueSeconds: number;
18+
/** Field name for the accessible labels, e.g. "Provider health interval". */
19+
readonly label: string;
20+
readonly onCommit: (interval: Duration.Duration) => void;
21+
}
22+
23+
/**
24+
* Keeps typing local and normalizes on commit (blur, Enter, or a stepper
25+
* click), so a partially typed value below the minimum is never persisted as
26+
* "disabled" mid-edit.
27+
*/
28+
export function ProviderHealthIntervalField({
29+
valueSeconds,
30+
label,
31+
onCommit,
32+
}: ProviderHealthIntervalFieldProps) {
33+
const [draft, setDraft] = useState<number | null>(valueSeconds);
34+
const [savedSeconds, setSavedSeconds] = useState(valueSeconds);
35+
if (savedSeconds !== valueSeconds) {
36+
setSavedSeconds(valueSeconds);
37+
setDraft(valueSeconds);
38+
}
39+
const stepperLabel = label.charAt(0).toLowerCase() + label.slice(1);
40+
41+
return (
42+
<NumberField
43+
value={draft}
44+
min={0}
45+
step={PROVIDER_HEALTH_INTERVAL_STEP_SECONDS}
46+
size="sm"
47+
className="w-32"
48+
onValueChange={setDraft}
49+
onValueCommitted={(next) => {
50+
const seconds = normalizeProviderHealthIntervalSeconds(next, valueSeconds);
51+
setDraft(seconds);
52+
if (seconds !== valueSeconds) onCommit(Duration.seconds(seconds));
53+
}}
54+
>
55+
<NumberFieldGroup>
56+
<NumberFieldDecrement aria-label={`Decrease ${stepperLabel}`} />
57+
<NumberFieldInput aria-label={`${label} in seconds`} />
58+
<NumberFieldIncrement aria-label={`Increase ${stepperLabel}`} />
59+
</NumberFieldGroup>
60+
</NumberField>
61+
);
62+
}

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

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
resolveServerBackgroundActivitySettings,
2424
} from "@t3tools/shared/backgroundActivitySettings";
2525
import * as Arr from "effect/Array";
26-
import * as Duration from "effect/Duration";
2726
import * as Equal from "effect/Equal";
2827
import * as Result from "effect/Result";
2928
import { PlusIcon } from "lucide-react";
@@ -68,13 +67,6 @@ import {
6867
EmptyMedia,
6968
EmptyTitle,
7069
} from "../ui/empty";
71-
import {
72-
NumberField,
73-
NumberFieldDecrement,
74-
NumberFieldGroup,
75-
NumberFieldIncrement,
76-
NumberFieldInput,
77-
} from "../ui/number-field";
7870
import { ScrollArea } from "../ui/scroll-area";
7971
import { Toggle, ToggleGroup } from "../ui/toggle-group";
8072
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -90,10 +82,9 @@ import {
9082
backgroundActivityOverrideSettings,
9183
buildProviderInstanceUpdatePatch,
9284
durationToSeconds,
93-
normalizeProviderHealthIntervalSeconds,
9485
PROVIDER_HEALTH_INTERVAL_MIN_SECONDS,
95-
PROVIDER_HEALTH_INTERVAL_STEP_SECONDS,
9686
} from "./SettingsPanels.logic";
87+
import { ProviderHealthIntervalField } from "./ProviderHealthIntervalField";
9788
import {
9889
PolicyTooltip,
9990
SettingResetButton,
@@ -1133,35 +1124,19 @@ export function EnvironmentProviderSettings({
11331124
readOnly && "opacity-50 select-none",
11341125
)}
11351126
>
1136-
<NumberField
1137-
value={providerHealthRefreshIntervalSeconds}
1138-
min={0}
1139-
step={PROVIDER_HEALTH_INTERVAL_STEP_SECONDS}
1140-
size="sm"
1141-
className="w-32"
1142-
onValueChange={(value) =>
1127+
<ProviderHealthIntervalField
1128+
valueSeconds={providerHealthRefreshIntervalSeconds}
1129+
label="Provider health check interval"
1130+
onCommit={(interval) =>
11431131
updateSettings(
11441132
backgroundActivityOverrideSettings(
11451133
settings.backgroundActivity,
11461134
resolvedBackgroundActivity,
1147-
{
1148-
providerHealthRefreshInterval: Duration.seconds(
1149-
normalizeProviderHealthIntervalSeconds(
1150-
value,
1151-
providerHealthRefreshIntervalSeconds,
1152-
),
1153-
),
1154-
},
1135+
{ providerHealthRefreshInterval: interval },
11551136
),
11561137
)
11571138
}
1158-
>
1159-
<NumberFieldGroup>
1160-
<NumberFieldDecrement aria-label="Decrease provider health check interval" />
1161-
<NumberFieldInput aria-label="Provider health check interval in seconds" />
1162-
<NumberFieldIncrement aria-label="Increase provider health check interval" />
1163-
</NumberFieldGroup>
1164-
</NumberField>
1139+
/>
11651140
<span className="text-xs text-muted-foreground">seconds</span>
11661141
</div>
11671142
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,12 @@ describe("normalizeProviderHealthIntervalSeconds", () => {
293293
expect(normalizeProviderHealthIntervalSeconds(600, min)).toBe(600);
294294
});
295295

296-
it("jumps to disabled when stepping down from the minimum", () => {
297-
expect(normalizeProviderHealthIntervalSeconds(min - 30, min)).toBe(0);
296+
it("snaps a value typed below the minimum down to disabled when decreasing", () => {
297+
expect(normalizeProviderHealthIntervalSeconds(min - 15, min)).toBe(0);
298298
});
299299

300-
it("jumps to the minimum when stepping up from disabled", () => {
301-
expect(normalizeProviderHealthIntervalSeconds(30, 0)).toBe(min);
300+
it("snaps a value typed below the minimum up to the minimum when increasing", () => {
301+
expect(normalizeProviderHealthIntervalSeconds(15, 0)).toBe(min);
302302
});
303303

304304
it("treats an empty or negative value as disabled", () => {

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

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,15 @@ import {
150150
getChangedBrowserSettingLabels,
151151
getChangedTypographySettingLabels,
152152
normalizeIntervalSeconds,
153-
normalizeProviderHealthIntervalSeconds,
154153
PROVIDER_HEALTH_INTERVAL_MIN_SECONDS,
155-
PROVIDER_HEALTH_INTERVAL_STEP_SECONDS,
156154
hasChangedBackgroundActivitySettings,
157155
isProjectGroupingEnabled,
158156
projectGroupingModeFromToggle,
159157
readLastEnabledProjectGroupingMode,
160158
rememberEnabledProjectGroupingMode,
161159
resolveBackgroundActivityProfileOption,
162160
} from "./SettingsPanels.logic";
161+
import { ProviderHealthIntervalField } from "./ProviderHealthIntervalField";
163162
import {
164163
PolicyTooltip,
165164
SETTINGS_PICKER_TRIGGER_CLASSNAME,
@@ -990,35 +989,19 @@ function BackgroundActivityAdvancedDialog({
990989
</p>
991990
</div>
992991
<div className="flex shrink-0 items-center gap-2">
993-
<NumberField
994-
value={providerHealthRefreshIntervalSeconds}
995-
min={0}
996-
step={PROVIDER_HEALTH_INTERVAL_STEP_SECONDS}
997-
size="sm"
998-
className="w-32"
999-
onValueChange={(value) =>
992+
<ProviderHealthIntervalField
993+
valueSeconds={providerHealthRefreshIntervalSeconds}
994+
label="Provider health interval"
995+
onCommit={(interval) =>
1000996
updateSettings(
1001997
backgroundActivityOverrideSettings(
1002998
settings.backgroundActivity,
1003999
resolvedBackgroundActivity,
1004-
{
1005-
providerHealthRefreshInterval: Duration.seconds(
1006-
normalizeProviderHealthIntervalSeconds(
1007-
value,
1008-
providerHealthRefreshIntervalSeconds,
1009-
),
1010-
),
1011-
},
1000+
{ providerHealthRefreshInterval: interval },
10121001
),
10131002
)
10141003
}
1015-
>
1016-
<NumberFieldGroup>
1017-
<NumberFieldDecrement aria-label="Decrease provider health interval" />
1018-
<NumberFieldInput aria-label="Provider health interval in seconds" />
1019-
<NumberFieldIncrement aria-label="Increase provider health interval" />
1020-
</NumberFieldGroup>
1021-
</NumberField>
1004+
/>
10221005
<span className="text-xs text-muted-foreground">seconds</span>
10231006
</div>
10241007
</div>

‎packages/contracts/src/settings.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,11 @@ export type SourceControlWritingStyleSettings = typeof SourceControlWritingStyle
913913
export const DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL = Duration.seconds(30);
914914
export const DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL = Duration.minutes(5);
915915
/**
916-
* Shortest allowed gap between provider health probes. Zero still disables
917-
* them. Matches the 90 second probe timeout of the slowest process-based
918-
* check (Antigravity spawns its full ACP server), so a short interval cannot
919-
* respawn that process back-to-back.
916+
* Shortest allowed gap between periodic provider health probes. Zero still
917+
* disables them. Matches the 30 second step the settings UI offers, so a
918+
* persisted or patched value cannot run probes faster than the UI allows.
920919
*/
921-
export const MIN_PROVIDER_HEALTH_REFRESH_INTERVAL = Duration.seconds(90);
920+
export const MIN_PROVIDER_HEALTH_REFRESH_INTERVAL = Duration.seconds(30);
922921

923922
export const BackgroundActivityProfile = Schema.Literals([
924923
"balanced",

‎packages/shared/src/backgroundActivitySettings.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("clampProviderHealthRefreshInterval", () => {
2121
expect(Duration.toMillis(clampProviderHealthRefreshInterval(Duration.seconds(5)))).toBe(
2222
MIN_MILLIS,
2323
);
24-
expect(Duration.toMillis(clampProviderHealthRefreshInterval(Duration.seconds(30)))).toBe(
24+
expect(Duration.toMillis(clampProviderHealthRefreshInterval(Duration.seconds(29)))).toBe(
2525
MIN_MILLIS,
2626
);
2727
});

‎packages/shared/src/backgroundActivitySettings.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as Duration from "effect/Duration";
1212
/**
1313
* Zero disables periodic probes. Any other interval is floored at
1414
* {@link MIN_PROVIDER_HEALTH_REFRESH_INTERVAL} so a persisted or patched
15-
* value cannot schedule probes faster than the probe timeout.
15+
* value cannot schedule probes faster than the settings UI allows.
1616
*/
1717
export function clampProviderHealthRefreshInterval(interval: Duration.Duration): Duration.Duration {
1818
const millis = Duration.toMillis(interval);
@@ -39,7 +39,7 @@ const PRESET_SETTINGS: Record<BackgroundActivityProfile, ResolvedBackgroundActiv
3939
performance: {
4040
profile: "performance",
4141
automaticGitFetchInterval: Duration.seconds(15),
42-
providerHealthRefreshInterval: MIN_PROVIDER_HEALTH_REFRESH_INTERVAL,
42+
providerHealthRefreshInterval: Duration.minutes(1),
4343
hostPowerMonitorActiveInterval: Duration.seconds(30),
4444
hostPowerMonitorIdleInterval: Duration.minutes(2),
4545
idleClientTtl: Duration.seconds(45),

0 commit comments

Comments
 (0)