Skip to content

fix(ui): make request IDs and copying work over plain HTTP - #1583

Merged
kvlonge merged 2 commits into
mainfrom
fix/ui-ids-without-secure-context
Nov 18, 2026
Merged

kvlonge merged 2 commits into
mainfrom
fix/ui-ids-without-secure-context

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Why

Served over plain HTTP from a host name, for example behind a proxy, the UI page is not a secure context. crypto.randomUUID and navigator.clipboard don't exist there, so every action that makes a request ID failed with "crypto.randomUUID is not a function", and copy buttons did nothing.

Changes

  • newRequestId (ui/src/lib/browser/request-id.ts) uses crypto.randomUUID where the page has it and otherwise builds a version 4 UUID from crypto.getRandomValues. The API client and the mock large project use it.
  • copyText (ui/src/lib/browser/clipboard.ts) uses the Clipboard API where it exists and otherwise copies through a hidden text area, keeping what the person had selected. Copy buttons, the selection bar, the SQL viewer and the plan page use it.
  • When a one-time secret cannot be copied, it is selected, with a hint to copy it by hand.
  • A unit test fails if any other source file calls crypto.randomUUID or navigator.clipboard directly.

DuckShop: no edge case added. This is browser behaviour in the UI, not a project shape, data value or lifecycle sequence.

Verification

  • npm run check (0 errors), npm test (83 files, 593 tests), npm run build.
  • Playwright: the new insecure-context spec removes both APIs before the app loads and checks that a plan opens, copying works and keeps the selection, and the secret hint shows; the layout and budgets projects pass.

`crypto.randomUUID` and `navigator.clipboard` exist only in secure
contexts (HTTPS or localhost). Served over plain HTTP behind a proxy,
every action that makes an ID failed with "crypto.randomUUID is not a
function": starting, cancelling and rerunning runs, acknowledging, and
changing triggers. Copy buttons either threw or said "Copied" without
copying.

- `newRequestId()` uses `crypto.randomUUID` where it exists, and
  otherwise builds an RFC 4122 version 4 UUID from
  `crypto.getRandomValues`, which every context has.
- `copyText()` uses the Clipboard API where it exists and works, and
  otherwise copies from a hidden textarea. Copy buttons say "Copied"
  only when the text was copied.
- A unit check keeps `crypto.randomUUID` and `navigator.clipboard` out
  of everything but these two helpers.
- Tests: the fallback's format, version and variant bits, and
  uniqueness; in a browser with both APIs removed before the app loads,
  a plan (which makes a request ID) opens, and Copy as sqb build copies.
…nd help copy a secret by hand

- The fallback copy puts back the person's own selection and focus,
  without scrolling, after copying from its hidden textarea.
- When a one-time secret can't be copied, it is selected, with a hint to
  copy it with Ctrl+C (⌘C on a Mac).
@kvlonge
kvlonge enabled auto-merge November 18, 2026 19:41
@kvlonge
kvlonge added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit d30811b Nov 18, 2026
33 checks passed
@kvlonge
kvlonge deleted the fix/ui-ids-without-secure-context branch November 18, 2026 20: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.

1 participant