Skip to content

fix( frontend) :notification permission refresh - #3768

Merged
WillemJiang merged 1 commit into
bytedance:mainfrom
zwj110610:fix/notification-permission-refresh
Jun 25, 2026
Merged

fix( frontend) :notification permission refresh#3768
WillemJiang merged 1 commit into
bytedance:mainfrom
zwj110610:fix/notification-permission-refresh

Conversation

@zwj110610

Copy link
Copy Markdown
Contributor

Fixes #3767

Why

Browser notifications could be skipped after a user enabled notification permission in Settings.

The root cause is that useNotification() stores permission state per hook instance. When Settings requests permission, another hook instance used by the chat/agent page can still hold the stale "default" state and refuse to send notifications until the page is refreshed.

There was also a first-notification timing edge case: lastNotificationTime was initialized at hook creation time, so a valid notification sent immediately after the hook mounted could be incorrectly throttled.

What changed

  • Notification sending now reads the browser's current Notification.permission before deciding whether to send.
  • The hook syncs its local permission state if the browser permission has changed.
  • First notification throttling now only applies after a notification has actually been sent.
  • Added unit tests covering:
    • first notification can be sent immediately;
    • rate limiting starts only after a successful send;
    • browser permission changes from another hook instance are respected.
  • Added Playwright coverage for notification settings/test-notification behavior.
  • Added an accessible label to the notification settings switch.

Surface area

  • Frontend UI — page / component / setting / interaction under frontend/
  • Backend API — endpoint / SSE event / request-response shape under backend/app
  • Agents / LangGraph — agent node, graph wiring, langgraph.json, or prompt change
  • Sandboxdocker/ or sandboxed execution
  • Skills — change under skills/
  • Dependencies — new/upgraded entry in backend/pyproject.toml or frontend/package.json (say what it buys us)
  • Default behavior change — notifications now use the browser's latest permission state when sending
  • Docs / tests / CI only — no runtime behavior change

Screenshots / Recording

N/A. This is a notification behavior fix; the visible Settings UI is unchanged.

Bug fix verification

Test path that reproduces the bug:

  • frontend/tests/unit/core/notification/hooks.test.ts

Before the fix, the notification hook tests fail against the old behavior:

  • the first notification can be rejected as Notification sent too soon;
  • a hook instance can keep stale "default" permission after another hook grants browser permission.

After the fix, the same tests pass.

Validation

cd frontend && pnpm test tests/unit/core/notification/hooks.test.ts
cd frontend && pnpm typecheck

AI assistance

Tool(s) used: codex

How you used it: AI helps with testing and code review.

  • I've read and understand every line of this change and take responsibility for it — it's not unreviewed AI output.

@github-actions github-actions Bot added area:frontend Next.js frontend under frontend/ risk:medium Medium risk: regular code changes size/M PR changes 100-300 lines labels Jun 24, 2026
@zwj110610 zwj110610 changed the title fix frontend notification permission refresh fix( frontend) :notification permission refresh Jun 24, 2026
@WillemJiang WillemJiang added this to the 2.1.0 milestone Jun 25, 2026
@WillemJiang
WillemJiang merged commit 69cf4f4 into bytedance:main Jun 25, 2026
13 checks passed
@yong326 yong326 mentioned this pull request Jun 26, 2026
2 tasks
yydspanda pushed a commit to yydspanda/deer-flow that referenced this pull request Jun 28, 2026
marvin9551 pushed a commit to marvin9551/deer-flow that referenced this pull request Aug 21, 2026
jihtsan pushed a commit to jihtsan/dnx-deer-flow that referenced this pull request Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Next.js frontend under frontend/ risk:medium Medium risk: regular code changes size/M PR changes 100-300 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Notification may not fire after enabling browser permission in Settings

2 participants