Restore task completion notification (#6427)
This commit is contained in:
@@ -170,6 +170,7 @@ export function useChatStream({
|
|||||||
});
|
});
|
||||||
const [notifications, setNotifications] = useState<NotificationEvent[]>([]);
|
const [notifications, setNotifications] = useState<NotificationEvent[]>([]);
|
||||||
const abortControllerRef = useRef<AbortController | null>(null);
|
const abortControllerRef = useRef<AbortController | null>(null);
|
||||||
|
const lastInteractionTimeRef = useRef<number>(Date.now());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (session) {
|
if (session) {
|
||||||
@@ -192,6 +193,14 @@ export function useChatStream({
|
|||||||
setSessionLoadError(error);
|
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}$/);
|
const isNewSession = sessionId && sessionId.match(/^\d{8}_\d{6}$/);
|
||||||
if (isNewSession) {
|
if (isNewSession) {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -294,6 +303,8 @@ export function useChatStream({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastInteractionTimeRef.current = Date.now();
|
||||||
|
|
||||||
// Emit session-created event for first message in a new session
|
// Emit session-created event for first message in a new session
|
||||||
if (!hasExistingMessages && hasNewMessage) {
|
if (!hasExistingMessages && hasNewMessage) {
|
||||||
window.dispatchEvent(new CustomEvent('session-created'));
|
window.dispatchEvent(new CustomEvent('session-created'));
|
||||||
@@ -352,6 +363,8 @@ export function useChatStream({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastInteractionTimeRef.current = Date.now();
|
||||||
|
|
||||||
const responseMessage = createElicitationResponseMessage(elicitationId, userData);
|
const responseMessage = createElicitationResponseMessage(elicitationId, userData);
|
||||||
const currentMessages = [...messagesRef.current, responseMessage];
|
const currentMessages = [...messagesRef.current, responseMessage];
|
||||||
|
|
||||||
@@ -431,6 +444,7 @@ export function useChatStream({
|
|||||||
const stopStreaming = useCallback(() => {
|
const stopStreaming = useCallback(() => {
|
||||||
abortControllerRef.current?.abort();
|
abortControllerRef.current?.abort();
|
||||||
setChatState(ChatState.Idle);
|
setChatState(ChatState.Idle);
|
||||||
|
lastInteractionTimeRef.current = Date.now();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onMessageUpdate = useCallback(
|
const onMessageUpdate = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user