fix(window-targeting): track tile-launched window focus + drop page-host's local Maximize cmd
User report: with a tile (tags, search, etc.) focused in front of a
content window (e.g. example.com), running the maximize command
maximizes the content window behind, not the focused tile.
Two distinct contributing bugs were uncovered:
1. tile-launcher.createTileBrowserWindow created BrowserWindows without
attaching the focus listener that updates lastFocusedVisibleWindowId.
The window-open IPC path attached its own focus listener after
window creation, so tiles opened via api.window.open were tracked
correctly. Windows created directly via launchTile (notably resident
tiles wired up at startup) silently skipped the tracker. When such
a window was focused, the tracker stayed pointed at whatever
non-tile window was focused last.
2. The page-host (app/page/page.js) registered a renderer-side
`Maximize` command (`scope: 'window'`). `scope: 'window'` is only a
UI badge — not a dispatch filter — so the cmd panel's prefix matcher
resolved typed `maximize` input to whichever page-host had
registered that name, calling its local `toggleMaximize()` on its
own `myWindowId` and bypassing both the focus tracker and the IPC
boundary entirely. With example.com being the only page-host, its
command always ran regardless of which window was actually focused.
Fix:
- Add an onWindowFocus hook to configureTileLauncher and call it from
inside createTileBrowserWindow on every focus event. main.ts wires
the hook to a new exported trackOnWindowFocus that runs
trackContentWindowFocus + trackVisibleWindowFocus. The hook receives
the manifest entry's role (e.g. 'workspace', 'overlay'), so role-based
exclusions work even though tile windows aren't yet in windowRegistry.
- Extend trackVisibleWindowFocus to accept an optional knownRole
parameter so tile-launcher callers don't need a registry lookup.
- Promote the focus-tracker log from DEBUG-gated to unconditional.
Wrong-window-targeting bugs are reported by symptom, and seeing the
transitions in stderr makes them diagnosable without re-instrumenting
the user.
- Add an unconditional log in tile:window:maximize that prints the
resolved window id + url, so the user can confirm which window was
actually targeted.
- Drop the page-host's local `Maximize` command registration. Maximize
is owned by the windows feature (`maximize window`), which targets
the focus tracker and crosses the IPC boundary. The page-host keeps
its `page:maximize` pubsub subscription and its navbar dbl-click
handler, both of which intentionally toggle the local
`toggleMaximize()` (legitimate UI affordances scoped to the
page-host).
Regression tests:
- Focusing a real tile window (peek://tags/home.html) in front of a
content window must update getFocusedVisibleWindowId to the tile's
id, not leave it pointing at the content window.
- A search tile opened on top of a content window must update the
tracker even without an explicit api.window.focus call.