mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
Fix NaN propagation in alert grouping window and AI duration display
setGroupingWindow stored Number.parseInt result without checking for NaN, while the adjacent setEscalationAfter properly guards against it. If an invalid value reached the parser, NaN would propagate into the grouping config and could cascade into alert delivery issues. formatDuration in AIModelSelectionSection displayed raw NaN/Infinity/ negative values without guarding. Now returns '-' for non-finite or negative inputs.
This commit is contained in:
@@ -126,7 +126,8 @@ export const PatrolPreflightControl: Component<{ state: AISettingsState }> = (co
|
||||
};
|
||||
|
||||
const formatDuration = (ms: number) => {
|
||||
if (ms < 1000) return `${ms}ms`;
|
||||
if (!Number.isFinite(ms) || ms < 0) return '-';
|
||||
if (ms < 1000) return `${Math.round(ms)}ms`;
|
||||
return `${(ms / 1000).toFixed(1)}s`;
|
||||
};
|
||||
|
||||
|
||||
@@ -254,9 +254,10 @@ export function useAlertScheduleState(props: UseAlertScheduleStateProps) {
|
||||
};
|
||||
|
||||
const setGroupingWindow = (rawValue: string) => {
|
||||
const parsed = Number.parseInt(rawValue, 10);
|
||||
props.setGrouping({
|
||||
...props.grouping(),
|
||||
window: Number.parseInt(rawValue, 10),
|
||||
window: Number.isNaN(parsed) ? props.grouping().window : parsed,
|
||||
});
|
||||
markUnsaved();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user