From a1f8d1e3137e77e7f682cf7fb2625b70bf583f10 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:55:29 +0000 Subject: [PATCH 1/2] Keep pending invitation decisions distinct from checking access Show the exact pending decision on the invitation screen. Pause the normal reload while the reply is expected, then offer the existing read-only check if the wait becomes slow. A late reply does not interrupt an explicit check or sign-out. Contract-Neutral: The invitation transport, session and CSRF handling, access rules and canonical bootstrap are unchanged. Only local feedback and readback timing on the invitee screen change. Change-source: pulse-maintainer --- .../src/components/NoOrganizationAccess.tsx | 130 ++++++++++++++---- .../__tests__/NoOrganizationAccess.test.tsx | 82 +++++++++++ 2 files changed, 186 insertions(+), 26 deletions(-) diff --git a/frontend-modern/src/components/NoOrganizationAccess.tsx b/frontend-modern/src/components/NoOrganizationAccess.tsx index f63b59cfa3..9123c60400 100644 --- a/frontend-modern/src/components/NoOrganizationAccess.tsx +++ b/frontend-modern/src/components/NoOrganizationAccess.tsx @@ -1,4 +1,12 @@ -import { For, Show, createResource, createSignal, onCleanup, type Component } from 'solid-js'; +import { + For, + Show, + batch, + createResource, + createSignal, + onCleanup, + type Component, +} from 'solid-js'; import { OrgsAPI, type UserOrganizationInvitation } from '@/api/orgs'; import { Button } from '@/components/shared/Button'; import { OrganizationRoleBadge } from '@/components/shared/OrganizationBadges'; @@ -16,6 +24,13 @@ type InvitationReadResult = | { kind: 'loaded'; invitations: UserOrganizationInvitation[] } | { kind: 'unavailable'; invitations: [] }; +interface InvitationDecision { + action: 'accept' | 'decline'; + organization: string; +} + +const SLOW_INVITATION_DECISION_MS = 10_000; + /** * Shown to a signed-in user who can use no organization yet, typically someone * invited to an organization who has not accepted. Accepting an invitation @@ -26,6 +41,7 @@ export const NoOrganizationAccess: Component = (props let invitationReadController: AbortController | undefined; let invitationRegion: HTMLElement | undefined; let restartCheckButton: HTMLButtonElement | undefined; + let slowDecisionTimer: number | undefined; const [invitationRead, { refetch }] = createResource(async () => { invitationReadController?.abort(); const controller = new AbortController(); @@ -58,13 +74,13 @@ export const NoOrganizationAccess: Component = (props onCleanup(() => { disposed = true; invitationReadController?.abort(); + window.clearTimeout(slowDecisionTimer); }); - const [responding, setResponding] = createSignal(false); - const [unconfirmedDecision, setUnconfirmedDecision] = createSignal<{ - action: 'accept' | 'decline'; - organization: string; - }>(); - const decisionsDisabled = () => responding() || unconfirmedDecision() !== undefined; + const [pendingDecision, setPendingDecision] = createSignal(); + const [decisionSlow, setDecisionSlow] = createSignal(false); + const [unconfirmedDecision, setUnconfirmedDecision] = createSignal(); + const decisionsDisabled = () => !!(pendingDecision() || unconfirmedDecision()); + const checkAgainDisabled = () => !!pendingDecision() && !decisionSlow(); const retryInvitations = () => { if (disposed || decisionsDisabled()) return; @@ -76,38 +92,70 @@ export const NoOrganizationAccess: Component = (props const reload = () => (props.onReload ? props.onReload() : window.location.reload()); - const respond = async (invitation: UserOrganizationInvitation, action: 'accept' | 'decline') => { + const finishDecision = (decision: InvitationDecision, unconfirmed = false) => { + window.clearTimeout(slowDecisionTimer); + batch(() => { + if (unconfirmed) setUnconfirmedDecision(decision); + setPendingDecision(undefined); + setDecisionSlow(false); + }); + }; + + const leaveWhileWaiting = () => { + const decision = pendingDecision(); + // Stop acting on this response if the user leaves. That does not cancel + // or undo a server write; the current access has to be read again. + if (decision) finishDecision(decision, true); + }; + + const checkAgain = () => { + if (disposed || checkAgainDisabled()) return; + leaveWhileWaiting(); + reload(); + }; + + const respond = async ( + invitation: UserOrganizationInvitation, + action: InvitationDecision['action'], + ) => { if (disposed || invitationRead.loading || decisionsDisabled()) return; // A disabled row button can drop keyboard focus. Move it only when it is // still inside this region, never from a recovery or sign-out control. if (invitationRegion?.contains(document.activeElement)) { invitationRegion.focus({ preventScroll: true }); } - setResponding(true); + const decision = { + action, + organization: getOrganizationInvitationPresentation( + invitation.orgId, + invitation.orgDisplayName, + ).organization, + }; + const isCurrent = () => !disposed && pendingDecision() === decision; + setPendingDecision(decision); + // Avoid replacing a healthy in-flight decision with a reload, but keep + // an escape for an unresponsive server. The timer itself does not retry. + slowDecisionTimer = window.setTimeout(() => { + if (isCurrent()) setDecisionSlow(true); + }, SLOW_INVITATION_DECISION_MS); try { if (action === 'accept') { await OrgsAPI.acceptMyInvitation(invitation.orgId); - if (!disposed) reload(); + if (isCurrent()) reload(); return; } await OrgsAPI.declineMyInvitation(invitation.orgId); // The decision is complete. Its readback can be replaced independently. - if (!disposed) void refetch(); + if (isCurrent()) void refetch(); } catch (error) { - if (disposed) return; + if (!isCurrent()) return; logger.warn('Failed to answer organization invitation', error); // The reply can fail after Pulse saved the decision. An inbox read // alone cannot tell whether an acceptance granted access; Check again // re-enters the existing bootstrap path instead of resending the write. - setUnconfirmedDecision({ - action, - organization: getOrganizationInvitationPresentation( - invitation.orgId, - invitation.orgDisplayName, - ).organization, - }); + finishDecision(decision, true); } finally { - setResponding(false); + if (isCurrent()) finishDecision(decision); } }; @@ -120,10 +168,32 @@ export const NoOrganizationAccess: Component = (props

{unconfirmedDecision() ? 'Check organization access' : 'No organization access yet'}

-

- {unconfirmedDecision() - ? 'You are signed in. Your organization access may have changed.' - : 'You are signed in, but you are not a member of an organization on this Pulse server.'} +

+ + {(decision) => ( + <> + You are signed in. Waiting for Pulse to confirm your decision to {decision.action}{' '} + the invitation to {decision.organization}. + + {' '} + Keep waiting or choose Check again to check access without + resending your decision. + + + )} +

= (props - diff --git a/frontend-modern/src/components/__tests__/NoOrganizationAccess.test.tsx b/frontend-modern/src/components/__tests__/NoOrganizationAccess.test.tsx index 7986915b8f..54d927bea7 100644 --- a/frontend-modern/src/components/__tests__/NoOrganizationAccess.test.tsx +++ b/frontend-modern/src/components/__tests__/NoOrganizationAccess.test.tsx @@ -76,6 +76,7 @@ beforeEach(() => { afterEach(() => { cleanup(); + vi.useRealTimers(); clearAuth(); document.cookie = 'pulse_csrf=; Max-Age=0; Path=/'; vi.unstubAllGlobals(); @@ -209,6 +210,14 @@ describe('no-organization invitation recovery', () => { expect(fetchMock).toHaveBeenCalledTimes(2); expectRequest(1, '/api/org-invitations/client%2Feast/accept', 'POST'); expect(onReload).not.toHaveBeenCalled(); + expect(screen.getByText(/Waiting for Pulse to confirm/)).toHaveTextContent( + 'Waiting for Pulse to confirm your decision to accept the invitation to East estate (client/east).', + ); + const checkAgain = screen.getByRole('button', { name: 'Check again' }); + expect(checkAgain).toBeDisabled(); + fireEvent.click(checkAgain); + expect(onReload).not.toHaveBeenCalled(); + expect(screen.getByRole('button', { name: 'Sign out' })).toBeEnabled(); expect(screen.queryByRole('button', { name: 'Restart invitation check' })).toBeNull(); for (const button of screen.getAllByRole('button', { name: /^(Accept|Decline) invitation to /, @@ -224,6 +233,74 @@ describe('no-organization invitation recovery', () => { expect(fetchMock).toHaveBeenCalledTimes(2); }); + it.each(['Accept', 'Decline'] as const)( + 'allows a read-only check after a slow %s without acting on its late response', + async (action) => { + const response = deferred(); + fetchMock + .mockResolvedValueOnce(jsonResponse(invitations)) + .mockReturnValueOnce(response.promise); + const { onReload } = renderRecovery(); + await screen.findByText('West estate'); + vi.useFakeTimers(); + + const button = screen.getByRole('button', { + name: `${action} invitation to West estate (client/west)`, + }); + const checkAgain = screen.getByRole('button', { name: 'Check again' }); + button.focus(); + fireEvent.click(button); + + await vi.advanceTimersByTimeAsync(9_999); + expect(checkAgain).toBeDisabled(); + expect(onReload).not.toHaveBeenCalled(); + await vi.advanceTimersByTimeAsync(1); + expect(checkAgain).toBeEnabled(); + expect(screen.getByText(/Waiting for Pulse to confirm/)).toHaveTextContent( + 'check access without resending your decision.', + ); + expect(button).toBeDisabled(); + expect(fetchMock).toHaveBeenCalledTimes(2); + + fireEvent.click(checkAgain); + expect(onReload).toHaveBeenCalledOnce(); + expect(screen.getByRole('alert')).toHaveTextContent( + 'The list below is from before your decision.', + ); + expect(button).toBeDisabled(); + + response.resolve(new Response(null, { status: 204 })); + await vi.advanceTimersByTimeAsync(0); + expect(onReload).toHaveBeenCalledOnce(); + expect(fetchMock).toHaveBeenCalledTimes(2); + }, + ); + + it('does not interrupt explicit sign-out with a late acceptance reload', async () => { + const response = deferred(); + fetchMock + .mockResolvedValueOnce(jsonResponse(invitations)) + .mockReturnValueOnce(response.promise); + const { onReload, onSignOut } = renderRecovery(); + await screen.findByText('East estate'); + vi.useFakeTimers(); + + fireEvent.click( + screen.getByRole('button', { name: 'Accept invitation to East estate (client/east)' }), + ); + const exit = screen.getByRole('button', { name: 'Sign out' }); + exit.focus(); + fireEvent.click(exit); + expect(onSignOut).toHaveBeenCalledOnce(); + expect(exit).toHaveFocus(); + + response.resolve(jsonResponse({ kind: 'member' })); + await vi.advanceTimersByTimeAsync(10_000); + expect(onReload).not.toHaveBeenCalled(); + expect(screen.queryByText(/Waiting for Pulse to confirm/)).toBeNull(); + expect(fetchMock).toHaveBeenCalledTimes(2); + }); + it.each([ ['Accept', 'HTTP failure'], ['Accept', 'lost response'], @@ -326,10 +403,15 @@ describe('no-organization invitation recovery', () => { fireEvent.click(row('West estate').getByRole('button', { name: /^Decline invitation to / })); expect(fetchMock).toHaveBeenCalledTimes(2); expectRequest(1, '/api/org-invitations/client%2Fwest', 'DELETE'); + expect(screen.getByText(/Waiting for Pulse to confirm/)).toHaveTextContent( + 'Waiting for Pulse to confirm your decision to decline the invitation to West estate (client/west).', + ); + expect(screen.getByRole('button', { name: 'Check again' })).toBeDisabled(); decline.resolve(new Response(null, { status: 204 })); await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(3)); expectRequest(2, '/api/org-invitations', 'GET'); expect(onReload).not.toHaveBeenCalled(); + expect(screen.getByRole('button', { name: 'Check again' })).toBeEnabled(); expect(screen.queryByRole('button', { name: /^Accept invitation to / })).toBeNull(); expect( screen.queryByText('Ask a Pulse administrator to add you to an organization.'), From b5d2fa55d9ffd6271fb5572ed53da47afcda2ad2 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:01:54 +0000 Subject: [PATCH 2/2] Record paired invitation recovery browser verification Bind the desktop and narrow bootstrap comparisons to the exact invitation decision UI they exercise. Change-source: pulse-maintainer --- .../af867a7ae398f49e.json | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 frontend-modern/browser-verification/af867a7ae398f49e.json diff --git a/frontend-modern/browser-verification/af867a7ae398f49e.json b/frontend-modern/browser-verification/af867a7ae398f49e.json new file mode 100644 index 0000000000..9723c522be --- /dev/null +++ b/frontend-modern/browser-verification/af867a7ae398f49e.json @@ -0,0 +1,42 @@ +{ + "version": 1, + "base_sha": "a1f8d1e3137e77e7f682cf7fb2625b70bf583f10", + "verified_at": "2026-11-21T12:01:50Z", + "result": "passed", + "changed_paths": [ + "frontend-modern/src/components/NoOrganizationAccess.tsx" + ], + "content_sha256": { + "frontend-modern/src/components/NoOrganizationAccess.tsx": "d8d2a69e8f94ac5716de1e973a772281f6098429ac73b75a13fc7dc7643990dc" + }, + "routes": [ + "/standalone/machines (signed-in invitation screen at bootstrap)" + ], + "viewports": [ + { + "width": 1440, + "height": 900, + "theme": "light", + "browser": "Chromium 141.0.7390.37" + }, + { + "width": 320, + "height": 800, + "theme": "dark", + "browser": "WebKit 26.0" + } + ], + "states": [ + "Two current same-named invitations with different exact IDs and roles.", + "Desktop acceptance awaiting acknowledgement with its target visible and Check again temporarily disabled.", + "Narrow decline awaiting acknowledgement, then still pending after ten seconds with read-only recovery available.", + "Unconfirmed acknowledgement distinct from signed-in access; original rows remain visible and non-actionable." + ], + "interactions": [ + "Activate Accept with Enter, verify one exact session-bound decision, and verify the disabled reload cannot issue a fresh read. Tab still reaches Sign out.", + "Release the acknowledgement; existing bootstrap runs once and opens the Machines page as the fixture member.", + "Tap Decline on WebKit, advance the clock past the slow threshold, and use Check again. Fresh inbox read, no repeated decision.", + "Recheck after an unconfirmed acceptance and verify the original write is not replayed." + ], + "evidence_summary": "Playwright 1.56.1 on paired exact-source app bootstraps with synthetic HTTP. Six matched pairs were inspected in the native image tool." +}