🐛 Handle clipboard API unavailable on access token copy (#8496) (#11156)

When copying an access token over plain HTTP (non-secure context), the
browser does not expose navigator.clipboard, causing to-clipboard to
return a rejected Promise. The caller was ignoring the Promise entirely,
so the rejection became an unhandled exception that crashed the UI.

Fix: chain .then/.catch on the returned Promise so that a successful
copy shows the existing success toast and a failure (including
insecure-origin) shows an error toast using the existing
errors.clipboard-api-unavailable translation key.

Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
0xTHAC0 2026-08-18 16:19:16 +05:30 committed by GitHub
parent b4bc3dfe6a
commit 904570f970
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,13 +79,19 @@
(mf/deps token-created)
(fn [event]
(dom/prevent-default event)
(clipboard/to-clipboard (:token token-created))
(st/emit! (ntf/show {:level :info
:type :toast
:content (if is-mcp
(tr "integrations.notification.success.mcp-key-copied")
(tr "integrations.notification.success.token-copied"))
:timeout notification-timeout}))))]
(-> (clipboard/to-clipboard (:token token-created))
(.then (fn [_]
(st/emit! (ntf/show {:level :info
:type :toast
:content (if is-mcp
(tr "integrations.notification.success.mcp-key-copied")
(tr "integrations.notification.success.token-copied"))
:timeout notification-timeout}))))
(.catch (fn [_]
(st/emit! (ntf/show {:level :error
:type :toast
:content (tr "errors.clipboard-api-unavailable")
:timeout notification-timeout})))))))]
[:div {:class (stl/css :modal-form)}
[:> text* {:as "h2"