fix(windows): keep VT enabled during progress#1465
fix(windows): keep VT enabled during progress#1465shaanmajid wants to merge 2 commits intoj178:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1465 +/- ##
==========================================
+ Coverage 91.65% 91.67% +0.02%
==========================================
Files 90 90
Lines 17813 17845 +32
==========================================
+ Hits 16326 16359 +33
+ Misses 1487 1486 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.2 MiB → 23.2 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
f7e1e45 to
762d114
Compare
|
Keeping in draft until @chrisoro or someone with a Windows machine can confirm this actually fixes the issue lolol |
|
Any chance to build arm64 version of it? I won't have access to my amd64 win machine until end of next week. I do have windows on arm as a vm on my mac |
|
Just did a dummy change to @chrisoro The link for the ARM Windows standalone binary specifically is https://github.com/j178/prek/actions/runs/21322541711/artifacts/5245733919. Looks like it's a zip file in another zip file lol, but the inner zip has a Let me know how it goes! |
|
Tried the arm executable and it shows the same errors in both cmd and powershell. Maybe it is the region/language setting in Windows? Mine is set to Germany / German |
bf6d4cc to
dd596f1
Compare
|
Sad, can you try the latest build? Tried some more changes. |
|
Nice, this seems to have done the trick. I can't overserve the broken output anymore. See: https://streamable.com/qaa5qs |
|
Awesome! Just to confirm, you were able to consistently reproduce in both cmd and powershell in prek 0.3.0, but the bug is consistently gone in both shells with the fix? |
|
Correct. I only did it in my Win11 ARM VM and not x86 but that shouldn't matter, right? |
51e4656 to
d31b4bd
Compare
Some Windows hook installers (uv, pip, npm, cargo) disable ENABLE_VIRTUAL_TERMINAL_PROCESSING on exit, which causes indicatif's progress output to render as raw ANSI escape sequences. Re-enable VT mode after subprocess output() and status() calls to restore console state before prek resumes its own output.
Subprocesses like uv/pip/npm can disable ENABLE_VIRTUAL_TERMINAL_PROCESSING while indicatif's spinner is actively rendering, causing raw ANSI escape sequences to appear mid-install. Add a Windows-only background thread that re-enables VT mode every 200ms (matching the spinner tick rate) while progress bars are visible. The thread is scoped to ProgressReporter lifetime and only spawns when color is enabled.
d31b4bd to
47a215d
Compare
|
@j178 no pressure, but not sure if you saw this, it was in draft for a while haha. Any concerns? |
|
Yeah, I've been keeping an eye on this. Thanks for the hard work! But the solution feels a bit unusual to me. I'm not sure if any other projects run into the same issue or handle it this way. Having a background thread constantly re‑enabling VT just seems a little unfortunate to me :( |
Some Windows hook installers (uv, pip, npm, cargo) disable
ENABLE_VIRTUAL_TERMINAL_PROCESSINGon exit, which causes indicatif's progress output to render as raw ANSI escape sequences duringprek install.This PR attempts two fixes:
output()andstatus()calls (148fe45)Notably, the first alone did not fix the issue (see #1465 (comment)), but the second did.
Video of issue behavior: https://github.com/user-attachments/assets/10b75c59-f528-4a5e-95cd-c1987ee5de4a
Video of behavior after fix: https://github.com/user-attachments/assets/531000c8-32c7-4d98-a6a9-b1ab05e25582
(both courtesy of @chrisoro)
Fixes #1237