Skip to content

Fix Virtual Review in modern command-line windows (Windows Terminal) - #16

Closed
serrebidev wants to merge 1 commit into
ruifontes:masterfrom
serrebidev:fix-terminal-review
Closed

serrebidev wants to merge 1 commit into
ruifontes:masterfrom
serrebidev:fix-terminal-review

Conversation

@serrebidev

Copy link
Copy Markdown

Problem

control+NVDA+w (Virtual Review) stopped working in many command-line windows. On Windows 11, cmd/PowerShell/WSL run inside Windows Terminal, where the text is exposed through a UIA TermControl element rather than the legacy console buffer.

The current code only reaches that control by walking down from the foreground window's children in obtainUWPWindowText(). That approach:

  • misses the active tab / split pane (or grabs the wrong one), and
  • aborts the whole command with no output if any UIAElement.currentClassName access raises a COM error while iterating.

Fix

  • Add an exception-safe _isTermControl() helper and reuse it for the existing inline checks (so a single failing object can no longer stop the command).
  • Add _findTermControl(), which finds the TermControl by walking up from the focused object.
  • In the review script, detect the terminal first and capture the text directly from the focused control, so it works across every tab and split pane regardless of the host window's class name.

Legacy ConsoleWindowClass consoles and the generic display-model path are unchanged.

Testing

Verified with control+NVDA+w in Windows Terminal running cmd, PowerShell and WSL, including multiple tabs and split panes, plus a legacy conhost console. NVDA 2026.1 on Windows 11.

🤖 Generated with Claude Code

On Windows 11, cmd/PowerShell/WSL run inside Windows Terminal, where the
text lives in a UIA "TermControl" rather than the legacy console buffer.
The previous code only reached it by walking down from the foreground
window's children, which misses the active tab/pane and aborts entirely
if any UIAElement.currentClassName access raises a COM error.

Detect the terminal directly from the focused control (walking up its
ancestors) and capture straight from there, so control+NVDA+w works
across every tab and split pane regardless of the host window's class
name. Detection is now exception-safe, so a single failing object can no
longer stop the review command.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serrebidev

Copy link
Copy Markdown
Author

This PR is the core fix — it restores control+NVDA+w in modern command-line windows.
Part of a three-PR set that splits a batch of Windows Terminal / command-line review improvements into independent, single-purpose changes. Each is branched off master and touches only addon/globalPlugins/virtualRevision.py, so they can be reviewed and merged in any order (or accepted/rejected independently):

Notes for review:

  • They edit the same file, so whichever merges first will leave the others needing a trivial rebase — happy to do that on request.
  • I deliberately left the addon_version / addon_changelog bump in buildVars.py out: it's date-based and yours to set at release, and three parallel branches would otherwise all conflict on that one line. Tell me the version you'd like and I'll add the changelog entry.
  • Verified on NVDA 2026.1 / Windows 11 (Windows Terminal running cmd, PowerShell and WSL, plus a legacy conhost console).

@ragb

ragb commented Aug 24, 2026

Copy link
Copy Markdown

Ported to ragb#5, where maintenance now continues. Credited via Co-Authored-By. Thanks @serrebidev.

@serrebidev

Copy link
Copy Markdown
Author

Ported with credit and merged in the maintained repository as ragb#5. Closing this obsolete PR in the old repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants