Skip to content

fix(web): make clipboard copy work over plain HTTP#1044

Merged
wbxl2000 merged 2 commits into
mainfrom
fix/web-clipboard-copy
Jun 23, 2026
Merged

fix(web): make clipboard copy work over plain HTTP#1044
wbxl2000 merged 2 commits into
mainfrom
fix/web-clipboard-copy

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

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.clipboard is 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.clipboard when available and falls back to a temporary textarea + execCommand('copy') in insecure contexts. Copy actions now also surface success or failure feedback instead of failing silently.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

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-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 21c8bde

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@21c8bde
npx https://pkg.pr.new/@moonshot-ai/kimi-code@21c8bde

commit: 21c8bde

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/kimi-web/test/clipboard.test.ts Outdated
@@ -0,0 +1,68 @@
// @vitest-environment jsdom

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep web tests out of jsdom

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().
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 21c8bde258

ℹ️ 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".

@wbxl2000 wbxl2000 merged commit 9d197e0 into main Jun 23, 2026
8 checks passed
@wbxl2000 wbxl2000 deleted the fix/web-clipboard-copy branch June 23, 2026 14:21
@github-actions github-actions Bot mentioned this pull request Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant