Skip to content

fix(cli): treat CRLF as paste in passthrough mode#1456

Draft
liqiongyu wants to merge 1 commit into
QwenLM:mainfrom
liqiongyu:fix/299-windows-paste-crlf
Draft

fix(cli): treat CRLF as paste in passthrough mode#1456
liqiongyu wants to merge 1 commit into
QwenLM:mainfrom
liqiongyu:fix/299-windows-paste-crlf

Conversation

@liqiongyu

Copy link
Copy Markdown
Contributor

Fixes #299.

Windows paste workaround (stdin passthrough) can receive a standalone CRLF chunk during multiline paste. Treating it as a normal return can trigger submit and break pasting.

Changes:

  • Treat standalone as a paste event in passthrough mode.
  • Add a regression test for the CRLF case.

Tests:

  • npx vitest packages/cli/src/ui/contexts/KeypressContext.test.tsx --run

@liqiongyu liqiongyu force-pushed the fix/299-windows-paste-crlf branch from cdf94fc to ba0f6ad Compare January 10, 2026 07:34
@liqiongyu

Copy link
Copy Markdown
Contributor Author

Follow-up: keep the non-bracketed paste heuristic CR-only (same as before) and keep the change scoped to treating standalone CRLF chunks as paste events.

@tanzhenxin

Copy link
Copy Markdown
Collaborator

@liqiongyuThanks for your PR! Copy-paste behavior on Windows can be quite subtle, and we’ve previously spent a fair amount of time trying to debug similar issues.

To make sure we handle this correctly, could you confirm whether you’re able to reliably reproduce the issue? If so, it would be really helpful if you could share clear and reliable reproduction steps.

Thanks a lot for your help!

@liqiongyu

Copy link
Copy Markdown
Contributor Author

Thanks for the careful check!

I don’t have a Windows machine available at the moment, so I can’t personally confirm reproduction in Windows Terminal/PowerShell.

That said, the bug is specific to stdin passthrough mode on Windows: during multiline paste, some terminals can emit a standalone CRLF chunk (\r\n). Previously we could interpret that \r as an Enter/submit mid-paste.

Repro suggestion (Windows 10/11, Windows Terminal + PowerShell):

  1. Start qwen (paste workaround / passthrough is enabled by default on win32).

  2. In PowerShell, populate clipboard with a large CRLF-separated payload (to increase the chance of chunking):

$txt = (1..5000 | ForEach-Object { "line$_" }) -join "`r`n"
Set-Clipboard -Value $txt
  1. Back in qwen, press Ctrl+V to paste into the prompt.

Expected: content is inserted (with newlines) without submitting mid-paste.
Before fix: paste could prematurely submit / truncate when the standalone CRLF chunk was interpreted as Enter.

I also added a regression test that simulates exactly this input chunk: packages/cli/src/ui/contexts/KeypressContext.test.tsx ("treats standalone CRLF as a paste event in passthrough mode").

If you (or someone on Windows) can run the above steps and confirm, that’d be great — happy to adjust if you observe different behavior.

@tanzhenxin

Copy link
Copy Markdown
Collaborator

@liqiongyu Understood. I prefer not to merge this PR until we can reproduce the issue and confirm that it is indeed the root cause. That said, we’ll keep an eye on it and revisit if similar issues come up in the future.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has had no activity for 60 days and is being marked as stale. It will be closed in another 30 days if no further activity occurs. To keep it open, push a new commit or leave a comment. Maintainers may apply pinned, status/blocked, status/on-hold, or status/ready-for-merge to exempt it from auto-close.

@github-actions github-actions Bot added the status/stale No activity for extended period label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/stale No activity for extended period

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the paste is not working properly, I am not able to paste multiline errors. Also new lines should be shift+enter instead of alt+enter

2 participants