Conversation
…stays, live status, test, reach - One origin: a browser navigation at 127.x/[::1]:<port> redirects to http://localhost:<port>/ (permission is per origin); APIs, the door, MCP, the tailnet and other names are never redirected. A canonicalUrl seam for the fixed-address prototype (#1945). - The line above the list stays until resolved: 'moved' (allowed at another address, none here) at once with Allow; 'ask' once there is a thread; 'blocked' quiet, pointing at Settings. - Live permission (change event + focus/visibility), Settings status, Allow, blocked steps, Send a test notification with the macOS hint. - The server counts open windows and which may notify (notify_reach on health, settings and an SSE 'reach' frame; POST /api/inbox/window). - Last-Event-ID wins over the URL cursor on reconnect; a discarded or long- frozen tab says so; a tab without permission claims nothing. Co-Authored-By: Claude <noreply@anthropic.com>
- A reconnecting tab reports its permission again on every hello (the stream URL's permission= can be stale past the grace or after a restart), without the page's serverSession so it reaches a restarted Inbox. - reach frames only on streams with a window= id (never the phone's door). - Last-Event-ID counts only when it is a non-negative whole number; else the URL's cursor. - Drop the unused canonicalUrl seam (the fixed-address prototype can add it). Co-Authored-By: Claude <noreply@anthropic.com>
…ns; the moved line says to reload or close the old tab; 7.9 says Last-Event-ID wins over ?cursor=
1 task
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
The owner rarely got Chrome notifications from the Inbox. His Inbox's settings showed
notifications: { enabled: true, allowed_origin: "http://127.0.0.1:59812" }, while the Inbox advertises and openshttp://localhost:59812/. Chrome grants notification permission per scheme+host+port, so the page atlocalhost:59812had no permission (default), and the one-time "allow again" line only appeared when a question arrived while the page was open, then never again after a reload. Notifications were off, silently.Owner's requirement: notifications must always work, deterministically, and never fail silently. This PR detects every way they fail silently, and fixes or plainly shows each. Which events notify is unchanged.
What changes
1. Origin drift (fixed / shown prominently)
/at another loopback spelling of this port (127.x.y.z,[::1]) answers307tohttp://localhost:<port>/with its query; the browser keeps the#thread=fragment (packages/server/inbox-canonical.ts). localhost is canonical because it is what the Inbox already opens and advertises, what every thread link agents get uses, and the spelling plan review / code review share their cookies on. Never redirected: APIs, the device door, MCP, connection routes, frames, clients without fetch metadata, the tailnet listener, another port's spelling, any non-literal name (the prototype'sinbox.plannotator.localhost,PLANNOTATOR_ALLOWED_HOSTSnames).allowedOrigin), a prominent "Notifications are off at this address … Allow" line shows at once, on every load, until answered. The plain ask (never asked here) also stays on every load once the Inbox holds a thread; a blocked address gets a quiet line pointing at Settings. A grant made in Chrome's site settings while the page is open recordsallowedOrigin.2. No tab open (shown; a fallback is a decision, see the design note)
window=<id>) and whether each one's browser allows notifications (POST /api/inbox/window, live on change).notify_reach: { enabled, windows, allowed, allowed_origins }rides/api/inbox/health,/api/inbox/settingsand anevent: reachframe.hello(a reconnect's URL carries the permission it first had; after the 15 s grace or an Inbox restart that would be stale), without the page's serverSession so it reaches a restarted Inbox.event: reachgoes only to streams with awindow=id, never the phone's door (contract 7.9).3. Background tabs
Page.setWebLifecycleState: frozen), sends a question, resumes, and the notice is raised once.cursorthe URL was opened with instead ofLast-Event-ID, replaying everything since page load. A usable header (a non-negative whole number) now wins; an empty or malformed one falls back to the cursor. So a tab whose connection dropped catches up from where it was and raises what it missed.document.wasDiscarded) or froze for a minute or more says so once, with how to keeplocalhostalways active.4. Several tabs / stale tabs
5. Live status and a test
changeevent + a fresh read on focus/visibility).On for this address,Off,Not allowed in Chrome for this addresswith Allow,Blocked in Chrome for this addresswith Chrome's own steps for this address; Send a test notification (own tag, never replaces a real notice) with "Didn't see it? Check System Settings → Notifications → Google Chrome, and Focus." No new keyboard shortcuts.Design note: notifying with no Inbox tab open (for the owner to decide)
(The note was meant for
.product/drafts/inbox-notify-deterministic/NOTE.mdin the main checkout; this agent could not write outside its worktree, so it is here in full.)The server now knows the exact moment no tab can notify (
notify_reach.allowed === 0when a question arrives), so any fallback below can fire only then, with no duplicates.Notification(no push). A service worker only runs when an event wakes it; with no tab open nothing does (Periodic Background Sync needs an installed PWA and fires at the browser's discretion, hours apart). Not viable alone.http://localhostis a secure context. Needs the internet and a third-party push service (payload end-to-end encrypted), and a fixed origin (subscription is per origin: PROTOTYPE: one-click fixed address for the Inbox (portless) — do not merge #1945 or a fixed port).UNUserNotificationCenter, its own permission and icon, offline, no browser/tab/origin involved, click opens the thread. Needs Developer ID signing + notarization. Linuxnotify-sendand a Windows toast have the same shape.osascript display notification. Zero install; but attributed to Script Editor (its permission and icon), click opens Script Editor not the thread, no replace-by-tag, no actions. A stop-gap only.Recommendation: merge this; land the fixed address (#1945) to end port drift (any browser-side option needs a stable origin anyway); for "no tab open", a server-side fallback fired only when
allowed === 0: the native macOS helper (3), withosascript(4) as a labelled interim if acceptable, andnotify-send/ Windows toast on those systems. Web Push (2) + PWA (5) only if a browser-only answer is preferred and the internet dependency is acceptable. Open question: is theosascriptinterim acceptable until the helper is signed?Tests
packages/server/inbox-notify-origin.test.ts: the redirect (127.x, [::1], query kept) and everything not redirected (no fetch metadata, frames, HEAD, APIs, the door, MCP, other names, other ports, the tailnet); window counting, a reconnect past the grace with a stale URL put right by the report, reach frames only for windows, unusable Last-Event-ID falling back to the cursor, live reports, grace, the switch off; validation and the stale-tab / cross-site guards; Last-Event-ID resumes.packages/inbox/notify.test.ts(askKind, the owner's case),notifyStatus.test.ts(status words, blocked steps, the test hint, reach),notifyHook.test.tsx(no claim without permission, live re-read, the ask staying, the test notice, frozen/discarded, the window report),notificationStates.test.tsx(DOM: each line, Settings status, Allow, steps, test, reach).tests/e2e/notifications.spec.tson the compiled binary: the ask stays across a reload, 127.0.0.1 lands on localhost with its#thread, Settings status / test / reach, "moved" at once after a port change with Allow, an Inbox restart under an open tab (the tab reconnects and reportsgrantedagain), a frozen tab raises what arrived as it wakes, once.inbox-devices.test.ts: health's key list gains the additivenotify_reach(contract 7.4 updated).