Skip to content

fix(cli): make WSL image paste use PowerShell STA + PNG format - #2510

Open
mangeshraut712 wants to merge 1 commit into
MoonshotAI:mainfrom
mangeshraut712:cursor/fix-wsl-clipboard-image-sta-7813
Open

fix(cli): make WSL image paste use PowerShell STA + PNG format#2510
mangeshraut712 wants to merge 1 commit into
MoonshotAI:mainfrom
mangeshraut712:cursor/fix-wsl-clipboard-image-sta-7813

Conversation

@mangeshraut712

Copy link
Copy Markdown
Contributor

Summary

  • Run the WSL → Windows clipboard helper as powershell.exe -STA so WinForms Clipboard APIs work (default MTA made GetImage() return null) (fixes kimi-code在wsl中的图片粘贴问题 #2425).
  • Prefer the PNG clipboard format, then fall back to GetImage().

Test plan

  • pnpm exec vitest run test/utils/clipboard/clipboard-image.test.ts in apps/kimi-code (7 passed)

Fixes #2425

WinForms Clipboard APIs require a single-threaded apartment; without
-STA, GetImage() silently returned null so Ctrl+V did nothing in WSL.
Also prefer the PNG clipboard format before GetImage (fixes MoonshotAI#2425).
@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0265111

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 Aug 1, 2026

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

commit: 0265111

@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: 0265111eca

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

' }',
'}',
"if ($ok) { Write-Output 'ok' } else { Write-Output 'empty' }",
].join('; ');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Join the PowerShell block with newlines

When the WSL fallback runs, joining these control-flow fragments with '; ' generates constructs such as if (...) {; $stream = ..., which Windows PowerShell rejects as a parse error. The command therefore fails before accessing the clipboard and this function returns null; the added mock test misses the regression because it never parses or executes the generated script. Join the fragments with newlines, or avoid inserting a separator immediately after opening braces.

Useful? React with 👍 / 👎.

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.

kimi-code在wsl中的图片粘贴问题

1 participant