fix(cli): make WSL image paste use PowerShell STA + PNG format - #2510
fix(cli): make WSL image paste use PowerShell STA + PNG format#2510mangeshraut712 wants to merge 1 commit into
Conversation
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 detectedLatest commit: 0265111 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: 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('; '); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
powershell.exe -STAso WinForms Clipboard APIs work (default MTA made GetImage() return null) (fixes kimi-code在wsl中的图片粘贴问题 #2425).Test plan
pnpm exec vitest run test/utils/clipboard/clipboard-image.test.tsinapps/kimi-code(7 passed)Fixes #2425