fix: disable Rich Live transient mode on Windows to prevent PS 5.1 hang#2938
Open
mnriem wants to merge 3 commits into
Open
fix: disable Rich Live transient mode on Windows to prevent PS 5.1 hang#2938mnriem wants to merge 3 commits into
mnriem wants to merge 3 commits into
Conversation
d520ae6 to
d3fead3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a Windows-specific hang in PowerShell 5.1 by disabling Rich Live(transient=True) cleanup behavior on win32, preventing deadlock during cursor restoration.
Changes:
- Set
transient=Falseon Windows for theLiveprogress UI inspecify init. - Set
transient=Falseon Windows for theLiveUI used by_console.select_with_arrows(). - Add regression tests to confirm the
win32platform guard remains present.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/commands/init.py |
Disables Live(transient=True) on Windows during init scaffolding progress rendering. |
src/specify_cli/_console.py |
Disables Live(transient=True) on Windows for the interactive arrow-key selection UI. |
tests/test_live_transient_windows.py |
Adds regression tests covering the Windows transient behavior and guarding against removal of the platform check. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
d3fead3 to
f71cb2f
Compare
PowerShell 5.1's legacy console host does not reliably support VT escape sequences. Rich's Live(transient=True) attempts cursor restoration on context exit, which hangs indefinitely on that console. Set transient=False when sys.platform == 'win32' in both init.py (progress tracker) and _console.py (select_with_arrows). The only cosmetic effect is that progress output remains visible after completion on Windows. Fixes #2927 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f71cb2f to
984efd8
Compare
- Use captured['transient'] instead of .get() for clearer KeyError on failure - Source guards now assert both the platform check AND transient=_transient usage - Remove unused imports (MagicMock retained as it's used, removed pytest) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
+75
to
+88
| init_src = Path(__file__).resolve().parent.parent / "src" / "specify_cli" / "commands" / "init.py" | ||
| content = init_src.read_text(encoding="utf-8") | ||
| assert re.search(r"sys\.platform\s*!=\s*['\"]win32['\"]", content) | ||
| assert re.search(r"transient\s*=\s*_transient", content) | ||
|
|
||
| def test_console_has_win32_guard(self): | ||
| """_console.py must check platform and pass transient to Live.""" | ||
| import re | ||
|
|
||
| console_src = Path(__file__).resolve().parent.parent / "src" / "specify_cli" / "_console.py" | ||
| content = console_src.read_text(encoding="utf-8") | ||
| assert re.search(r"sys\.platform\s*!=\s*['\"]win32['\"]", content) | ||
| assert re.search(r"transient\s*=\s*_transient", content) | ||
| assert "transient=_transient" in content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2927 —
specify inithangs indefinitely on Windows PowerShell 5.1 after writing files.Root Cause
Rich's
Live(transient=True)attempts cursor restoration via VT escape sequences when the context manager exits. PowerShell 5.1's legacy console host (conhost.exe) does not reliably support these sequences, causing the cleanup to deadlock.The hang occurs at line 297 of
init.pywhen theLiveblock exits — after all files have been written successfully but before "Project ready" prints.Fix
Set
transient=Falsewhensys.platform == "win32"in both locations that useLive(transient=True):src/specify_cli/commands/init.py— progress tracker during scaffoldingsrc/specify_cli/_console.py—select_with_arrows()interactive menuThe only cosmetic effect is that progress output remains visible after completion on Windows (not erased). No functional impact.
Tests
Added
tests/test_live_transient_windows.pywith 5 tests:Liveconstructor viaselect_with_arrows()and verify the correcttransientkwarg under patchedsys.platform(win32, linux, darwin)transient=_transientusage exist in both files