Skip to content

fix(studio): make new API tokens selectable on plain HTTP - #9906

Closed
Souravrajvi0 wants to merge 9 commits into
unslothai:mainfrom
Souravrajvi0:feat/api-token-selectable-b930
Closed

Souravrajvi0 wants to merge 9 commits into
unslothai:mainfrom
Souravrajvi0:feat/api-token-selectable-b930

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9899

Problem

On http:// Studio installs (common for local/LAN use), the clipboard API is blocked. The new-token reveal UI wrapped the full API key in a click-to-copy button, so when automatic copy failed silently users could not select the token manually — they had to inspect the page DOM.

Fix

  • Show the token in a read-only <Input> with a separate copy button
  • Auto-focus and select the token when it is revealed (Ctrl+C works immediately)
  • Re-select the field and show a toast when automatic copy fails: "Couldn't copy automatically. Select the token and copy manually."

Testing

  • node --test tests/key-reveal-card.test.ts — 3 passed (source contracts for input, select-on-focus, copy-failure toast)

On http:// Studio installs the clipboard API is blocked, and the old
KeyRevealCard wrapped the token in a button so it could not be selected
manually when copy failed silently.

Show the token in a read-only input with a separate copy button, auto-
select on reveal, and toast with manual-copy guidance when automatic
copy fails.
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed this hits key-reveal-card.tsx, where handleCopy has no failure branch and the token sits inside a button so it cannot be selected when the clipboard API is unavailable. Will get this reviewed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-06T07:01:54.123301Z b093249 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 1afca32090

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga

Copy link
Copy Markdown
Member

Thanks @Souravrajvi0. I pushed two commits to the branch rather than send it back for a round trip.

copyAccessTokenFailed was only in en.ts, and the Locale parity job runs npm run i18n:check:strict, which fails on a key missing from any overlay, so CI was going to be red. Added the string to the other eleven locales.

The read-only <Input> also carried aria-label={t("settings.apiKeys.copyAccessToken")}, the same accessible name as the copy button beside it, so a screen reader announced the token field as a control that copies the token. It now uses newTokenCreated, which is already the visible heading above it. Same commit picks up the biome import-order and formatting output on the new lines.

Verified against a running Studio: the token lands in a read-only field that has focus and a full selection on mount (so Ctrl+C works immediately), the copy button still writes the token, and with every clipboard writer forced to fail the field is re-selected and the toast appears. Also confirmed the move from <code> to <input> keeps the token out of the reload snapshot -- mirrorFieldState in public/reload-snapshot.js strips the value attribute on a sensitive field, so the INPUT case is covered.

All 37 checks are green and Codex is clean on 1afca32.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 2da54025d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: f5101da764

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: b093249727

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

Checked this against main, where key-reveal-card.tsx still renders the token inside the copy button with no failure branch, so #9899 is still live and this addresses it. Thanks for the locale parity and aria-label follow-ups, nothing further needed from you.

@danielhanchen

Copy link
Copy Markdown
Member

Thank you for the PR and for tracking this down! Closing as superseded by #11489, which landed on main on 2026-09-22 and closed #9899.

Current main now renders the new token in a read-only input beside a separate copy button, focuses and selects it when the card appears so Ctrl+C works straight away, and re-selects the field when the copy button fails. That covers the plain HTTP case this PR addressed. The one piece not carried over is the copy failure toast; #11489 kept the change string-free so locale parity is unaffected, and re-selecting the field gives the same hint without a new translation key.

Thanks again, and thanks @oobabooga for the locale follow-ups along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Turn API Token into selectable text

3 participants