Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add browser notifications #6246

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Add browser notifications #6246

wants to merge 10 commits into from

Conversation

neubig
Copy link
Contributor

@neubig neubig commented Jan 13, 2025

This PR implements a new browser notification service and adds comprehensive test coverage. The changes include:

  1. New notification service (notification.ts):

    • Implements browser notification functionality with proper feature detection
    • Respects user notification preferences via localStorage
    • Handles browser permissions appropriately
    • Provides a clean API for sending notifications
  2. Comprehensive test suite (notification.test.tsx):

    • Tests notification sending when enabled
    • Tests notification suppression when disabled
    • Tests browser permission handling
    • Includes proper mocking of browser APIs and localStorage

Fixes #6236


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:274e7e4-nikolaik   --name openhands-app-274e7e4   docker.all-hands.dev/all-hands-ai/openhands:274e7e4
  -p 3000:3000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  --add-host host.docker.internal:host-gateway \
  -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:c21866d-nikolaik \
  --name openhands-app-c21866d \
  docker.all-hands.dev/all-hands-ai/openhands:c21866d

@neubig neubig changed the title Fix browser notifications tests Add browser notifications Jan 17, 2025
@neubig neubig marked this pull request as draft January 17, 2025 14:42
@neubig neubig self-assigned this Jan 18, 2025
Copy link
Contributor Author

@neubig neubig left a comment

Choose a reason for hiding this comment

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

I think this is implemented correctly, but unfortunately can't confirm notifications on my computer even after.

  1. Running localStorage.setItem("notifications-enabled", "true") in my javascript console.
  2. Enabling notifications through mac settings.
  3. Enabling notifications through chrome settings.
  4. Adding console print statements indicating that the notification was shown.

I'm not sure what's wrong and why I'm not seeing notifications showing up, but if someone else could try (after running steps above) that'd be really helpful.

@neubig neubig requested a review from enyst January 18, 2025 20:20
@neubig neubig marked this pull request as ready for review January 18, 2025 20:20
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.

Browser notification when the agent has finished
3 participants