Skip to content

fix: copy current session share URL#2324

Open
AjTheSpidey wants to merge 4 commits into
hyperdxio:mainfrom
AjTheSpidey:codex/share-session-current-url
Open

fix: copy current session share URL#2324
AjTheSpidey wants to merge 4 commits into
hyperdxio:mainfrom
AjTheSpidey:codex/share-session-current-url

Conversation

@AjTheSpidey
Copy link
Copy Markdown

@AjTheSpidey AjTheSpidey commented May 21, 2026

Fixes #2313.

The Share Session button was grabbing the URL too early. If the panel opened while the session params were still being written, it could copy a link without sid, sfrom, or sto.

This makes it read the current address bar URL when you actually click Share Session. I also added tests for the copied URL and the success/error notifications.

Tested locally with the focused Jest test, prettier, app typecheck, and eslint. ESLint had no errors, only the existing warnings.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

@AjTheSpidey is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: 130d313

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Deep Review

🟡 P2 -- recommended

  • packages/app/src/SessionSidePanel.tsx:75 -- notifications.show runs after the await with no mounted check, so closing the drawer (e.g. via the esc hotkey at :99) while navigator.clipboard.writeText is pending fires a Copied link to clipboard toast on whatever view the user landed on; the prior synchronous CopyToClipboard path could not produce this stale notification.
    • Fix: Capture a mounted flag in a useRef reset by a useEffect cleanup and gate the notifications.show call on it before firing.
    • julik-frontend-races, correctness, testing
🔵 P3 nitpicks (6)
  • packages/app/src/SessionSidePanel.tsx:65-83 -- The button stays visually enabled while the copy is in flight, so the ref-based dedup silently drops rapid double-clicks (or a click during a slow clipboard permission prompt) with no user feedback.
    • Fix: Mirror the ref with a useState(false) and pass loading or disabled to the Button so the in-flight state is visible.
    • maintainability, julik-frontend-races
  • packages/app/src/SessionSidePanel.tsx:71-76 -- The try { ... } catch { copied = false } wrapper is dead under copyTextToClipboard's current contract (the helper catches internally and always returns Promise<boolean>), and would silently swallow any future real exception.
    • Fix: Drop the try/catch, keep isSharingSessionRef.current = false in a finally, and let any future contract change surface as a real error.
    • maintainability
  • packages/app/src/SessionSidePanel.tsx:81 -- Success message 'Copied link to clipboard' is a one-off; the peer URL-share handler in DBRowTableRowButtons already uses 'Copied shareable link!' for the same intent.
    • Fix: Either reuse the existing peer string or co-locate a CLIPBOARD_SUCCESS_MESSAGE next to CLIPBOARD_ERROR_MESSAGE in utils/clipboard.ts and consume both from there.
    • maintainability
  • packages/app/src/__tests__/SessionSidePanel.test.tsx:32 -- copyTextToClipboard as jest.Mock discards the helper's Promise<boolean> signature, so mockResolvedValue / mockRejectedValueOnce are never structurally checked against the real return type.
    • Fix: Replace with const copyTextToClipboardMock = jest.mocked(copyTextToClipboard); to type-check mock returns against the real signature.
    • kieran-typescript
  • packages/app/src/__tests__/SessionSidePanel.test.tsx:34-35 -- notificationsShowSpy is installed once at module scope; jest.clearAllMocks() in afterEach wipes call history but leaves the spy in place across the suite, which is fragile if anything else in the test environment reinstalls notifications.show.
    • Fix: Move the jest.spyOn(notifications, 'show').mockImplementation(...) into beforeEach, or pair it with jest.restoreAllMocks() in afterEach.
    • testing
  • packages/app/src/__tests__/SessionSidePanel.test.tsx:40-57 -- traceSource={{} as any}, sessionSource={{} as any}, and ... as any on the session literal cast away the component's prop contract in the new test fixtures.
    • Fix: Replace each {} as any with a minimal satisfies TTraceSource / satisfies TSessionSource / satisfies Session stub of just the fields the rendered tree reads.
    • project-standards, kieran-typescript

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races.

Testing gaps:

  • No test unmounts the panel while copyTextToClipboard is pending, so the stale-notification regression is not pinned.
  • No test asserts the Share button's in-progress affordance (disabled / loading) during the async window, so any future addition or removal of visual feedback would silently change UX.

@AjTheSpidey AjTheSpidey force-pushed the codex/share-session-current-url branch from 5e18c50 to 130d313 Compare May 21, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share Session button copies stale URL on first click (missing sid/sfrom/sto)

1 participant