nvda
fdbb6c85 - Improve Windows Terminal caret tracking with delayed UIA updates (#20398)

Commit
22 days ago
Improve Windows Terminal caret tracking with delayed UIA updates (#20398) Related to #19503 ### Summary of the issue: Windows Terminal can update its UIA selection / caret position after NVDA's default 100 ms caret movement timeout, especially in remote terminal sessions such as SSH. When this happens, NVDA may speak from stale caret information after left/right arrow navigation. In practice, this can cause NVDA to report the previous or next character rather than the character at the current caret position. ### Description of user facing changes: NVDA should be less likely to report stale characters when moving the caret in Windows Terminal, including remote SSH sessions. This change is scoped to Windows Terminal controls. It does not change the default editable text caret movement timeout for other applications. ### Description of developer facing changes: Windows Terminal UIA overlays now use the existing editable text caret movement timeout multiplier mechanism. The `_caretMovementTimeoutMultiplier` class attribute is set to `3.0` for both Windows Terminal UIA strategies: - `_DiffBasedWinTerminalUIA` - `_NotificationsBasedWinTerminalUIA` With the default 100 ms editable text caret movement timeout, this gives Windows Terminal up to 300 ms for delayed UIA caret updates while reusing the existing `_hasCaretMoved` timeout path. This covers both the diff-based path shown in #19503 and the notification-based path tested locally. ### Description of development approach: The existing caret movement timeout workaround was first validated manually. Raising the timeout to 300 ms avoided stale character reporting in a high-latency Windows Terminal SSH session. A local scratchpad appModule prototype then applied a 0.300 second Windows Terminal-only timeout. This confirmed that giving Windows Terminal more time to update its UIA caret position works when applied to a Windows Terminal `TermControl`. The final change does not add a separate `_hasCaretMoved` wrapper. Instead, it reuses NVDA's existing `_caretMovementTimeoutMultiplier` mechanism, matching the approach already used elsewhere in `winConsoleUIA.py`. ### Testing strategy: Manual testing: - Reproduced stale character reporting in Windows Terminal over SSH with the default caret movement timeout. - Verified that increasing the caret movement timeout to 300 ms avoids the stale character reporting. - Verified a Windows Terminal-only scratchpad prototype using a 0.300 second timeout. - Confirmed the prototype applied to a `TermControl` object using `_NotificationsBasedWinTerminalUIA`. - Confirmed the `_hasCaretMoved` path ran with a 0.300 second timeout. Representative log excerpts from the prototype: - `Windows Terminal caret latency prototype appModule loaded from scratchpad/source` - `Windows Terminal caret latency prototype overlay inserted for UIA class 'TermControl'; appName='windowsterminal'` - `Windows Terminal caret latency prototype active: using minimum caret movement timeout 0.300 sec` NVDA+F1 developer info confirmed: - UIA className: `TermControl` - appModule.productName: `Microsoft.WindowsTerminal` - appModule.productVersion: `1.24.11321.0` - MRO included `_NotificationsBasedWinTerminalUIA` Local checks run: - `python -m py_compile source/NVDAObjects/UIA/winConsoleUIA.py` - `git diff --check` - `uvx ruff check --config pyproject.toml source/NVDAObjects/UIA/winConsoleUIA.py` Unit/system tests were not added for this small timing-specific UIA behavior change. The behavior depends on Windows Terminal UIA caret timing and was validated manually. ### Known issues with pull request: This uses a fixed multiplier of `3` for Windows Terminal. Further adjustments may be needed if maintainers prefer a different multiplier or a profile-only workaround.
Author
Parents
Loading