fix(windows): resolve compatibility, path resolution, and encoding issues - #42775
fix(windows): resolve compatibility, path resolution, and encoding issues#42775necoweb3 wants to merge 3 commits into
Conversation
Positive Verification — Windows Compatibility ReviewReviewed the full diff across Changes verified:
No issues found. The pytest timeout-method change is the most impactful — signal-based timeout can hang on Windows. Thread-based timeout is the documented cross-platform alternative. The path normalization fixes are correct for WSL/Cygwin/mingw edge cases. |
austinpickett
left a comment
There was a problem hiding this comment.
Hermes Agent Review — #42775 (Windows compatibility)
Reviewed locally against origin/main (real scope = the 3 files GitHub lists; ran the static checker + the cited ACP suites). Two of the three changes are correct and I verified them — but the pyproject.toml change directly conflicts with the canonical, already-reviewed #39881 and takes the inferior approach. Requesting changes to split that one hunk out; the rest is good and I'd happily approve it on its own.
Verified good ✅
1. scripts/check_subprocess_stdin.py — all four sub-changes correct.
sys.stdout.reconfigure(encoding='utf-8')is properly guarded (hasattr+ try/except) — safe no-op where unsupported.[FAIL]/[PASS]instead of emoji — avoidsUnicodeEncodeErroron cp1252 consoles.read_text(encoding='utf-8')— correct; the default is locale-dependent (cp1252) on Windows..as_posix()for theKNOWN_SAFElookup — this is a real bug fix, not cosmetic:KNOWN_SAFEentries use forward slashes (agent/shell_hooks.py), so on Windows the oldstr(relative_to(...))producedagent\shell_hooks.pyand the exemption silently never matched..as_posix()fixes it and is a no-op on Unix.- Confirmed:
python scripts/check_subprocess_stdin.py→[PASS], exit 0.
2. acp_adapter/server.py — both changes correct.
os.name == 'nt'short-circuit in_path_from_file_uri— on native Windows, returns the realC:/.../C:\...path instead of the WSL-only/mnt/<drive>/...rewrite, which would point at a nonexistent path for a Windows-host editor (e.g. Zed on Windows). Non-nt path is unchanged. Correct, and aligns with #40649.- CRLF normalization in
_decode_text_bytes— conservative (\r\n→\nonly, leaves lone\r), refactored cleanly to a single return. Harmless for text-resource content fed to the agent. - Confirmed:
tests/acp_adapter/test_acp_images.py+tests/acp/test_events.py→ 27 passed (withpytest-asyncio). No regression from these changes.
Blocking 🔴
3. pyproject.toml — conflicts with the canonical #39881; please drop this hunk.
This edits the exact same addopts line that #39881 owns, but differently and in a way that contradicts the approved direction:
- #39881 (canonical, reviewed):
--timeout-method=signal→--timeout-method=thread— explicitly standardizes onthreadon all platforms. - This PR: removes
--timeout-methodentirely, relying on pytest-timeout's auto-default (threadon Windows,signalon Unix).
The net effect is the opposite of what #39881 intends: your version re-introduces the signal method on Unix, which #39881 deliberately moved away from (signal-based timeouts can't interrupt blocking C calls and misbehave under threads). The two also can't both merge cleanly since they touch the same line.
The Windows symptom you describe (SIGALRM crash) is genuinely fixed by #39881's explicit thread just as well — so please remove the pyproject hunk from this PR and let #39881 carry it. That keeps this PR focused on its two unique, correct Windows fixes. (Same pattern as the stray timeout hunk we asked #41754 to split out — pyproject timeout config has one canonical home.)
Bottom line
Drop the pyproject.toml change (defer to #39881); keep the check_subprocess_stdin.py and acp_adapter/server.py fixes. With that split, this is an easy approve — both unique changes are verified correct.
Reviewed by Hermes Agent (verified locally against origin/main).
| @@ -305,7 +305,7 @@ markers = [ | |||
| # scripts/run_tests_parallel.py). Per-file isolation gives every test | |||
| # file a fresh Python interpreter; pytest-timeout catches Python-level | |||
| # hangs within a file. | |||
| addopts = "-m 'not integration' --timeout=30 --timeout-method=signal" | |||
| addopts = "-m 'not integration' --timeout=30" | |||
There was a problem hiding this comment.
🔴 Conflicts with #39881 — please drop this hunk. #39881 (canonical, already reviewed) changes this same line to --timeout-method=thread (explicit thread on all platforms). Removing the flag instead falls back to pytest-timeout's auto-default, which is thread on Windows but signal on Unix — re-introducing the exact method #39881 deliberately moved away from, and the two edits can't both merge. Your Windows SIGALRM crash is fixed equally by #39881's explicit thread. Keep this PR's two unique Windows fixes and let #39881 own the timeout config.
|
Thanks for the update and @liuhao1024 for the verification — the two unique Windows fixes in The pyproject.toml hunk still needs to be dropped before this can merge. Here's why: The current diff removes So the conflict is:
Both can't merge to the same line. Please drop the pyproject.toml hunk from this PR — #39881 owns that line. The two .py file changes in this PR are genuinely valuable on their own and I'll approve immediately once that hunk is out. |
554e303 to
8b13bf1
Compare
necoweb3
left a comment
There was a problem hiding this comment.
I've dropped the pyproject.toml changes and force-pushed the branch. The PR is now focused purely on the unique Windows fixes in check_subprocess_stdin.py and acp_adapter/server.py
teknium1
left a comment
There was a problem hiding this comment.
Thanks for preserving the two Windows-specific fixes after dropping the pyproject.toml hunk discussed by the maintainer review. Current main still has the ACP and checker behavior this PR targets.
Problems
acp_adapter/server.py:165-174rejects a raw drive path before the proposed native-Windows branch at diff line 182 can execute: generic non-fileURI rejection occurs immediately afterurlparse(raw). The stated bareC:\...case therefore remains unsupported.- No regression test covers native-Windows file URIs, raw drive paths, or CRLF decoding. Existing resource-link coverage uses
tmp_path.as_uri()attests/acp_adapter/test_acp_images.py:39-59.
Suggested changes
- Detect drive-form paths before generic URI-scheme rejection, then preserve the
os.name == "nt"behavior. - Add focused regression tests for both drive forms and CRLF normalization.
Automated hermes-sweeper review.
| drive = path_text[1].lower() | ||
| rest = path_text[3:].lstrip("/\\").replace("\\", "/") | ||
| return Path("/mnt") / drive / rest | ||
| if len(path_text) >= 2 and path_text[1] == ":" and path_text[0].isalpha(): | ||
| if os.name == "nt": | ||
| return Path(path_text) | ||
| drive = path_text[0].lower() |
There was a problem hiding this comment.
This branch is bypassed for raw C:\... input: urlparse(raw) is followed by the generic non-file scheme rejection before path_text reaches this drive-form check. Recognize Windows drive paths before that rejection and add a regression test for the bare-path case.
|
Updated the branch. Changes:
Validation:
|
536804a to
f4482fb
Compare
|
Updated the branch again. The latest CI failure was not from the ACP Windows path change; slice 7 was failing in Follow-up changes:
Validation:
|
Summary
This PR addresses multiple Windows-compatibility issues in the test runner, static regression check scripts, and the ACP adapter that currently block developer and CI workflows on Windows hosts.
Changes Included:
Static Regression Checking (
scripts/check_subprocess_stdin.py- Unique)sys.stdoutto force UTF-8 on launch to preventUnicodeEncodeErrorwhen writing outputs on non-UTF-8 Windows consoles.❌/✅) with standard tags ([FAIL]/[PASS]) to avoid terminal encoding crashes.encoding="utf-8"toPath.read_text()calls to preventUnicodeDecodeErrorwhen scanning files with Unicode comments or docstrings..as_posix()to resolve backslash separator mismatches (\\vs/) on Windows, ensuring file exemptions match correctly.ACP Adapter (
acp_adapter/server.py- Unique + Alignment)\r\nto\nin_decode_text_bytes()to prevent line-ending mismatches during local test runs for attached text files.os.name == "nt") in_path_from_file_uri()so that Windows host editors (e.g. Zed on Windows) do not have their local file URIs rewritten into nonexistent/mnt/<drive>/...paths (aligning with changes proposed in fix(acp): keep Windows file URIs native outside WSL #40649).Test Timeout Configuration (
pyproject.toml- Alignment)--timeout-method=signalfromaddopts(aligns with fix(tests): use cross-platform pytest-timeout method #39881).pytest-timeoutdefault automatically tothreadon Windows andsignalon Unix.Verification
python scripts/check_subprocess_stdin.pyyields[PASS] All TUI-context subprocess calls have explicit stdin=without crashes.pytest tests/acp_adapter/test_acp_images.pypasses cleanly on Windows using the fallbackthreadmethod automatically.