-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: resolve Claude Code integration hanging on Windows #5147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve Claude Code integration hanging on Windows #5147
Conversation
- Use stdin instead of command-line arguments for input - Fix command-line flags (--print, --input-format stream-json) - Add WSL execution wrapper for Windows This minimal fix addresses the Windows compatibility issue without restructuring the message format or prompt handling.
350e903 to
9d9f3b3
Compare
|
Thank you for the thorough review! You're absolutely right about the prompt restructuring being unnecessary for the Windows fix. I've updated the PR to include only the minimal changes needed:
All prompt formatting/restructuring has been removed. The changes are now focused solely on fixing the Windows compatibility issue as you suggested. The PR now contains just one file change with +53/-17 lines in |
|
Update: After testing the minimal approach, I discovered that some form of message transformation is actually necessary for Claude Code compatibility. Claude Code expects input in its SDKMessage format, where the message content needs to be properly formatted. Without this transformation, the connection succeeds but Claude Code cannot process the messages correctly. The current fix includes:
The message transformation is kept as minimal as possible - just wrapping the input in the required SDKMessage structure that Claude Code expects. |
…put in SDKMessage format via stdin. This minimal message transformation is necessary for compatibility.
…ession ID generation
|
@EchoingVesper I noticed that my wsl responds with a title change command in front of the correct output for some reason.
The correct JSON is right after that. I don't know if it's just me but I felt like I should mention it. |
I didn't run into that in my testing on my system, so I'm not sure, and I tested for a while last night on something else. I did notice, however, that it passes the entire system prompt and all mode prompts on every message, which burns through tokens like nothing else, and the AI responds as if it's a new chat on each message. I also noticed that sometimes portions of the context seem to be lost. I'm not sure how to fix these issues. Those weren't, however the actual bug I was trying to fix and I don't have time or energy to mess with it more today. I also notice there's another PR trying to fix Claude Code on Windows, so I'm unsure if this one is even necessary any longer. |
|
I've reviewed this PR and while I understand the hanging issue on Windows is real, I have some concerns about the implementation approach: Critical Issues:
Implementation Concerns:
Questions for Clarification:
The hanging issue definitely needs to be addressed, but it would be helpful to understand the specific failure mode better to ensure this solution is the right approach. |
|
Thank you for your contribution @EchoingVesper, we really appreciate it. While there's nothing wrong with the changes here, I believe the issue this PR was addressing has already been resolved by #5186. I'll go ahead and close this one for now, but feel free to reach out if you have any questions. Looking forward to seeing more contributions from you! |
Related GitHub Issue
Closes: #5097
Description
This PR fixes the Claude Code integration hanging issue on Windows by correcting the API usage. The original implementation used non-existent command-line flags (
-pfor messages,--system-prompt) and tried to pass large payloads via command-line arguments, hitting Windows' 8191 character limit.Key implementation details:
--print,--input-format stream-json,--output-format stream-jsontype,message, andsession_idfieldswsl.exeto execute Claude Code in WSLThe fix maintains backward compatibility with Linux/Mac while enabling Windows users to use Claude Code through WSL.
Test Procedure
Manual Testing Steps:
Testing Environment:
Command-line Verification:
The fix was validated by testing the corrected Claude Code command format directly:
wsl.exe -e bash -c 'echo "{\"type\":\"user\",\"message\":{\"role\":\"user\",\"content\":\"Hello\"},\"session_id\":\"test-123\"}" | claude --print --verbose --input-format stream-json --output-format stream-jsonPre-Submission Checklist
Screenshots / Videos
N/A - This is a backend integration fix with no UI changes.
Documentation Updates
The fix maintains the same user interface and configuration. Windows users can now use Claude Code seamlessly without
additional setup steps.
Additional Notes
This fix enables the Claude Code integration to work on Windows as originally intended. The solution is platform-aware and
doesn't affect Linux/Mac functionality. The implementation follows Claude Code's documented SDKMessage format for proper API
communication.
Get in Touch
Discord: echoingvesper
Important
Fix Claude Code integration on Windows by correcting API usage, using stdin for input, and ensuring WSL compatibility in
run.ts.--print,--input-format stream-json,--output-format stream-jsoninrunProcess().runProcess().type,message, andsession_idfields inrunProcess().wsl.exefor execution inrunProcess().processtochildProcessinrunClaudeCode()andrunProcess().run.tsto handle Windows compatibility while maintaining Linux/Mac functionality.This description was created by
for 3d667cf08b9c4c54d3f4ddba94c2bac96f200cc5. You can customize this summary. It will automatically update as commits are pushed.