KiCad - the KiCad Bridge
Public Made by Adomby adom
Drive your own KiCad from an AI, in the background: open every editor, read the whole board as data (the EDA Bridge Standard board model), stack-up, part heights, netlists, place, route, pour, DRC and exports.
Focus-guardian flickers a self-raising KiCad window ~10x/sec (and pegs CPU) on first launch
Symptom
Opening a component in a freshly-installed KiCad made the KiCad window flicker to the front and back roughly 10 times a second -- genuinely jarring, "epileptic" -- until KiCad was closed.
Cause
win_focus.restore_foreground_persistent (the focus guardian) demotes a KiCad window every time it takes the OS foreground. A just-launched KiCad 10.0 editor self-raises repeatedly while it loads/renders (wx frames Raise() themselves after the SW_SHOWNOACTIVATE Popen), so the guardian demotes it in a tight loop with no debounce: KiCad raises -> guardian demotes -> KiCad raises -> ... at the guardian's poll rate. That is the visible flicker.
Repro
- Fresh KiCad 10.0 install (first launch of the editor).
kicad_show_symbol { "background": true }(via the web-control demo's "Symbol" button).- The Symbol Editor flickers front/back continuously until KiCad is closed.
kicad-bridge 0.9.171, KiCad 10.0, ab 2.0.59, Windows.
Fix ideas
The guardian should stop fighting a persistently self-raising window instead of demoting it on every poll:
- Debounce / rate-limit per hwnd: after demoting a given KiCad hwnd N times within M ms, stop and just hold it demoted-below (one
SetWindowPos, then leave it), rather than re-demoting every tick. - Or detect the self-raise loop and back off (exponential), or let a first-launch window settle (it stops self-raising once loaded) before guarding.
- Either way the loop must not run at UI frame rate; one demote that sticks is enough.
Related (foreground intent)
Separately: the demo's "Footprint" button reported success but the user never saw the footprint editor -- it opened in the background (correct per the background-first rule) and was demoted behind their windows. For an explicit user "show me" click (a Quick Actions "Open in Footprint Editor" button), the show verb should be called with foreground: true so the sanctioned bring_to_user path runs. Not a bridge bug, but worth a note: the show-me buttons need to pass the foreground intent, and when they do the guardian should not be demoting at all.