fix(app): copy correct session URL on first Share Session click#2318
fix(app): copy correct session URL on first Share Session click#2318dewly-justice wants to merge 2 commits into
Conversation
CopyToClipboard captured window.location.href into its text prop at render time, but nuqs flushes sid/sfrom/sto into the URL asynchronously (after startTransition + throttleMs). The panel rendered before the flush and froze the stale URL, so the first click copied a link without the session params. A reload "fixed" it only because the URL already contained the params on initial render. Replace CopyToClipboard with an onClick handler that reads window.location.href at click time (after nuqs has flushed) and uses the shared copyTextToClipboard util for the non-HTTPS textarea fallback and error reporting. Fixes hyperdxio#2313
|
@dewly-justice is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: f9128b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Deep Review✅ No critical issues found. The fix correctly resolves the render-time URL capture by reading 🔵 P3 nitpicks (1)
Reviewers (9): correctness, testing, maintainability, project-standards, agent-native, learnings, julik-frontend-races, kieran-typescript, previous-comments. |
Address PR hyperdxio#2318 review comments: - Add an RTL test that mutates window.location after mount and asserts copyTextToClipboard receives the post-mutation URL, plus a failure-branch test for the red CLIPBOARD_ERROR_MESSAGE toast. - Add a changeset for @hyperdx/app.
Summary
Fixes #2313.
On the Client Sessions page, clicking Share Session immediately after opening a session copied the previous URL (without
sid/sfrom/sto). A reload was required for the button to copy the correct link.Root cause:
CopyToClipboardcapturedwindow.location.hrefinto itstextprop at render time.nuqs(setSelectedSessionQueryinSessionsPage.tsx:322) updates React state synchronously but flusheswindow.historyasynchronously (batched viastartTransition+throttleMs).SessionSidePanelrendered before the flush and froze the stale URL into the prop. After reload the URL already contained the params on initial render, which is why the bug "disappeared."Fix: Replace
CopyToClipboardwith a plainonClickhandler that readswindow.location.hrefat click time — by thennuqshas flushed. Reuse the sharedcopyTextToClipboardutil frompackages/app/src/utils/clipboard.tsso we get the non-HTTPS<textarea>fallback and explicit error reporting for free.Screenshots or video
Non-visual behavioral fix; no UI changes.
sid/sfrom/stoHow to test on Vercel preview
Preview routes: /sessions
Steps:
/sessionsand ensure at least one session card is visible (use the demo data).&sid=...&sfrom=...&sto=....sid,sfrom, andstoquery params on the first click (no reload needed).References