Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): avoid reloads on mobile notification read failures (#796)
Gustavo Ye7ec270293566
diff --git a/src/web/src/hooks/community/use-native-system-notifications.dom.test.ts b/src/web/src/hooks/community/use-native-system-notifications.dom.test.tsindex 7184969ee..25bdc9245 100644--- a/src/web/src/hooks/community/use-native-system-notifications.dom.test.ts+++ b/src/web/src/hooks/community/use-native-system-notifications.dom.test.ts@@ -444,6 +444,47 @@ describe("native system notification hook", () => {expect(stop).toHaveBeenCalledOnce()})+ it.each(["unmounted", "open"])("preserves the page when a foreground activation read fails with Inbox %s", async (inboxState) => {+ vi.useFakeTimers()+ hookMocks.desktop = false+ hookMocks.mobile = true+ const assign = vi.fn()+ vi.stubGlobal("location", { href: "https://alook.test/c/channels/server_1/channel_1", assign })+ hookMocks.mobileListen.mockResolvedValue(vi.fn())+ hookMocks.mobileCheck.mockResolvedValue("denied")+ hookMocks.mobileTake.mockResolvedValueOnce(null).mockRejectedValue(new Error("native bridge unavailable"))+ const button = document.createElement("button")+ button.setAttribute("aria-label", "Close Inbox")+ const click = vi.spyOn(button, "click")+ if (inboxState === "open") document.body.append(button)+ const visible = vi.spyOn(document, "visibilityState", "get").mockReturnValue("visible")+ const rendered = renderHook(() => useNativeSystemNotifications("viewer_1"))+ await act(async () => { await vi.advanceTimersByTimeAsync(0) })+ await act(async () => {+ document.dispatchEvent(new Event("visibilitychange"))+ await vi.advanceTimersByTimeAsync(2_100)+ })+ expect(hookMocks.mobileTake).toHaveBeenCalledTimes(2)+ expect(assign).not.toHaveBeenCalled()+ expect(click).not.toHaveBeenCalled()+ expect(window.sessionStorage.length).toBe(0)++ const nextActivation = {+ notificationId: "4f3bb3fd-5d7f-4a26-8e0e-3ddd1154f71e",+ messageId: "message_1",+ targetId: "channel_1",+ }+ hookMocks.mobileTake.mockResolvedValueOnce(nextActivation)+ hookMocks.mobileRevalidate.mockResolvedValueOnce({ href: "/c/me/channel_1?seq=4" })+ await act(async () => {+ window.dispatchEvent(new Event("online"))+ await vi.advanceTimersByTimeAsync(0)+ })+ expect(assign).toHaveBeenCalledExactlyOnceWith("/c/me/channel_1?seq=4")+ rendered.unmount()+ visible.mockRestore()+ })+it("schedules and cancels a mobile registration retry", async () => {hookMocks.desktop = falsehookMocks.mobile = truediff --git a/src/web/src/lib/community/mobile-system-notification.test.ts b/src/web/src/lib/community/mobile-system-notification.test.tsindex 18c75a187..9822e19c1 100644--- a/src/web/src/lib/community/mobile-system-notification.test.ts+++ b/src/web/src/lib/community/mobile-system-notification.test.ts@@ -537,7 +537,7 @@ describe("mobile notification activation", () => {)).resolves.toBeNull()})- it("opens Inbox on invalid, revoked, or unreadable activations", async () => {+ it("opens Inbox for an unreadable destination but ignores unavailable activation reads", async () => {const openInbox = vi.fn()const navigate = vi.fn()const controller = createMobileSystemNotificationActivationController({@@ -549,8 +549,9 @@ describe("mobile notification activation", () => {openInbox,})await controller.drain()+ expect(openInbox).toHaveBeenCalledTimes(1)await controller.drain()- expect(openInbox).toHaveBeenCalledTimes(2)+ expect(openInbox).toHaveBeenCalledTimes(1)expect(navigate).not.toHaveBeenCalled()})diff --git a/src/web/src/lib/community/mobile-system-notification.ts b/src/web/src/lib/community/mobile-system-notification.tsindex d175873f7..91035c382 100644--- a/src/web/src/lib/community/mobile-system-notification.ts+++ b/src/web/src/lib/community/mobile-system-notification.ts@@ -369,7 +369,6 @@ export function createMobileSystemNotificationActivationController(try {activation = await deps.take()} catch {- if (!disposed) await deps.openInbox()continue}if (!activation || disposed) continue