Repository navigation
fix(notifications): land alert taps in an app window and off removed PCs - #958
Merged
Merged
Conversation
The service worker focused whichever same-origin window was used last, which could be a Markdown reader (?read=) or a raw file tab that never handles the pane selection. It now keeps app windows only and opens the app otherwise. A tapped alert or a remembered selection naming a PC removed since left an empty pane area. Alerts now go through the link path (resolveLink, notes), which also stops the worker's repeated select-pane from clearing a cold start's pending link, and a remembered selection of a removed PC falls back to this PC with the machine-missing note once the roster is in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 41 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… the pane's workspace Review follow-ups for the notification tap target fix: - A second delivery of one tap (the worker posts before and after focus) no longer strands the first's session lookup: an identical pending link is kept, and a tap's link bumps a counter the link resolver watches, so a pane that is already selected is settled too. - A PC missing from the tab's cached roster no longer discards the tap: it waits as a link and a fresh roster is asked for. A PC is called gone only by a roster the server sent after it was named, so a list rebuilt from a pane status (Open PC before load()) no longer drops a new PC. - The worker treats only the app shell's paths as app windows: any shipped file is excluded. - Push alerts name the workspace the pane was last seen in (PushPayload.workspace_id), so an ended pane's tap opens that workspace with the pane-closed note instead of workspace-closed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… roster The selection's missing-PC check stays on for every roster the server sends after the selection was made, so a PC removed elsewhere while selected still lands on this PC with the note. Rosters rebuilt from a pane status remain no newer than the selection, and only a pending link bumps the re-check tick, so no render is added per poll. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ab alerts A phone resumed from the background can still list the pane an ended alert names, so the tap selected it at once and dropped the alert's workspace. When the next roster removed the pane, the app fell back to herdr's focused pane, possibly in another workspace, with no note. The tap now keeps the alert's workspace as a hint with the selection; when the selected pane is confirmed gone, the hint resolves as a link does: that workspace's pane opens with "That agent has closed: its workspace is open". Any other pick clears the hint. The tab's own alerts (push off, alerts on in this tab) carried no workspace_id, so a tap after the pane ended said "That link's workspace is closed" although the workspace was open. They now name the pane's workspace as the server's push does, and the worker-less fallback click goes through the same landing as a worker's tap. The browser check covers the listed-then-closed pane with herdr focus in another workspace, and bounds its /api/session wait so a future change fails fast instead of holding the lane. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server tells every tab the roster without a removed PC before it answers the DELETE, so the tab's new selection check usually saw the selected PC missing first and said "That link's PC is not set up here" for the user's own Remove PC. Remove PC now selects this PC before the request and puts the selection back if the request fails. machine-conflict-regression.ts gains an event stream and a DELETE that tells the roster before it answers, and checks that no note appears. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Problem
/?read=…) or a raw file tab opened earlier from the file viewer. The pane named in the alert never opened./social-preview.pngstill counted as app windows; and a closed pane's tap always said its workspace had closed.Cause
public/sw.jsnotificationclickpickedwindows.find(focused) || windows[0]without checkingclient.url.matchAlllists the most recently focused window first, so the reader tab got theselect-panemessage. It rendersFileReader, notApp, so nothing consumed the message, andfocus()succeeded, soopenWindownever ran.src/App.tsxhandled "PC missing" and "pane closed" only for address links (pendingLink,resolveLink,setHeaderNote). Notification targets went straight toselectTarget, which also clearedpendingLink. That includes the worker'sselectLatestrepeat on a cold start, so a cold start's link could lose its machine-missing handling as well. A stored selection never setpendingLink.pendingLinkobject had been replaced, so the worker's second identical delivery stranded it. The tap handler decided "PC missing" from whatever roster the tab held, and the selection check ran on anymachineschange, including lists rebuilt from a pane status beforeload()brought a just-added PC. The alert carried no workspace, soresolveLinkcould only answer workspace-closed for a closed pane.Fix
sw.js: newisAppWindow(url). Only the app shell's paths count: it rejects?read=readers,/api/responses (raw files and HTML pages),/ws, and any path whose last part has an extension other thanindex.html(icons,/social-preview.png, the manifest,/sw.js, notices).notificationclickonly considers app windows, and opens the app when none is left.CACHE_NAMEis unchanged because no icons changed.PushPayload.workspace_id(optional, additive).server/push.tsrecords each pane's workspace inseed()beside its title and sends it with status and ended alerts.sw.jskeeps it in the notification data, posts it withselect-pane, and puts it in the cold-start URL asws=.src/lib/notificationTarget.ts:machineMissing,machineGone(roster, rosterSeq, since, id)(a PC is gone only by a roster the server sent after it was named),notificationLanding(roster, target)(select, or a link carrying the alert's workspace, markedstalewhen the cached roster lacks the PC) andsameLink.App.tsx, notification handler:pendingLink, the same way popstate does, so it settles throughresolveLinkwith its notes. With the alert's workspace, a closed pane opens its workspace's pane with the pane-closed note.linkTick, which the resolver effect watches, so it also settles when the pane is already selected.load()asks for a fresh roster.App.tsx, machine-missing effect: counts server rosters (rosterSeq, bumped inload()and themachinesevent, never for pane-status rebuilds) and decides only from one sent after the link or selection was made. A remembered selection (reload, new window) is checked against the first roster, and the selection keeps being checked against each newer one (a PC removed elsewhere while selected); "Open PC" beforeload()is checked against the rosterload()brings. ArosterTickstate re-runs the check when a roster comes in while a link waits, even if the list is unchanged (no re-render per poll otherwise).Tests
src/pwa-notification.test.ts:isAppWindowcases, now including/social-preview.png,/THIRD_PARTY_NOTICES.md, the manifest,/sw.jsand/favicon.ico.workspace_idin the notification data; a tap posts it and a cold start opens/?machine=…&ws=…&pane=…&view=chat. Both fail on the previoussw.js.sw.jschange.src/lib/notificationTarget.test.ts:machineMissing,machineGone(a roster no newer than the naming never settles; one after it does),notificationLanding(a PC the cached roster lacks waits as a stale link, known pane, unknown roster/panes/pane, the alert's workspace withresolveLinkgivingpane-closed),sameLink, andworkspace_idparsing innotificationTargets.server/push.test.ts: status and ended alerts carry the seededworkspace_id.scripts/notification-view-regression.ts: an ended pane's alert delivered twice while the session lookup is held (page.routeon/api/session, released after the second tap) lands on its workspace's pane with "That agent has closed: its workspace is open". Run alone throughbun run check run: passes with the fix, times out on the note with the dedupe andlinkTicktaken out.bun run buildthenbun run check run bun scripts/ui-contexts-regression.ts: pass. After the review follow-ups:bun run buildthenbun run check run bun scripts/ui-contexts-regression.ts(includescheckNotificationStartup, which pins theselect-panemessage shape, andcheckNotificationView): pass.bun run check fast(workflow syntax, generated types, typecheck, build, unit tests: 3080 pass, 0 fail): pass.Notes
public/sw.js, in the cache and fetch code; this PR edits the push and notificationclick handlers and no longer callsisCacheFirst, so the two should merge with at most a textual conflict. Otherwise no open PR touchespublic/sw.js,src/lib/notificationTarget.tsorsrc/lib/deepLink.ts. Several open PRs editsrc/App.tsx(feat(chat): port t3code chat rendering, composer and settings features #951, feat(palette): use pane shortcuts to cycle status filters #917, feat(sidebar): Settings as a gear beside search; the footer only for the usage meters #909, feat(new-tab): choose the new tab's folder #890, feat(keyboard): focus pane input with Mod+Shift+E #822), but none in the notification or machine-missing code.seed()saw it, has noworkspace_id: its closed pane still gets the workspace-closed note and herdr's fallback pane.watchingcheck still counts any visible window, a reader tab included; a split view's other half on a removed PC is not handled here.Merge-session review
Fixed (2be0fd0, 3b87dfc):
workspace_id; when the next roster removed the pane, the app fell back to herdr's focused pane with no note. The tap now keeps the alert's workspace as a hint with the selection (cleared by any other pick); once the selected pane is confirmed gone againstfetchSession, the hint resolves throughresolveLink: the workspace's pane opens with "That agent has closed: its workspace is open". Regression inscripts/notification-view-regression.ts: the pane is listed at the tap, closed through herdr afterwards, with herdr's focus in another workspace; it times out without the fix.workspace_id(medium): with push off and alerts on in this tab,showPaneStatusNotification/showPaneEndedNotificationnow put the pane'sworkspace_idin the notification data, and the worker-less fallback click goes through the same landing as a worker's tap. Unit test insrc/lib/notifications.test.ts(fails without the fix).MachineSidebarnow selects this PC before the request and restores the selection if the request fails.scripts/machine-conflict-regression.tsgains an event stream and a DELETE that tells the roster first; it fails without the fix./api/sessionlookup wait races a 4 s timeout, andrelease()/unrouterun in afinally.Deferred:
seed()) with noworkspace_id, whose pane alone is gone still shows "That link's workspace is closed"; settling such a tap silently is a wording/policy choice, left as in the Notes above.Checks:
bun run check fast(3081 pass, 0 fail);CI=1 bun run check run --build bun scripts/ui-contexts-regression.ts: pass;CI=1 bun run check run --build bun scripts/machine-conflict-regression.ts: pass.🤖 Generated with Claude Code