Skip to content

v0.10.1 — Fix: filter invisible/utility windows from MRU Z-order ranking

Choose a tag to compare

@KenM76 KenM76 released this 16 Jun 19:27
· 1 commit to main since this release

Closes `FR_sessionpicker_mru_filter_invisible_windows.md` — a bug diagnosed live against multi-instance SolidWorks.

What was wrong

`SessionPicker.RankByZOrder` matched the first top-level window per PID in global Z-order without filtering, so invisible utility windows (`tooltips_class32`, IME input contexts, addin-host shells, drop-shadow hosts) determined MRU rank. Their position in Z-order shifts based on mouse-hover side-effects on host UI — unrelated to which window the user actually clicked. Result: `--session 1` (combridge's default when no session selector is specified) sometimes attached to the wrong instance even when the user had clicked into a specific one moments earlier.

Live diagnostic evidence (3-instance SW setup): every per-PID first-hit was a `tooltips_class32` — `visible=False`, `titleLen=0`, `WS_EX_TOOLWINDOW` set. Mouse hover lifecycle was determining MRU rank.

Fix

4-line filter in `RankByZOrder` skips windows failing any of:

  • `IsWindowVisible == false`
  • `GetWindowTextLength == 0` (no caption)
  • `WS_EX_TOOLWINDOW` set (hidden from Alt-Tab)
  • `WS_EX_NOACTIVATE` set (never receives focus)

The canonical "is this user-focusable?" predicate every Alt-Tab and taskbar has used since Win95.

Scope: who's affected

Plugin Affected by the bug? Notes
`solidworks` ✅ Severely Confirmed by the FR; real multi-process, no shim
`excel` / `word` / `powerpoint` ⚠ Yes when actually multi-process Office 365's shared-instance shim usually masks it; real multi-instance hit the same bug
`outlook` ✗ No effect Single-instance MAPI — only one PID to rank
Mac plugins (×4) ✗ Not applicable Override `FindSessions` with AppleScript

Verified

Live-tested against the same 4-instance SW setup that surfaced the bug. `list-sessions` returned identical rank ordering across three successive runs after the fix. Pre-fix, ordering flipped between runs based on mouse-hover state.

Cost: ~3 extra Win32 calls per walked window (sub-microsecond each). Total walk time stays well under a millisecond on ~1500-window workstations.

Lesson captured

`C:\personal_rag\claude_code\lesson_20260616_combridge_zorder_mru_visible_filter.md` — generalises the diagnostic technique (PowerShell Z-order walk comparing unfiltered vs filtered first-hit per PID) to any multi-instance focus-tracking puzzle on Win32.