fix(web): make clipboard copy work over plain HTTP#1044
Conversation
The Clipboard API (navigator.clipboard) is only exposed in secure contexts. When the web UI is served over plain HTTP, every copy action threw synchronously and silently failed. Route all copy call sites through a helper that falls back to execCommand('copy') in insecure contexts, and surface success or failure feedback to the user.
🦋 Changeset detectedLatest commit: 21c8bde The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 711bb8ac8d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -0,0 +1,68 @@ | |||
| // @vitest-environment jsdom | |||
There was a problem hiding this comment.
The package guide in apps/kimi-web/AGENTS.md says the web test suite is for “pure logic tests only; no jsdom / component tests.” This pragma makes the new clipboard test require jsdom, so @moonshot-ai/kimi-web tests now depend on the browser test environment that this package explicitly avoids; please mock the small navigator/document surface in the default node environment instead.
Useful? React with 👍 / 👎.
- clipboard test: drop the jsdom environment and mock the small navigator/document surface in the default node environment, per the kimi-web "pure logic tests only" rule.
- footer-goal-badge test: assert the absence of the "[goal" badge instead of the bare "goal" substring, which could match a rotating working tip ("/goal ...") and fail depending on Date.now().
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Related Issue
No linked issue — reported directly by a user.
Problem
Copy actions in the web UI (copy session ID, copy workspace path, copy messages and code blocks, etc.) silently did nothing when the UI was served over plain HTTP.
navigator.clipboardis only exposed in secure contexts, so the call threw synchronously and the existing.catch()handlers never ran.What changed
Routed every web copy call site through a single clipboard helper that uses
navigator.clipboardwhen available and falls back to a temporarytextarea+execCommand('copy')in insecure contexts. Copy actions now also surface success or failure feedback instead of failing silently.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.