Skip to content

[codex] fix(apikeys): support clipboard fallback on HTTP - #2018

Draft
lihaojiee wants to merge 1 commit into
looplj:unstablefrom
lihaojiee:codex/fix-api-key-copy-http
Draft

[codex] fix(apikeys): support clipboard fallback on HTTP#2018
lihaojiee wants to merge 1 commit into
looplj:unstablefrom
lihaojiee:codex/fix-api-key-copy-http

Conversation

@lihaojiee

Copy link
Copy Markdown
Contributor

Summary

  • add a shared clipboard utility for API key copy actions
  • use the modern Clipboard API when available and a DOM copy command when it is unavailable
  • migrate API key table, view dialog, base URL, rotation result, and masked code example copy actions to the shared implementation
  • show success feedback only after the text has actually been copied

Problem

When AxonHub is opened from a non-secure HTTP origin, such as a LAN deployment, navigator.clipboard is unavailable. Clicking an API key copy button throws Cannot read properties of undefined (reading 'writeText'), so nothing is copied and the page provides no useful failure feedback.

The API key page also had several independent clipboard implementations with inconsistent success and error handling.

Fix

  • introduce copyTextToClipboard as the single low-level clipboard implementation
  • prefer navigator.clipboard.writeText on secure origins
  • use a temporary read-only textarea and document.execCommand('copy') only when the Clipboard API is unavailable
  • throw when both copy mechanisms fail, allowing the shared hook to display the existing localized failure toast
  • honor the hook's custom success message and update copied-state only after a successful copy

The legacy copy command is intentionally limited to non-secure origins where the modern Clipboard API is unavailable.

Validation

  • rebased the change onto the latest upstream/unstable
  • IntelliJ inspections report no errors in the six changed files
  • TypeScript transpileModule parsing passed for all changed TypeScript/TSX files
  • git diff --check passed, including the new file
  • confirmed that the repaired API key scope no longer calls navigator.clipboard directly

Full frontend lint/build was not run locally because the repository instructions prohibit running lint or build commands unless explicitly requested. The upstream PR CI will run the configured frontend build and repository checks.

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