Skip to content

Record the Push permission answer after a Smart Alert acceptance - #103

Merged
rockwellll merged 6 commits into
mainfrom
smart-alert-permission-result
Nov 6, 2026
Merged

rockwellll merged 6 commits into
mainfrom
smart-alert-permission-result

Conversation

@rockwellll

@rockwellll rockwellll commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

As soon as the browser answers the permission prompt an acceptance opens, the alert posts the answer to the alerts endpoint as granted or denied. Push#subscribe takes an optional onPermission callback that receives the answer before the subscription is created and registered, so a visitor who allows Push and leaves the page mid-registration still counts as a grant. Permission is still requested first, inside the click. When the identity registration that follows a grant succeeds, it also posts registered with the identity id the identities endpoint returned. All three use the section and page saved at the click, so a client-side navigation that shows another section mid-prompt doesn't change them.

  • A prompt closed without an answer leaves permission at default and records nothing.
  • A visitor who had already granted permission (so no prompt appears) records granted.
  • A failed or rejected registration records no registered on that page. The alert keeps the granted acceptance (section and page) in localStorage until the identity is saved. If the page closes or registration fails first, the next page that loads the alert subscribes and registers without asking again, since permission is already granted, and posts registered under the original acceptance. show() waits for it. Only a grant from the alert leaves the mark, so permission given to another tool on the site never subscribes the visitor. WebKit skips its user gesture check in PushManager.subscribe once permission is granted (source), so this works in Safari too.
  • The identity id comes from a clone of the response body, so the response subscribe() returns stays readable.
  • Push#unsubscribe fires a new push:unsubscribed event once the visitor has no subscription (including when there was none), and the alert drops its pending mark on it, so a resume never reverses an opt-out. The resume also re-reads the mark after Push restoration, in case another tab unsubscribed. Documented in docs/push.md.
  • onPermission is typed in index.d.ts and documented in docs/push.md. A call that joins a pending subscribe() is not given the answer.

Needs hellotext/hellotext#6934 deployed before release, otherwise the endpoint answers the new kinds with 422 (the SDK only warns in the console).

Rebuilt lib and dist.

🤖 Generated with Claude Code

Once the permission request an acceptance starts settles, the alert posts
the browser's answer to the alerts endpoint: `granted` or `denied`, read
from Notification.permission. A prompt closed without an answer leaves
permission at default and records nothing, so it stays an acceptance with
no answer. The Smart Alert report uses these to count grants and denials.

Rebuilt lib and dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T14:01:20.672364Z e6179aa New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6709aeb3a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/controllers/alert_controller.js Resolved
rockwellll and others added 4 commits November 6, 2026 10:08
Client-side navigation can show another section while the permission
request is pending, which replaced the controller's section and page
before the answer was recorded. The acceptance's section and page are
now kept for the answer.

Rebuilt lib and dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the identity registration after a grant succeeds, the alert posts a
`registered` interaction with the identity id the identities endpoint
returned, under the acceptance's section and page. It reads a clone of
the response body, so the response subscribe() returns stays readable.
A failed or rejected registration records nothing.

Rebuilt lib and dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The answer used to be posted only after the whole subscription settled:
the service worker, the browser subscription and the identity
registration. A visitor who allowed Push and left the page in that
window counted as having no answer. Push#subscribe now takes an
optional onPermission callback that gets the answer before
subscribing and registering, and the alert posts it from there.
Permission is still requested first, inside the click.

Rebuilt lib and dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the visitor allows Push from the alert, the alert keeps the
acceptance's section and page in localStorage until the Push identity is
saved. If the page closes or registration fails first, the next page that
loads the alert subscribes and registers without asking again, since
permission is already granted, and records `registered` under the
original acceptance. show() waits for it, so the alert doesn't appear
meanwhile.

Only a grant from the alert leaves the mark, so permission the visitor
gave another tool on the site never subscribes them to Hellotext. The
mark is dropped once permission is no longer granted, and a failure
keeps it for the next page. WebKit skips its user gesture check for
PushManager.subscribe once permission is granted, so this works in
Safari too.

Rebuilt lib and dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7a20c47c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/controllers/alert_controller.js Resolved
If the registration after a grant failed, the pending mark stayed, and
a later Hellotext.push.unsubscribe() didn't clear it. Permission stays
granted after unsubscribing, so the next page resubscribed the visitor
without a click, reversing their opt-out.

Push#unsubscribe now fires push:unsubscribed once the visitor has no
subscription, including when there was none to remove, and the alert
drops its mark on it. The resume also re-reads the mark after Push
restoration, in case another tab unsubscribed meanwhile.

Rebuilt lib and dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rockwellll
rockwellll merged commit bb93002 into main Nov 6, 2026
3 checks passed
@rockwellll
rockwellll deleted the smart-alert-permission-result branch November 6, 2026 14:06
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.

1 participant