Skip to content

feat(ui): restore task completion notification for desktop app#6424

Closed
blackgirlbytes wants to merge 3 commits intomainfrom
feat/task-completion-notification
Closed

feat(ui): restore task completion notification for desktop app#6424
blackgirlbytes wants to merge 3 commits intomainfrom
feat/task-completion-notification

Conversation

@blackgirlbytes
Copy link
Contributor

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 in onStreamFinish callback

    • Only notify when document.hasFocus() returns false (user is in another app)
    • Uses existing window.electron.showNotification infrastructure
  • ui/desktop/src/components/TaskCompletionNotification.test.tsx: New test file with 5 tests

    • Tests notification is shown when window not focused
    • Tests notification is NOT shown when window is focused
    • Tests notification content (title: 'Goose', body: 'Task completed')

Testing

  • All 5 new tests pass
  • Lint checks pass
  • TypeScript compilation passes

How to manually test

  1. Build and run the desktop app
  2. Send a message to Goose
  3. Minimize the window or switch to another app
  4. Wait for Goose to complete
  5. You should see a native OS notification: "Goose - Task completed"

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
Copilot AI review requested due to automatic review settings January 9, 2026 20:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 onStreamFinish callback 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
@blackgirlbytes
Copy link
Contributor Author

Screenshot 2026-01-09 at 4 29 12 PM

@blackgirlbytes blackgirlbytes requested a review from a team as a code owner January 9, 2026 21:30
Copilot AI review requested due to automatic review settings January 9, 2026 21:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@blackgirlbytes blackgirlbytes force-pushed the feat/task-completion-notification branch from ce54844 to e588219 Compare January 9, 2026 21:31
@blackgirlbytes blackgirlbytes changed the title feat(ui): add task completion notification for desktop app feat(ui): restore task completion notification for desktop app Jan 9, 2026
@blackgirlbytes blackgirlbytes requested a review from zanesq January 9, 2026 21:32
// Store original hasFocus
originalHasFocus = document.hasFocus;

// Mock window.electron.showNotification
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Mock window.electron.showNotification

beforeEach(() => {
mockShowNotification = vi.fn();

// Store original hasFocus
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Store original hasFocus


afterEach(() => {
vi.clearAllMocks();
// Restore original hasFocus
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Restore original hasFocus

@@ -0,0 +1,8 @@
export function notifyTaskCompletion(): void {
if (!document.hasFocus()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@blackgirlbytes
Copy link
Contributor Author

closing this PR for #6427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants