diff --git a/ui/desktop/src/ChatWindow.tsx b/ui/desktop/src/ChatWindow.tsx index 06cc1ea4f..86932c061 100644 --- a/ui/desktop/src/ChatWindow.tsx +++ b/ui/desktop/src/ChatWindow.tsx @@ -189,6 +189,9 @@ export function ChatContent({ const updatedMessages = [...messages.slice(0, -1), newLastMessage]; setMessages(updatedMessages); } + + // Terminate any background processes + window.electron.terminateBackgroundProcesses(); }; return ( diff --git a/ui/desktop/src/ai-sdk-fork/call-custom-chat-api.ts b/ui/desktop/src/ai-sdk-fork/call-custom-chat-api.ts index 3d7230114..6ac919424 100644 --- a/ui/desktop/src/ai-sdk-fork/call-custom-chat-api.ts +++ b/ui/desktop/src/ai-sdk-fork/call-custom-chat-api.ts @@ -90,3 +90,12 @@ export async function callCustomChatApi({ } } } + +export function stop() { + const abortController = abortController?.(); + if (abortController) { + abortController.abort(); + } + // Terminate any background processes + window.electron.terminateBackgroundProcesses(); +} diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index fc8b128c7..a92416222 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -594,6 +594,8 @@ app.whenReady().then(async () => { log.info('Stopped power save blocker'); return true; } + // Terminate any background processes + window.electron.terminateBackgroundProcesses(); return false; });