Repository navigation
Open the share panel at its full size the first time - #646
Conversation
The share panel's code loaded only when the panel first opened (or as Publish was pressed), so a first open showed its heading and a spinner, then grew about 200 px when the code arrived. Share and Publish and share now fetch it once the page is idle (200 ms after it's shown in Safari, which has no requestIdleCallback). Fetching it early isn't enough on its own: lazy waits a turn on a promise even when the module is cached, and React keeps a fallback up for 300 ms once shown. So once the code is in, the panel's lazy gets a then that calls back at once, and resolves in the same render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
From the review: SharePanel's lazy now lives in load-share-panel.ts, so the object that only has `then` reaches nothing but `lazy`. The CHANGELOG says the panel usually opens at its full size, and that a failed load is tried again when the panel opens; SharePanel's and ShareQrCode's comments no longer say the code loads only when the panel opens. Tests: the same-render test now relies on the page's own idle load, a failed load is shown not to be kept, and the panel is mocked afresh in each test, since a mocked module stays loaded through resetModules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
main's #601 (the tabs' focus ring) and this PR's idle load and instant `then` together take the Responses tab to 130.018 kB, 18 B over 130. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
The CHANGELOG's only conflict: main's two new entries for #604 and #605 go after this branch's line for the share panel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
budgets.json was the only conflict, and main's side is kept: #649 raised Responses to 131 itself, the raise this branch made, along with the other signup tabs' budgets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H
Tophat: passedRan c0ec83d as a production build ( I measured with a Playwright script that waits a set time after the page loads, then clicks. It samples the open dialog's height and whether the spinner is showing on every animation frame for 1.5 s. It also logs which JS files load after the page's
For the owner (UX): the first time an organizer opens Share or presses Publish and share on a page, the panel now opens at its full size. Before, it showed a small box with a spinner for about a quarter of a second and then jumped about 200 px taller. Once the code is in, nothing else about the panel looks different. If someone clicks within a few hundred ms of the page loading, or the early fetch fails, they get the old spinner-then-grow behaviour, and the panel still works. The cost is that every draft or open signup's tabs now fetch the panel's file (about 7.5 kB gzip, cached per deploy) after the page loads, even if the organizer never shares. Screenshots: Screenshots are in https://claude.ai/code/session_01MTLHRSYbwK1vKjngmLNWUb. Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
Review: passed (round 1)
This PR loads the share panel's code once a draft's or open signup's page is idle (usePrefetchSharePanel in ShareButton and PublishButton, requestIdleCallback with a 2 s timeout, or a 200 ms timer where there's none). It also moves the panel's lazy into load-share-panel.ts, where a load that has already come in is handed to lazy through a then that calls back at once. React's lazy calls then and then checks whether the payload resolved during that call, so the panel renders in the same pass and no fallback (with its 300 ms throttle) shows. Only a load that worked is stored in loaded, so a failed early load is tried again when the panel opens, and the fallback still shows if that fails too. The fake thenable is module-private and only lazy gets it. Several mounted buttons (desktop and phone) each prefetch, but import() dedupes them. The prefetch hook calls the module's own loadSharePanel, so the count assertions in ShareButton.test.tsx and PublishButton.test.tsx still measure Publish's own load and aren't padded by the prefetch. Each behaviour the description claims has a unit test: idle-only fetch, cancel on unmount, the Safari timer, same-render open once loaded, the fallback while loading, and a failed load not being kept.
Blocking (0): none
Optional (0): none
Earlier threads: none. Copilot couldn't review (quota used up).
Checks: CI green on c0ec83d (lint-type-test, e2e, CodeQL). The tophat passed on this same SHA, as a production build, at 1280 and 390, so runtime code hasn't changed since. I went through the checklist: no services, schema or public routes are touched. Budgets are unchanged and the PR reports its pages under them. The CHANGELOG entry is updated, and no help or legal page describes when the code loads. No local runs were needed, since there were no findings to prove. The branch is behind main (#600, #643) with no conflict, and the merge stage updates it.
Why the owner: UX. The first Share or Publish and share on a page now opens the panel at full size instead of as a spinner that then grows about 200 px. Every draft or open signup's tabs also now fetch about 7.5 kB gzip after load, even when the organizer never shares. The tophat's per-frame heights table and screenshots (646-after-share-desktop, 646-after-share-phone, 646-after-publish-*, 646-after-all-loads-fail) show it.
https://claude.ai/code/session_01DFKGuYh28iFmKJaws6mXzT
Generated by Claude Code
|
Approved by the owner at The branch is behind https://claude.ai/code/session_014qBeQRGx7pCq7m7Xv8ZCpD Generated by Claude Code |
Through the server, telemetry and screen branches. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Fixes the polish point in #574's comment: the share panel opened small and grew on its first open on a page.
The problem
The share panel's code (the panel and its QR encoder) loaded only when the panel first opened, or as Publish and share was pressed. So the first open showed the heading and a spinner, then grew by about 200 px when the code arrived. A second open on the same page was fine.
Loading the code earlier isn't enough on its own.
lazywaits a turn on a promise even when the module is already loaded, so the first render still shows the fallback, and React then keeps a fallback on screen for at least 300 ms (FALLBACK_THROTTLE_MS). I measured it: with the early load alone, the spinner still showed for about 280 ms.The fix
usePrefetchSharePanel,requestIdleCallbackwith a 2 s timeout). Safari has norequestIdleCallback, so there it starts 200 ms after the page shows. Closed and archived signups show neither button, so they don't load it.lazynow lives inload-share-panel.ts. Once the code has loaded, it gets an object whosethencalls back at once, whichlazytakes in the same render, so no fallback shows. The object isn't a real promise, so it stays private to that file and reaches nothing butlazy.Measured
Production build, with the click about 1 s after the page loads. The "before" numbers are the owner's, from
pnpm dev; my own dev run ofmaingave the same picture, a spinner for about 280 ms on each.The spinner can still show when the code hasn't arrived by the time of the click: a very slow connection with an instant click, or a failed early load. Then the panel loads and works as before.
Choices this makes
Tests
Unit:
prefetch-share-panel.test.tsx(new):load-share-panel.test.tsx: a load that failed ahead isn't kept, so opening tries again. Each of these tests fails when the fix is broken in the way it covers: an early load that doesn't keep the panel, alazythat always waits on a promise, and a failed load that is kept.Passed on
c0ec83d, withmainthrough Add a help page on closing and reopening a signup #650 merged in:pnpm lint && pnpm typecheck && pnpm knip && pnpm test(1770),pnpm build && pnpm budgetswith CI's build settings, and the full chromium e2e withCI=1(88). Each earlier timemainmoved (Show the whole keyboard focus ring on the signup tabs #601, then Say which slot someone is taking in the sign-up sheet, "You're in." and the signed-up bar #602, Let a closed signup be reopened, through the service and the REST API #604 and Give the AI connector a reopen_signup tool #605), the head passed the unit tests, the budgets and the publish and share e2e specs; the only conflicts were the CHANGELOG, where both sides' entries are kept, andbudgets.json, below.Independent checks: a code review by an agent that didn't write the change found nothing blocking, and this PR's second commit fixes its findings. The reviewer checked the instant
thenagainst Next's bundled React 19.2 (production and development) as well as the react 19.0 the tests use. A tophat on the production build, at 1280 and 390, passed:Budgets
Every signup tab's first load grows by 142 B: the idle load and the instant
then, measured againstmainat28373e1. No budget changes: this PR had raised Responses from 130 to 131, after #601 left it no room, andmain's #649 has since made the same raise along with the other signup tabs', sobudgets.jsonismain's.At
c0ec83d, with CI's build settings, which bake in their own instance name and contact details:/app/signups/[id]/build/app/signups/[id]/responses/app/signups/[id]/settings/app/signups/[id]/edit,/app/signups/[id]Docs
SharePanel.tsxandShareQrCode.tsxno longer say the code loads only when the panel opens.🤖 Generated with Claude Code
https://claude.ai/code/session_01HoJtwsyrp6YC4DU9JAnc7H