Repository navigation
Unsloth Studio: make a newly created API key selectable when the clipboard is unavailable - #11489
Conversation
…board is unavailable
|
Confirmed main still renders the token inside the copy button in key-reveal-card.tsx, so a failed clipboard call leaves nothing selectable, and I checked that mirrorFieldState in reload-snapshot.js does strip value on a sensitive input. Note #9906 covers the same ground, so I will pick between the two when I review this. |
…vent
Inside a modal dialog on a plain http:// origin, the fallback textarea is appended outside the dialog's focus trap, focus is pulled back, and execCommand("copy") copies an empty selection while still returning true. Set the payload from a capture-phase copy listener and report success only when it was written.
The recipe-studio copyTextToClipboard duplicated the textarea fallback and reported execCommand's result, so inside a dialog on a plain http:// origin it claimed success with an unchanged clipboard. Several audio and Codex-connect copies called navigator.clipboard.writeText directly, which is undefined over plain http:// and in the desktop shell. All now use the shared helper, keeping their existing toasts.
|
Pushed three commits on top of the original change (head
Codex review on the same head: Lyxot#71 (comment) ("Didn't find any major issues", reviewed commit CI on the same head (staging run, Lyxot#71): 41 passed, 4 failed. None of the 4 failures touches this PR's files. Three fail identically on
|
…board is unavailable (unslothai#11489) * Unsloth Studio: make a newly created API key selectable when the clipboard is unavailable * fix(studio): write the execCommand clipboard fallback from the copy event Inside a modal dialog on a plain http:// origin, the fallback textarea is appended outside the dialog's focus trap, focus is pulled back, and execCommand("copy") copies an empty selection while still returning true. Set the payload from a capture-phase copy listener and report success only when it was written. * docs(studio): clarify why the new API key is preselected * fix(studio): route remaining text copies through copyToClipboard The recipe-studio copyTextToClipboard duplicated the textarea fallback and reported execCommand's result, so inside a dialog on a plain http:// origin it claimed success with an unchanged clipboard. Several audio and Codex-connect copies called navigator.clipboard.writeText directly, which is undefined over plain http:// and in the desktop shell. All now use the shared helper, keeping their existing toasts. --------- Co-authored-by: Lyxot <[email protected]>
Fixes #11387, fixes #9899. Supersedes #9906 with a one-file change on current main.
Problem
On a plain
http://Unsloth Studio (a LAN address rather than localhost) the browser exposes nonavigator.clipboard, and theexecCommandfallback can refuse too.key-reveal-card.tsxrendered the new token inside the copy<button>, so when the copy failed the token wasn't selectable either: the click did nothing, the text couldn't be dragged over, and the only way to get the key was the DOM inspector.Change (
studio/frontend/src/features/settings/components/key-reveal-card.tsxonly)<input>beside a separate copy button, so it can always be selected and copied by hand.data-reload-snapshot-sensitivemoves to the input, andmirrorFieldStateinreload-snapshot.jsalready stripsvalueon a sensitiveINPUT, so the token stays out of the reload snapshot.No new strings, so locale parity is unaffected.
Testing (at
96e81b8024)biome checkandeslinton the file: clean.npm run typecheck: the app project passes.tsconfig.test.jsonhas one pre-existing error intests/sidebar-row-drag.test.tsthat this PR doesn't touch.npm test: 8217 passed, 0 failed.Browser check on Linux (WSL2, Ubuntu 24.04) with Playwright headless Firefox 155 and Chromium 153, real input events. A static page served from inside WSL carried main's
copyToClipboardbehind a button (before) and this PR's read-only input, selected on load, followed by Ctrl+C (after). Pass means the pasted value matched the token.http://127.0.0.1writeTexthttp://172.19.x.xexecCommandfallbackhttp://127.0.0.1execCommandfallback (headless deniesclipboard-write; desktop Chrome grants it on a click)http://172.19.x.xexecCommandfallbackThe copy button on main already copies on a plain
http://LAN origin in both engines, so the "copy does nothing" report on Firefox and Brave on Linux is not reproduced here. Headless browsers use an in-process clipboard, so a desktop clipboard problem (X11 or Wayland) or a Brave shield would not show up in this table. What holds in every row is that the token on main could not be selected at all, and with this PR it is selected on reveal and Ctrl+C copies it.Not yet run inside Unsloth Studio itself over a LAN
http://URL; that check is in progress on a second machine.