feat(ui): restore task completion notification for desktop app#6424
feat(ui): restore task completion notification for desktop app#6424blackgirlbytes wants to merge 3 commits intomainfrom
Conversation
When Goose finishes a task, show a native OS notification if the window is not focused. This helps users who switch to other apps while waiting for Goose to complete. - Add notification trigger in BaseChat.tsx onStreamFinish callback - Only notify when document.hasFocus() returns false - Add test file with 5 tests covering notification behavior
There was a problem hiding this comment.
Pull request overview
This PR adds native OS notifications when goose completes a task, but only if the application window is not focused. This allows users to be notified when they've switched to other applications while waiting for goose to finish.
Key Changes:
- Added notification trigger in BaseChat's
onStreamFinishcallback that checks window focus - Created test suite with focus state verification and notification content validation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ui/desktop/src/components/BaseChat.tsx | Implements task completion notification in onStreamFinish callback, checking document.hasFocus() before showing notification |
| ui/desktop/src/components/TaskCompletionNotification.test.tsx | New test file with tests for notification behavior based on window focus state |
- Move notification logic from inline callback to utils/taskCompletionNotification.ts - Update BaseChat.tsx to import and use the utility function - Move test file to utils/ and test the actual function (not duplicated logic) - Remove redundant tests, keep only 2 essential tests This addresses code review feedback: - Tests now import and test the actual function, not duplicated logic - Removed redundant tests that were already covered
ce54844 to
e588219
Compare
| // Store original hasFocus | ||
| originalHasFocus = document.hasFocus; | ||
|
|
||
| // Mock window.electron.showNotification |
There was a problem hiding this comment.
| // Mock window.electron.showNotification |
| beforeEach(() => { | ||
| mockShowNotification = vi.fn(); | ||
|
|
||
| // Store original hasFocus |
There was a problem hiding this comment.
| // Store original hasFocus |
|
|
||
| afterEach(() => { | ||
| vi.clearAllMocks(); | ||
| // Restore original hasFocus |
There was a problem hiding this comment.
| // Restore original hasFocus |
| @@ -0,0 +1,8 @@ | |||
| export function notifyTaskCompletion(): void { | |||
| if (!document.hasFocus()) { | |||
There was a problem hiding this comment.
any reason why you didn't restore the original implementation?
const timeSinceLastInteraction = Date.now() - lastInteractionTime;
if (timeSinceLastInteraction > 60000) {
try {
window.electron.showNotification({
title: 'Goose finished the task',
body: 'Click here for details',
});
} catch (error) {
console.error('Failed to show notification:', error);
}
}
There was a problem hiding this comment.
hmm yeah i dont like that it didnt restore it easier. I think goose did too much. Closing this PR for a better one here: #6427
|
closing this PR for #6427 |

Summary
When Goose finishes a task, show a native OS notification if the window is not focused. This helps users who switch to other apps while waiting for Goose to complete.
Changes
ui/desktop/src/components/BaseChat.tsx: Add notification trigger inonStreamFinishcallbackdocument.hasFocus()returnsfalse(user is in another app)window.electron.showNotificationinfrastructureui/desktop/src/components/TaskCompletionNotification.test.tsx: New test file with 5 testsTesting
How to manually test