Skip to content

feat(coderd): add webpush package #17091

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

Merged
merged 40 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a980379
wip
kylecarbs Mar 17, 2025
bc02200
fix migration number
johnstcn Mar 25, 2025
2ecae9d
make fmt
johnstcn Mar 25, 2025
84e3ace
fix tests
johnstcn Mar 25, 2025
377eaab
add cli command to regenerate vapid keypair and remove existing subsc…
johnstcn Mar 25, 2025
982acef
remove dbauthz system usage
johnstcn Mar 25, 2025
d82073e
add test endpoint for push notifications
johnstcn Mar 25, 2025
fc59c70
make linter happy
johnstcn Mar 25, 2025
cbff3ca
test push notifications endpoint
johnstcn Mar 25, 2025
9e7e1dc
add deployment config for push notifications
johnstcn Mar 25, 2025
1315a46
add test for push notifications being enabled
johnstcn Mar 25, 2025
85db78c
rename migration
johnstcn Mar 25, 2025
892388a
skip vapid keypair test on non-postgres;
johnstcn Mar 25, 2025
e600b7d
fix some tests
johnstcn Mar 25, 2025
eef2038
hide subscribe button
johnstcn Mar 25, 2025
46f7519
conditionally hide push notification button
johnstcn Mar 25, 2025
4408090
Revert "conditionally hide push notification button"
johnstcn Mar 25, 2025
204ab4a
fix data race caused by webpush-go mutating msg []byte
johnstcn Mar 25, 2025
0535ed6
Remove deployment config for push notifications in favour of Experime…
johnstcn Mar 26, 2025
9f1f4f9
push notification -> webpush
johnstcn Mar 26, 2025
29bba04
notification -> webpush
johnstcn Mar 26, 2025
46c2cd8
move to webpush package
johnstcn Mar 26, 2025
960c5db
webpush: refactor notification test and send logic
johnstcn Mar 26, 2025
aa22161
move endpoints under webpush beside notifications
johnstcn Mar 26, 2025
57d84a9
skip apidocgen for push notification endpoints
johnstcn Mar 26, 2025
ef22b35
make webpush endpoints 404 if experiment not enabled
johnstcn Mar 26, 2025
9a1a605
auth on test notification endpoint
johnstcn Mar 26, 2025
e8b6083
fix ts
johnstcn Mar 26, 2025
5331f9c
ui fixes
johnstcn Mar 26, 2025
449f882
fixup migrations
johnstcn Mar 26, 2025
e5fd00e
fix check_unstaged.sh again
johnstcn Mar 26, 2025
bcf108a
make bee jenn
johnstcn Mar 26, 2025
eb7b102
address comments
johnstcn Mar 26, 2025
9b5ed09
address more comments + renaming
johnstcn Mar 26, 2025
c06558e
move out check_unstaged.sh changes to separate PR
johnstcn Mar 26, 2025
10ac9fb
remove site changes
johnstcn Mar 26, 2025
a114ddb
fixup! remove site changes
johnstcn Mar 26, 2025
ca72676
nits
johnstcn Mar 27, 2025
3b1dc70
make gen
johnstcn Mar 27, 2025
12808f1
gen
johnstcn Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove deployment config for push notifications in favour of Experime…
…ntWebPush
  • Loading branch information
johnstcn committed Mar 26, 2025
commit 0535ed6c9ee7e950208e4c1508c9effa0e747994
5 changes: 3 additions & 2 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
}

