Improve Windows Terminal caret tracking with delayed UIA updates#20398
Improve Windows Terminal caret tracking with delayed UIA updates#20398sheldon-im wants to merge 5 commits into
Conversation
|
Thanks for your contribution! I have some concerns about this route:
I think I prefer the multiplier approach instead of introducing yet another mechanism to fiddle with the timeout. In fact, the multiplier is already used for older editions of |
|
cc @codeofdusk |
|
Thanks for taking a look and for the detailed feedback. I missed the existing I've updated the PR to use the existing multiplier mechanism for the Windows Terminal UIA overlays and removed the custom timeout wrapper. Happy to adjust further depending on @codeofdusk's thoughts. |
|
Thanks for applying my feedback. I also think that you don't need to use an AutoPropertyGetter |
|
We used to have a caret movement multiplier before auto select detection was added to these objects, but it can make caret movement slow. See #12453. |
|
Thanks for the follow-up. I agree that the class-level override is simpler for the fixed multiplier case, and I can update that. For applying this to terminals in general, I think that needs a bit more consideration. I initially scoped this PR to Windows Terminal because that is where I could reproduce and manually validate the issue, and it kept the change small and reviewable. Broadening this to the shared |
True, but in a certain way that's kind of the point here. When using SSH, there may often be over 100ms of round-trip latency, so NVDA will end up reporting inaccurate caret positions. At least in Windows Terminal, cranking up the caret movement timeout doesn't seem to hurt perceived performance for me, though I only tested it briefly. That being said, on some connections there may be over 300ms of round-trip latency, in which case the same issue is going to come up. So I guess the goal here is to find a sweet spot that balances performance in local consoles where we don't get caret movement events, but works correctly over most remote connections. Clearly from my own experience and the comments of others, 100ms is too low for a lot of SSH connections, but 300ms feels almost uncomfortably high to me. @LeonarddeR, @codeofdusk, @seanbudd, @michaelDCurran, thoughts? |
| """ | ||
|
|
||
| def _get__caretMovementTimeoutMultiplier(self): | ||
| "Windows Terminal sessions can take a while to update the UIA caret. (#19503)" |
There was a problem hiding this comment.
| "Windows Terminal sessions can take a while to update the UIA caret. (#19503)" | |
| """Caret updates can take a while, particularly over remote connections such as SSH. (#19503)""" |
| """ | ||
|
|
||
| def _get__caretMovementTimeoutMultiplier(self): | ||
| "Windows Terminal sessions can take a while to update the UIA caret. (#19503)" |
There was a problem hiding this comment.
| "Windows Terminal sessions can take a while to update the UIA caret. (#19503)" | |
| """Caret updates can take a while, particularly over remote connections such as SSH. (#19503)""" |
|
Can we make sure this is documented clearly in the user guide? |
|
Thanks, that makes sense. I've updated the User Guide to document the Windows Terminal caret behavior, including delayed UIA caret updates over SSH, the related Caret move timeout setting, and the trade-off that increasing the timeout may make caret movement feel slower. I also changed the multiplier implementation to a class-level override as previously suggested. |
0a8f13e to
7cd2ae8
Compare
| Windows Terminal may delay UIA caret updates, especially in remote sessions over SSH. | ||
| NVDA waits slightly longer for caret movement in Windows Terminal, so it is less likely to report stale characters. | ||
| If caret reporting is still inaccurate, try increasing [Caret move timeout](#AdvancedSettingsCaretMoveTimeout) in Advanced settings. | ||
| Increasing this value may make caret movement feel slower, so consider changing it in a configuration profile for terminal applications. |
There was a problem hiding this comment.
Think you need to keep an empty line belone.
| Increasing this value may make caret movement feel slower, so consider changing it in a configuration profile for terminal applications. | |
| Increasing this value may make caret movement feel slower, so consider changing it in a configuration profile for terminal applications. | |
Link to issue number:
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
_caretMovementTimeoutMultiplierclass attribute is set to3.0for both Windows Terminal UIA strategies:_DiffBasedWinTerminalUIA_NotificationsBasedWinTerminalUIAWith 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
_hasCaretMovedtimeout 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
_hasCaretMovedwrapper. Instead, it reuses NVDA's existing_caretMovementTimeoutMultipliermechanism, matching the approach already used elsewhere inwinConsoleUIA.py.Testing strategy:
Manual testing:
TermControlobject using_NotificationsBasedWinTerminalUIA._hasCaretMovedpath ran with a 0.300 second timeout.Representative log excerpts from the prototype:
Windows Terminal caret latency prototype appModule loaded from scratchpad/sourceWindows 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 secNVDA+F1 developer info confirmed:
TermControlMicrosoft.WindowsTerminal1.24.11321.0_NotificationsBasedWinTerminalUIALocal checks run:
python -m py_compile source/NVDAObjects/UIA/winConsoleUIA.pygit diff --checkuvx ruff check --config pyproject.toml source/NVDAObjects/UIA/winConsoleUIA.pyUnit/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
3for Windows Terminal. Further adjustments may be needed if maintainers prefer a different multiplier or a profile-only workaround.Code Review Checklist: