Skip to content

fix(track): VS Code caret via the MSAA system caret; no tracking stall on a blocking app (#367) - #368

Merged
Maxaubert merged 2 commits into
mainfrom
fix/367-vscode-caret
Oct 4, 2026
Merged

Maxaubert merged 2 commits into
mainfrom
fix/367-vscode-caret

Conversation

@Maxaubert

@Maxaubert Maxaubert commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Closes #367. Stacked on #366 (which is stacked on #364).

1. VS Code caret.

  • VS Code's editor is an EditContext element (native-edit-context). Its UIA caret and selection stay at the start of the line wherever the caret is, so Wind only followed line changes.
  • A probe shows Chromium's MSAA system caret (OBJID_CARET) tracks it exactly:
    • End: x went from 261 to 556;
    • each character typed: +17 px.
  • For that element class only, the MSAA caret on the same line wins (msaa-editcontext).
  • Edge textareas are left alone: their UIA caret is right and their MSAA caret lags it by about 100 ms.
  • The class is cached per focus and window. A stale cache once sent MSAA queries into Notepad; that is fixed here.

2. Tracking stalls.

  • One app that does not answer a UIA call stalls all tracking.
  • UIA calls are now capped at 500 ms.
  • GetFocusedElement ignores that cap: it blocked for 3 s at Notepad's activation. It now runs on a Wind focus lookup thread:
    • the tracker waits at most 150 ms, then resolves without UIA;
    • no new lookup starts while one is stuck;
    • a late answer is reused if it is under 250 ms old and for the same window.
  • With focus-following off, an app with a classic Win32 caret skips the lookup entirely; that caret already wins.
  • Resolves over 200 ms log slow resolve with the phase.

Lookup thread verified (runs 28 to 32, 30 switches per app):

  • 0 unfollowed switches, and 0 missed moves in Notepad and Edge.
  • No stall over 1 s. Before, there was one 3 s stall about every 18 Notepad switches.
  • Edge is now followed at the first keystroke (about 0.33 s after a switch). Before, a caret Edge moved by itself during activation was followed at 0.09 s.

Verified on the signed UIAccess build

  • Scripted app switches, 6 per app per run, typing, Home and End right after each switch, with trackLog.

    App Before After (runs 20 to 22)
    VS Code 36 of 36 moves missed, 5 of 6 switches never followed Every switch followed right after the first keystroke (0.73 to 0.8 s after the switch)
    Notepad 0 missed in 2 of 3 runs. One 3 s stall in 18 switches remains, at an activation with no Win32 caret yet.
    Edge 0 missed
  • No stall over 1 s in runs 21 and 22.

  • build.bat test: 572/572 pass.

Version 0.23.3.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KPUNAWcwghXdHCApcKKjSG

@Maxaubert
Maxaubert force-pushed the fix/365-caret-switch-java branch from ab27217 to 4c822a3 Compare October 4, 2026 08:37
Maxaubert and others added 2 commits October 4, 2026 10:39
…l on a blocking app (#367)

VS Code's native-edit-context element pins its UIA caret to the line start;
for that class only, Chromium's OBJID_CARET on the same line wins. UIA calls
are capped at 500 ms, and with focus-following off a Win32-caret app skips
GetFocusedElement, which blocked 3 s at Notepad's activation. Resolves over
200 ms are logged with the phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KPUNAWcwghXdHCApcKKjSG
…eadline (#367)

GetFocusedElement ignores the UIA timeouts and blocked 3 s at Notepad's
activation when no Win32 caret existed yet, freezing all tracking. It now runs
on a "Wind focus lookup" thread; the tracker waits 150 ms and resolves without
UIA otherwise, never stacks lookups on a stuck app, and reuses a late answer
under 250 ms old for the same window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KPUNAWcwghXdHCApcKKjSG
@Maxaubert
Maxaubert force-pushed the fix/367-vscode-caret branch from bc116de to c5197d9 Compare October 4, 2026 08:39
@Maxaubert
Maxaubert changed the base branch from fix/365-caret-switch-java to main October 4, 2026 08:39
@Maxaubert
Maxaubert merged commit 913a8b9 into main Oct 4, 2026
1 check passed
@Maxaubert
Maxaubert deleted the fix/367-vscode-caret branch October 4, 2026 08:41
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.

Caret tracking: VS Code caret pinned to line start; tracking stalls on a blocking app

1 participant