Repository navigation
fix(mcp): make Copy token work on HTTP deployments (#148) - #154
Merged
Merged
Conversation
The Agent connections token dialog used Mantine's CopyButton directly, which relies on navigator.clipboard. That API is unavailable on non-secure (HTTP) origins such as kobe:3000, so clicking Copy token threw silently and nothing was copied. Switch the page to the shared polyfilled CopyButton (execCommand fallback), report real failures via the new onError hook, and make execCommandCopy throw when the browser rejects the copy so success is only shown when copying actually succeeded. Manual selection-based copying remains possible and the token is still shown once and never persisted. Refs #148 Signed-off-by: Leo Stehlik <[email protected]>
Signed-off-by: Leo Stehlik <[email protected]>
Signed-off-by: Leo Stehlik <[email protected]> # Conflicts: # apps/client/src/wrenlore/mcp/agent-connections.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #148
Fixes: clicking Copy token in the once-only agent-token dialog did nothing on HTTP deployments (e.g.
http://kobe:3000).Root cause
AgentConnectionsimportedCopyButtonfrom@mantine/core, which usesnavigator.clipboarddirectly.navigator.clipboardis only exposed in secure contexts, so on plain-HTTP, non-localhost origins the click threw inside the handler and nothing was copied or reported. Every other copy surface in WrenLore already uses the shared polyfilledCopyButton(components/common/copy-button→useClipboard→execCommandCopyfallback); this page was the only one that didn't.Changes
agent-connections.tsxnow uses the sharedCopyButton(both the token dialog and the OpenCode config button).useClipboard/CopyButtongained anonErrorhook; the page shows an actionable red notification on failure ("select the text and copy with the keyboard") and only shows Copied when a copy actually succeeded.execCommandCopy(editor-ext) now checks thedocument.execCommand("copy")return value and throws when the browser refuses, instead of silently reporting success;copyToClipboardstays best-effort/non-throwing for its editor callers.Verification (disposable stack on kobe:3210, HTTP,
isSecureContext=false,navigator.clipboardabsent)Ctrl+Vpastes the exact 84-char token; token absent fromlocalStorage/sessionStorage.execCommand): no false "Copied", notification shown, token still selectable for manual copy.pnpm --filter @wrenlore/editor-ext test: 35/35 pass, incl. 4 new clipboard regression tests.Limitations
document.execCommand("copy")is deprecated but remains the only synchronous fallback for insecure contexts; when browsers remove it, HTTP deployments will need the manual-copy path (already supported) or HTTPS.Review follow-up: clear stale Copied status immediately when a later attempt fails; handle an unavailable clipboard method. The clipboard fixture now uses a generic test hostname.