refactor(copilot): convert stop to plain function declaration

Remove useCallback wrapper per project guidelines — stopRef.current
captures the latest closure on every render regardless.
This commit is contained in:
Zamil Majdy
2026-02-20 02:25:43 +07:00
parent b6064d0155
commit f8ad8484ee

View File

@@ -112,7 +112,7 @@ export function useCopilotPage() {
// Wrap AI SDK's stop() to also cancel the backend executor task.
// sdkStop() aborts the SSE fetch instantly (UI feedback), then we fire
// the cancel API to actually stop the executor and wait for confirmation.
const stop = useCallback(async () => {
async function stop() {
sdkStop();
// Mark any in-progress tool parts as errored so spinners stop.
@@ -138,7 +138,7 @@ export function useCopilotPage() {
variant: "destructive",
});
}
}, [sdkStop, sessionId, setMessages]);
}
// Abort the stream if the backend doesn't start sending data within 12s.
const stopRef = useRef(stop);