fix(lint): clear the 7 exhaustive-deps warnings carried all session
Every lint run this session reported the same 7 warnings across 4 files. Fixed properly, not suppressed: - Chat/index.tsx: effect depended on the whole liveChatStatus object; narrowed to liveChatStatus?.requestId, the one field it actually reads. - Heartbeat/index.tsx: fetchConfig wrapped in useCallback([form, t]) and added to its effect's dependency array, instead of an empty array silencing the warning on a function that closes over both. - Environments/index.tsx: `t` (i18n) added to 4 useCallback dependency arrays that read it but didn't declare it. - ModelsSection.tsx: effect depended on the currentSlot object reference; extracted currentProviderId/currentModel primitives so it only reruns when the actual values change, not on every new object identity. Build 0 errors, lint 0 errors / 0 warnings (was 7). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -922,7 +922,7 @@ export default function ChatPage() {
|
|||||||
}, [activeTab]);
|
}, [activeTab]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (liveChatStatus) {
|
if (liveChatStatus?.requestId) {
|
||||||
forceFollowUntilRef.current = Date.now() + 15_000;
|
forceFollowUntilRef.current = Date.now() + 15_000;
|
||||||
scrollChatToBottom(chatStageRef.current);
|
scrollChatToBottom(chatStageRef.current);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
@@ -72,7 +72,7 @@ function HeartbeatPage() {
|
|||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [form] = Form.useForm<HeartbeatFormValues>();
|
const [form] = Form.useForm<HeartbeatFormValues>();
|
||||||
|
|
||||||
const fetchConfig = async () => {
|
const fetchConfig = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const data = await api.getHeartbeatConfig();
|
const data = await api.getHeartbeatConfig();
|
||||||
@@ -92,11 +92,11 @@ function HeartbeatPage() {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
}, [form, t]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchConfig();
|
fetchConfig();
|
||||||
}, []);
|
}, [fetchConfig]);
|
||||||
|
|
||||||
const onFinish = async (values: HeartbeatFormValues) => {
|
const onFinish = async (values: HeartbeatFormValues) => {
|
||||||
const every =
|
const every =
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ function EnvironmentsPage() {
|
|||||||
onOk: doRemove,
|
onOk: doRemove,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[workingRows, ensureLocal, envVars.length],
|
[workingRows, ensureLocal, envVars.length, t],
|
||||||
);
|
);
|
||||||
|
|
||||||
const removeSelected = useCallback(() => {
|
const removeSelected = useCallback(() => {
|
||||||
@@ -211,7 +211,7 @@ function EnvironmentsPage() {
|
|||||||
cancelText: t("common.cancel"),
|
cancelText: t("common.cancel"),
|
||||||
onOk: doRemove,
|
onOk: doRemove,
|
||||||
});
|
});
|
||||||
}, [selected, workingRows, ensureLocal, envVars.length]);
|
}, [selected, workingRows, ensureLocal, envVars.length, t]);
|
||||||
|
|
||||||
/* ---- validate & save ---- */
|
/* ---- validate & save ---- */
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ function EnvironmentsPage() {
|
|||||||
}
|
}
|
||||||
setKeyErrors(errors);
|
setKeyErrors(errors);
|
||||||
return Object.keys(errors).length === 0;
|
return Object.keys(errors).length === 0;
|
||||||
}, [workingRows]);
|
}, [workingRows, t]);
|
||||||
|
|
||||||
const handleSave = useCallback(async () => {
|
const handleSave = useCallback(async () => {
|
||||||
if (!validate()) return;
|
if (!validate()) return;
|
||||||
@@ -254,7 +254,7 @@ function EnvironmentsPage() {
|
|||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
}, [validate, workingRows, fetchAll]);
|
}, [validate, workingRows, fetchAll, t]);
|
||||||
|
|
||||||
const handleReset = useCallback(() => {
|
const handleReset = useCallback(() => {
|
||||||
setRows(null);
|
setRows(null);
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ export function ModelsSection({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const currentSlot = activeModels?.active_llm;
|
const currentSlot = activeModels?.active_llm;
|
||||||
|
const currentProviderId = currentSlot?.provider_id;
|
||||||
|
const currentModel = currentSlot?.model;
|
||||||
|
|
||||||
const eligible = useMemo(
|
const eligible = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -70,12 +72,12 @@ export function ModelsSection({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentSlot) {
|
if (currentProviderId || currentModel) {
|
||||||
setSelectedProviderId(currentSlot.provider_id || undefined);
|
setSelectedProviderId(currentProviderId || undefined);
|
||||||
setSelectedModel(currentSlot.model || undefined);
|
setSelectedModel(currentModel || undefined);
|
||||||
}
|
}
|
||||||
setDirty(false);
|
setDirty(false);
|
||||||
}, [currentSlot?.provider_id, currentSlot?.model]);
|
}, [currentProviderId, currentModel]);
|
||||||
|
|
||||||
const chosenProvider = providers.find((p) => p.id === selectedProviderId);
|
const chosenProvider = providers.find((p) => p.id === selectedProviderId);
|
||||||
const modelOptions = chosenProvider?.models ?? [];
|
const modelOptions = chosenProvider?.models ?? [];
|
||||||
|
|||||||
Reference in New Issue
Block a user