Filter UI chrome out of cmd.exe / Windows Terminal review output#13
Open
serrebidev wants to merge 3 commits into
Open
Filter UI chrome out of cmd.exe / Windows Terminal review output#13serrebidev wants to merge 3 commits into
serrebidev wants to merge 3 commits into
Conversation
added 3 commits
May 15, 2026 19:06
When the focused UWP window hosts a TermControl child (cmd.exe and other
shells running inside Windows Terminal), obtainUWPWindowText() previously
appended every non-None child name during the tree walk. That pulled in
the window title repeated as child element names, the "Close Tab" button,
the four scroll-bar parts ("Vertical Small/Large Decrease/Increase"), and
the "System" menu — all interleaved with the actual terminal text.
Detect TermControl during the walk; when one is present anywhere in the
foreground window, return only [title, terminal text] and drop the chrome.
Non-terminal UWP apps fall through to the existing behavior unchanged.
In addition to the chrome elements stripped above, capturing the full TermControl story also returns space-padded blank rows for any visible terminal cell that hasn't been written to. TUI apps such as Claude Code, vim, htop, lazygit etc. paint content at the top of the buffer and a status/input row at the bottom, leaving a large empty band in the middle that becomes a long run of blank lines in the review window. Add _cleanTerminalText() that: - Strips per-line trailing whitespace (removes the column padding) - Collapses 2+ consecutive blank lines into a single blank line - rstrips the final result This preserves intentional single-blank-line spacing (e.g. the blank between "All rights reserved." and the cmd prompt) while eliminating the long visual gap, and tightens cmd output as a side benefit.
The previous commit collapsed runs of blank padding to a single blank line, but in TUI apps that paint boxed UIs (Claude Code, lazygit, gh dash) every box-row gap also produces "│ │" lines that aren't blank and so survive the collapse. Reviewing the result line-by-line still required pressing arrow keys through dozens of decorative rows between content paragraphs. Replace the collapse logic with a stricter filter: after per-line rstrip, drop any line whose only non-whitespace characters are in the Unicode Box Drawing block (U+2500-U+257F). Truly blank lines fall under the same predicate (empty stripped == decorative) so they're removed too. Content lines that include "│" borders survive because the letters between the borders fall outside the range. Tradeoff: cmd output loses its single-blank line between the copyright banner and the prompt. For the audience most affected (NVDA users navigating the review window with up/down arrow), eliminating the decorative-line wading is the bigger win.
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
When the focused UWP window hosts a
TermControlchild (cmd.exe, PowerShell, etc. running inside Windows Terminal),obtainUWPWindowText()appended every non-Nonechild element name during the tree walk. For a typicalcmd.exewindow that produces output like:The window title repeats as several child element names, and the tab Close button, the four scroll-bar parts, and the System menu all get interleaved with the actual terminal output.
This change detects a
TermControlduring the walk; when one is present anywhere in the foreground window, the function returns just[title, terminal text]and drops the chrome. Non-terminal UWP apps (Start menu, Settings, etc.) fall through to the existing behavior unchanged, so there's no regression risk for those.A small
_isTermControlhelper is extracted since the samehasattr / UIAElement / currentClassNamecheck now needs to happen in three places.Test plan
ConsoleWindowClasscmd window — unchanged (handled by separate code path)TermControlpresent, falls through)🤖 Generated with Claude Code