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]);
|
||||
|
||||
useEffect(() => {
|
||||
if (liveChatStatus) {
|
||||
if (liveChatStatus?.requestId) {
|
||||
forceFollowUntilRef.current = Date.now() + 15_000;
|
||||
scrollChatToBottom(chatStageRef.current);
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -72,7 +72,7 @@ function HeartbeatPage() {
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [form] = Form.useForm<HeartbeatFormValues>();
|
||||
|
||||
const fetchConfig = async () => {
|
||||
const fetchConfig = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await api.getHeartbeatConfig();
|
||||
@@ -92,11 +92,11 @@ function HeartbeatPage() {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
}, [form, t]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchConfig();
|
||||
}, []);
|
||||
}, [fetchConfig]);
|
||||
|
||||
const onFinish = async (values: HeartbeatFormValues) => {
|
||||
const every =
|
||||
|
||||
@@ -178,7 +178,7 @@ function EnvironmentsPage() {
|
||||
onOk: doRemove,
|
||||
});
|
||||
},
|
||||
[workingRows, ensureLocal, envVars.length],
|
||||
[workingRows, ensureLocal, envVars.length, t],
|
||||
);
|
||||
|
||||
const removeSelected = useCallback(() => {
|
||||
@@ -211,7 +211,7 @@ function EnvironmentsPage() {
|
||||
cancelText: t("common.cancel"),
|
||||
onOk: doRemove,
|
||||
});
|
||||
}, [selected, workingRows, ensureLocal, envVars.length]);
|
||||
}, [selected, workingRows, ensureLocal, envVars.length, t]);
|
||||
|
||||
/* ---- validate & save ---- */
|
||||
|
||||
@@ -231,7 +231,7 @@ function EnvironmentsPage() {
|
||||
}
|
||||
setKeyErrors(errors);
|
||||
return Object.keys(errors).length === 0;
|
||||
}, [workingRows]);
|
||||
}, [workingRows, t]);
|
||||
|
||||
const handleSave = useCallback(async () => {
|
||||
if (!validate()) return;
|
||||
@@ -254,7 +254,7 @@ function EnvironmentsPage() {
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}, [validate, workingRows, fetchAll]);
|
||||
}, [validate, workingRows, fetchAll, t]);
|
||||
|
||||
const handleReset = useCallback(() => {
|
||||
setRows(null);
|
||||
|
||||
@@ -44,6 +44,8 @@ export function ModelsSection({
|
||||
);
|
||||
|
||||
const currentSlot = activeModels?.active_llm;
|
||||
const currentProviderId = currentSlot?.provider_id;
|
||||
const currentModel = currentSlot?.model;
|
||||
|
||||
const eligible = useMemo(
|
||||
() =>
|
||||
@@ -70,12 +72,12 @@ export function ModelsSection({
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentSlot) {
|
||||
setSelectedProviderId(currentSlot.provider_id || undefined);
|
||||
setSelectedModel(currentSlot.model || undefined);
|
||||
if (currentProviderId || currentModel) {
|
||||
setSelectedProviderId(currentProviderId || undefined);
|
||||
setSelectedModel(currentModel || undefined);
|
||||
}
|
||||
setDirty(false);
|
||||
}, [currentSlot?.provider_id, currentSlot?.model]);
|
||||
}, [currentProviderId, currentModel]);
|
||||
|
||||
const chosenProvider = providers.find((p) => p.id === selectedProviderId);
|
||||
const modelOptions = chosenProvider?.models ?? [];
|
||||
|
||||
Reference in New Issue
Block a user