Restore task completion notification (#6427)

This commit is contained in:
Rizel Scarlett
2026-01-09 18:44:31 -05:00
committed by GitHub
parent 350ab4b96a
commit 40747ebac9
+14
View File
@@ -170,6 +170,7 @@ export function useChatStream({
});
const [notifications, setNotifications] = useState<NotificationEvent[]>([]);
const abortControllerRef = useRef<AbortController | null>(null);
const lastInteractionTimeRef = useRef<number>(Date.now());
useEffect(() => {
if (session) {
@@ -192,6 +193,14 @@ export function useChatStream({
setSessionLoadError(error);
}
const timeSinceLastInteraction = Date.now() - lastInteractionTimeRef.current;
if (!error && timeSinceLastInteraction > 60000) {
window.electron.showNotification({
title: 'goose finished the task.',
body: 'Click here to expand.',
});
}
const isNewSession = sessionId && sessionId.match(/^\d{8}_\d{6}$/);
if (isNewSession) {
console.log(
@@ -294,6 +303,8 @@ export function useChatStream({
return;
}
lastInteractionTimeRef.current = Date.now();
// Emit session-created event for first message in a new session
if (!hasExistingMessages && hasNewMessage) {
window.dispatchEvent(new CustomEvent('session-created'));
@@ -352,6 +363,8 @@ export function useChatStream({
return;
}
lastInteractionTimeRef.current = Date.now();
const responseMessage = createElicitationResponseMessage(elicitationId, userData);
const currentMessages = [...messagesRef.current, responseMessage];
@@ -431,6 +444,7 @@ export function useChatStream({
const stopStreaming = useCallback(() => {
abortControllerRef.current?.abort();
setChatState(ChatState.Idle);
lastInteractionTimeRef.current = Date.now();
}, []);
const onMessageUpdate = useCallback(