// Manage push notifications.
if options.DeploymentValues.Notifications.Push.Enabled {
experiments := coderd.ReadExperiments(options.Logger, options.DeploymentValues.Experiments.Value())
if experiments.Enabled(codersdk.ExperimentWebPush) {
pushNotifier, err := push.New(ctx, &options.Logger, options.Database)
if err != nil {
options.Logger.Error(ctx, "failed to create push notifier", slog.Error(err))
Expand All @@ -789,7 +790,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
options.PushNotifier = pushNotifier
} else {
options.PushNotifier = &push.NoopNotifier{
Msg: "Push notifications are not configured.",
Msg: "Push notifications are disabled. Enable the 'web-push' experiment to use this feature.",
}
}

Expand Down
5 changes: 3 additions & 2 deletions cli/server_regenerate_vapid_keypair.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ func (r *RootCmd) newRegenerateVapidKeypairCommand() *serpent.Command {
regenVapidKeypairPgAuth string
)
regenerateVapidKeypairCommand := &serpent.Command{
Use: "regenerate-vapid-keypair",
Short: "Regenerate the VAPID keypair used for push notifications.",
Use: "regenerate-vapid-keypair",
Short: "Regenerate the VAPID keypair used for push notifications.",
Hidden: true, // Hide this command as it's an experimental feature
Handler: func(inv *serpent.Invocation) error {
var (
ctx, cancel = inv.SignalNotifyContext(inv.Context(), StopSignals...)
Expand Down
6 changes: 0 additions & 6 deletions cli/testdata/coder_server_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ SUBCOMMANDS:
postgres-builtin-serve Run the built-in PostgreSQL deployment.
postgres-builtin-url Output the connection URL for the built-in
PostgreSQL deployment.
regenerate-vapid-keypair Regenerate the VAPID keypair used for push
notifications.

OPTIONS:
--allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false)
Expand Down Expand Up @@ -479,10 +477,6 @@ NOTIFICATIONS / INBOX OPTIONS:
--notifications-inbox-enabled bool, $CODER_NOTIFICATIONS_INBOX_ENABLED (default: true)
Enable Coder Inbox.

NOTIFICATIONS / PUSH OPTIONS:
--notifications-push-enabled bool, $CODER_NOTIFICATIONS_PUSH_ENABLED (default: false)
Enable push notifications using VAPID.

NOTIFICATIONS / WEBHOOK OPTIONS:
--notifications-webhook-endpoint url, $CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT
The endpoint to which to send webhooks.
Expand Down
4 changes: 0 additions & 4 deletions cli/testdata/server-config.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,3 @@ notifications:
# How often to query the database for queued notifications.
# (default: 15s, type: duration)
fetchInterval: 15s
push:
# Enable push notifications using VAPID.
# (default: false, type: bool)
enabled: false
23 changes: 5 additions & 18 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 5 additions & 18 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 1 addition & 21 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,6 @@ type NotificationsConfig struct {
Webhook NotificationsWebhookConfig `json:"webhook" typescript:",notnull"`
// Inbox settings.
Inbox NotificationsInboxConfig `json:"inbox" typescript:",notnull"`
// Push notification settings.
Push NotificationsPushConfig `json:"push" typescript:",notnull"`
}

type NotificationsPushConfig struct {
Enabled serpent.Bool `json:"enabled" typescript:",notnull"`
}

// Are either of the notification methods enabled?
Expand Down Expand Up @@ -1007,11 +1001,6 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
Parent: &deploymentGroupNotifications,
YAML: "inbox",
}
deploymentGroupNotificationsPush = serpent.Group{
Name: "Push",
Parent: &deploymentGroupNotifications,
YAML: "push",
}
)

httpAddress := serpent.Option{
Expand Down Expand Up @@ -2980,16 +2969,6 @@ Write out the current server config as YAML to stdout.`,
Hidden: true, // Hidden because most operators should not need to modify this.
},
// Push notifications.
{
Name: "Notifications: Push: Enabled",
Description: "Enable push notifications using VAPID.",
Flag: "notifications-push-enabled",
Env: "CODER_NOTIFICATIONS_PUSH_ENABLED",
Value: &c.Notifications.Push.Enabled,
Default: "false",
Group: &deploymentGroupNotificationsPush,
YAML: "enabled",
},
}

return opts
Expand Down Expand Up @@ -3214,6 +3193,7 @@ const (
ExperimentAutoFillParameters Experiment = "auto-fill-parameters" // This should not be taken out of experiments until we have redesigned the feature.
ExperimentNotifications Experiment = "notifications" // Sends notifications via SMTP and webhooks following certain events.
ExperimentWorkspaceUsage Experiment = "workspace-usage" // Enables the new workspace usage tracking.
ExperimentWebPush Experiment = "web-push" // Enables web push notifications through the browser.
)

// ExperimentsAll should include all experiments that are safe for
Expand Down
5 changes: 0 additions & 5 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1320,11 +1320,6 @@
"description": "Output the connection URL for the built-in PostgreSQL deployment.",
"path": "reference/cli/server_postgres-builtin-url.md"
},
{
"title": "server regenerate-vapid-keypair",
"description": "Regenerate the VAPID keypair used for push notifications.",
"path": "reference/cli/server_regenerate-vapid-keypair.md"
},
{
"title": "show",
"description": "Display details of a workspace's resources and agents",
Expand Down
3 changes: 0 additions & 3 deletions docs/reference/api/general.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 1 addition & 24 deletions docs/reference/api/schemas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions docs/reference/cli/server.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 0 additions & 39 deletions docs/reference/cli/server_regenerate-vapid-keypair.md

This file was deleted.

Loading