Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(site): add webpush notification serviceworker#17123

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 8 commits intomainfromcj/push-notifications-2-site
Mar 27, 2025

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedMar 26, 2025
edited
Loading

Based on#17091

Original changes fromhttps://github.com/coder/coder/commits/kyle/tasks/

  • Improves tests for webpush notifications
  • Sets subscriber correctly in web push payload (without this, notifications do not work in Safari)
    • NOTE: for now, I'm using the Coder Access URL. Some push messaging service don't like it when you use a non-HTTPS URL, so dropping a warn log about this.
  • Adds a service worker and context for push notifications
  • Adds a button beside "Inbox" to enable / disable push notifications

Notes:

  • ✅ Tested in in Firefox and Safari, and Chrome.

@johnstcnjohnstcn self-assigned thisMar 26, 2025
@johnstcnjohnstcn changed the titlesite changes from cj/push-notifications-2-rebaseWIP feat(site): add webpush notification serviceworkerMar 26, 2025
@johnstcnjohnstcn changed the titleWIP feat(site): add webpush notification serviceworkerWIP: feat(site): add webpush notification serviceworkerMar 26, 2025

{enabled ?(
subscribed ?(
<Buttonvariant="outline"disabled={loading}onClick={unsubscribe}>
Copy link
Member

Choose a reason for hiding this comment

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

Is it just for experimental purposes? Dropping a button on NavBar may look inconsistent. If this is permanent, perhaps ask Bruno for his guidance.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yep, just for experimental. We'll need to better integrate this later.

Base automatically changed fromcj/push-notifications-2-rebase tomainMarch 27, 2025 10:03
@johnstcnjohnstcnforce-pushed thecj/push-notifications-2-site branch from81b8c6e to58cc953CompareMarch 27, 2025 10:07
@johnstcnjohnstcn changed the titleWIP: feat(site): add webpush notification serviceworkerfeat(site): add webpush notification serviceworkerMar 27, 2025
@johnstcnjohnstcn requested a review fromCopilotMarch 27, 2025 16:41
Copy link
Contributor

@CopilotCopilotAI 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 webpush notification support by implementing a dedicated service worker and integrating related API and UI changes. Key changes include:

  • Bundling and serving the service worker through Vite with proper proxy configuration
  • Implementing the webpush notifications logic, including subscription management via a new React hook and API endpoints
  • Updating tests to verify proper webpush payload handling and functionality

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
site/vite.config.mtsConfigures service worker bundling and proxy endpoints
site/src/testHelpers/entities.tsUpdates mock build info to include a webpush public key
site/src/serviceWorker.tsImplements service worker logic for push and notification click events
site/src/modules/dashboard/Navbar/NavbarView.tsxAdds buttons to enable/disable webpush notifications
site/src/index.tsxRegisters the service worker for push notifications
site/src/contexts/useWebpushNotifications.tsImplements a hook for managing webpush subscriptions
site/src/api/api.tsIntroduces API methods for creating and deleting webpush subscriptions
coderd/webpush/webpush_test.goUpdates tests with random notifications and payload assertions
coderd/webpush/webpush.goModifies the dispatcher to include a VAPID subscriber and logs errors with endpoint details
coderd/coderdtest/coderdtest.goUpdates test setup for the webpush dispatcher with the proper subscriber URL
cli/server.goIntegrates a check for HTTPS access URLs before initializing webpush notifications
Comments suppressed due to low confidence (1)

coderd/webpush/webpush_test.go:239

  • [nitpick] The parameters for assert.Equal are inverted. Swap the arguments so that the expected value comes first to improve error messages and consistency.
assert.Equal(t, r.Header.Get("content-encoding"), "aes128gcm")

@johnstcnjohnstcn merged commite1f27a7 intomainMar 27, 2025
39 checks passed
@johnstcnjohnstcn deleted the cj/push-notifications-2-site branchMarch 27, 2025 17:30
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 27, 2025
@stirby
Copy link
Collaborator

/cherry-pick release/2.21

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

Copilot code reviewCopilotCopilot left review comments

@mtojekmtojekmtojek approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@johnstcn@stirby@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp