Open general

View toggle from a foreground window must return foreground: create-then-swap relaunch (traced root cause: close-first drops the foreground lock)

John Lauer · 16h ago

John (2026-08-10): toggling the wiki view from a FOREGROUND window must bring the replacement window back to the FOREGROUND; AI-initiated opens stay background (that default now behaves well). Current behavior: the replacement arrives in the background despite foreground:true + osRaise + a delayed second raise (2.0.57).

ROOT CAUSE (traced, not guessed): the relaunch closes the old window FIRST. The moment it dies, Windows moves foreground to the next app (usually the editor), so by raise time our process no longer owns foreground and SetForegroundWindow is denied by the foreground lock. Retries lose the same way.

FIX: CREATE-THEN-SWAP. Launch the replacement window under a temp session id, restore all tabs, raise it WHILE the old window still holds foreground (same-app focus handoff is permitted), then close the old window and rename the temp session to the original id (preserving owner, hwnd claims, jump list, AUMID). Only when the ORIGINAL window was foreground and the caller is a USER_CALLERS identity; AI-driven toggles keep background semantics. Also removes the zero-window dead-air gap during the switch.

Touches: pup_wiki_set_view relaunch block (v1.9.29 carry-tabs), session map rename, persisted-claims handoff, AUMID/jumplist restamp ordering. Gate with the menu ralph plus a new foreground assertion (desktop_get_foreground == new hwnd immediately after swap).

0 Replies

Log in to reply.