You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is not a service-worker or backend problem. The only broken seam is the notification gate, which still treats document.hidden as the only background signal.
The repo already has several stream safety paths tied to real Page Visibility state, so the desktop host needs a second, notification-only background signal instead of spoofing hidden state.
That makes the right fix small: add the host setter, widen the notification gate, and prove that stream visibility logic stays untouched.
What Changed
static/messages.js: added a desktop-owned notification-only background flag and setter, then used it only in the browser-notification gate.
tests/test_pwa_notification_controls.py: kept the existing notification control coverage and added guards that the new desktop flag stays out of SSE hidden-state helpers.
tests/test_issue4753_desktop_background_notifications.py: added focused runtime coverage for backgrounded visible tabs, focused visible tabs, real hidden tabs, and forceHidden.
Why It Matters
Background desktop tabs can now fire approval, clarify, and completion notifications without pretending the page is hidden. That keeps the desktop notification gap closed without risking the live SSE behavior that background tabs depend on.
This PR fixes #4753 by introducing a desktop-shell-owned background signal that is entirely separate from the Page Visibility API, so desktop tabs can receive approval, clarify, and completion notifications while remaining visibly open. The stream-visibility and SSE reconnection paths are untouched.
static/messages.js: adds window.__hermesSetBackgrounded, _isBackgroundedForBrowserNotification(), and _shouldForceCompletionNotification which atomically reads and clears both tracker entries; all non-done terminal stream paths now call _clearStreamNotificationBackground.
tests/test_pwa_notification_controls.py: updated assertions to match refactored names and adds an isolation guard verifying notification-only symbols never appear in stream-visibility code.
Confidence Score: 5/5
Safe to merge — the change introduces an additive, desktop-shell-gated notification path with no modifications to stream visibility, SSE, or reconnection logic.
The new flag and its setter are entirely isolated from document.hidden checks that govern stream behavior. The STREAM_NOTIFICATION_BACKGROUND tracker mirrors the well-tested STREAM_WAS_HIDDEN pattern and is cleaned up on every terminal path. Runtime tests confirm gate logic end-to-end.
No files require special attention.
Important Files Changed
Filename
Overview
static/messages.js
Adds desktop-notification-only flag and setter, refactors completion gate into _shouldForceCompletionNotification, adds _clearStreamNotificationBackground on all terminal paths.
Shipped in v0.51.612 🚀 — thanks @rodboev. Background desktop-app tabs now fire OS notifications without closing their live stream. Codex+Opus SAFE (the notification-only flag leaves all document.hidden stream/SSE logic untouched) + full suite 10307.
Merged into master + shipped in v0.51.612 (release PR #4802). Closing — GitHub didn't auto-detect the merge because the release stage's CHANGELOG rebase changed the commit. Thanks again @rodboev!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
document.hiddenas the only background signal.What Changed
static/messages.js: added a desktop-owned notification-only background flag and setter, then used it only in the browser-notification gate.tests/test_pwa_notification_controls.py: kept the existing notification control coverage and added guards that the new desktop flag stays out of SSE hidden-state helpers.tests/test_issue4753_desktop_background_notifications.py: added focused runtime coverage for backgrounded visible tabs, focused visible tabs, real hidden tabs, andforceHidden.Why It Matters
Background desktop tabs can now fire approval, clarify, and completion notifications without pretending the page is hidden. That keeps the desktop notification gap closed without risking the live SSE behavior that background tabs depend on.
Verification
Full-suite CI context, not a required local check unless requested:
pytest tests/ -v --timeout=60.Upstream
Closes #4753.
Model Used
GPT 5.5 via Codex CLI