Commit Graph
2 Commits
Author SHA1 Message Date
yetone ab72c8eb85 gui: TestCoveredWindowStaysUp hides magpie and checks the window in one step, so the activation its open asked for can't unhide magpie in between (macos-latest, CI run 37942751214)
Cause: on macos-latest the helper exited 1 with "window up: timed out
waiting until magpie is hidden" (6.06 s: the whole 5 s wait). It passed
on 3cd0b5f7's own run and the ten green runs after it, so it is a flake,
not a missing window server: the open and covered steps before it
passed on the same machine. Opening the window (openMain -> showHere ->
Focus) asks the Mac to activate magpie, which it does through the
window server and the run loop, not at once. On a loaded CI machine that
activation can still be pending when the test hides magpie a moment
later; it lands right after the hide and unhides magpie, which puts the
window back, so every poll found it open. NSApp hide: itself is
synchronous here (hidden with no window ordered in, in the same
main-thread block), active or not, and under full CPU load. That the
CI log has no line between is inferred from this: the only thing that
puts a hidden app's windows back is unhiding it, and the helper's only
activation is the open's.

Change: the test's hide step hides magpie and reads whether the window
counts as up in one block on the main thread, and hides again when it
finds magpie shown again. No production code changes: a user can't hide
magpie with Command-H before it is active. Not skipped: the test needs
nothing CI lacks.

Run:
- The old step with a late activation injected (queued from another
  goroutine while the hide block runs, not committed): FAIL 3 of 3,
  "window up: timed out waiting until magpie is hidden" in 5.8-6.3 s,
  the CI failure. The new step with the same injection: ok, 3 of 3.
- Guarantee still checked: windowUp with its "open as magpie was hidden"
  clause removed fails the new test, "hidden with magpie: the window
  counts as up=false, want true".
- go test -count=10 -run TestCoveredWindowStaysUp ./internal/gui: ok.
  Before the change, load alone didn't reproduce it here: three copies
  at a time, 15 runs, with a busy loop on every core, all passed.
- gofmt -l: nothing. go vet ./internal/gui (darwin), GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/gui, GOOS=windows go vet
  ./internal/gui: clean. go test ./internal/gui (darwin, under a temp
  HOME with pinned caches): ok.
2026-10-09 23:07:44 +08:00
yetone 3cd0b5f78d gui: lightweight mode no longer lets go of a main window that is open under another app's, so Command-Tab back to magpie finds it there (#1381, ttmouse)
Cause: lightweight mode (#580) let go of the main window once two of its
30 s looks found it "not shown", and it asked Wails' IsVisible, which on
the Mac is the window's occlusion state. A window the user had
Command-Tabbed away from, covered by the other app's window, counted as
closed: 30-60 s later its webview was dropped and the window closed, and
Command-Tab back to magpie found a blank shell or no window at all. Hidden
with magpie (Command-H) it went the same way, since hiding orders every
window out.

Change: windowUp says whether a window is up as the user sees it:
ordered in on any Space, covered or not, minimised, or open as magpie was
hidden (watchHide records those on NSApplicationWillHideNotification).
Only a window magpie closed itself is down. lighten (through lightShown)
and mainShown use it, so the Dock-while-open setting and a restart to
update also keep a covered window as open. Elsewhere windowUp is
IsVisible as before (visible there covers covered and minimised).

Run:
- Reproduced with a sandbox build of origin/main (own HOME and
  CFFIXED_USER_HOME, port 3481, dock+lightweight on): with the open
  window covered by a full-screen window of a helper process for 70 s the
  log said "the main window's webview let go" and the window was a blank
  white shell. With this change, the same run let go only the closed
  panel and the window kept its page (screenshot of the window).
- Activation itself was checked by handing activation from the helper to
  magpie (NSRunningApplication activateFromApplication): with the window
  there it came forward. A real Command-Tab keystroke was not sent.
- New TestCoveredWindowStaysUp (AppKit, own process): open, covered by
  another window (until IsVisible says false), hidden with the app,
  minimised -> up; closed by magpie, also with the app hidden -> down.
  With windowUp put back to IsVisible it fails: "open: the window counts
  as up=false, want true"; without the hidden clause: "hidden with
  magpie: the window counts as up=false, want true". Passes -count=10.
- gofmt -l; go vet ./internal/gui; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet (with and without nogui) ./internal/gui; go build,
  GOOS=linux go build -tags nogui, GOOS=windows go build;
  go test ./internal/gui and go test -tags nogui ./internal/gui under a
  temp HOME: ok.
2026-10-09 12:59:29 +08:00