Commit Graph
5 Commits
Author SHA1 Message Date
yetone 63be47717a gui: TestPanelJoinsFullScreenSpaces checks key status only where the session gives it (#2450)
The test was wrong, not the panel. It required the quick panel to be key
after Focus, but on this Mac (macOS 26.2 25C56, no input for ~30 min,
frontmost app kitty) macOS makes no non-activating panel key for an app
that isn't active when nothing the user did is behind it. That held at
e5d4c4929, the test's own commit, as well as on main, so there is no
regression to bisect. A control panel shows it: a plain NSPanel, titled +
NonactivatingPanel (canBecomeKeyWindow YES), ordered front and made key
the same way in the same child, isn't key either.

Now the test always checks that the panel can be made key
(canBecomeKeyWindow, which a borderless window has only through Wails'
panel class). It checks that the panel is key only when the session makes
the control panel key, and otherwise prints that it skipped that check.
Its other checks are unchanged: it joins full-screen Spaces, doesn't
activate, keeps the frontmost app, and hides.

Broken by hand, both ways:
- canBeKey returning 0 fails with "the panel can't be made key, so it never
  takes the keyboard".
- sessionKeysPanels returning 1 (which says the session gives key status)
  fails with "the panel shown doesn't take the keyboard", the old red.

Not tried: a real click on the menu bar icon with someone at the Mac.
That click is input, so a session at the Mac should run the key check
fully rather than skip it.

Run:
- go test ./internal/gui -run TestPanelJoinsFullScreenSpaces: ok, with
  the skip line printed.
- gofmt -l: clean.
- go vet -tags nogui ./... with GOOS=darwin, linux and windows: ok.
- go vet ./internal/gui (cgo): ok.
Full suite: set -o pipefail; go test -timeout 45m ./... (sandbox HOME, macOS 26.2, load ~150 from other suites): 66 ok, 18 no test files, 0 FAIL; gateway 2712s, agent 2553s, gui 419s.
2026-10-16 15:40:38 +08:00
yetone e5d4c49294 gui: on the Mac the quick panel opens over a full-screen app without taking the user to magpie's desktop (#2141, witt-bit)
b2d558db9 put the panel on every Space, full-screen ones too, but witt-bit
still saw a click on the menu bar icon over full-screen Chrome land on the
non-full-screen desktop on v0.1.1246. The panel was an ordinary NSWindow,
and togglePanel's Focus() activated magpie (activateIgnoringOtherApps).
Activating an app makes the Mac switch to a Space with that app's windows,
the desktop the main window is on, so the user was taken off the
full-screen Space however the panel itself was set.

The panel is now a non-activating NSPanel (Wails' MacWindowClassPanel with
NonActivating), as a menu bar extra's panel is: Show/Focus order it front
and make it key without activating magpie, so the full-screen app stays
frontmost and the Space stays where it is. It still takes the keyboard.
Lightweight mode makes it again from the same options.

Tests: TestPanelJoinsFullScreenSpaces now also checks, on a real AppKit
panel made at start and made again, that it is a non-activating panel,
that showing and focusing it (the icon's path) leaves magpie not
frontmost, and that it is key. With the old options it fails ("showing the
panel brought magpie to the front, which takes the user to the Space of its
other windows"), with the panel-class check turned off to reach that line.
TestPanelOnEverySpaceOnMac checks the options.

Not tried: a real full-screen Space. A test can't make one, and switching
Spaces on the shared Mac would take over its screen, so the reporter's
click over full-screen Chrome is for them to confirm. Paste into the
panel's fields while another app is frontmost wasn't tried by hand either.

Full suite: SUITE_LINE
2026-10-15 23:08:00 +08:00
yetone b2d558db97 gui: on the Mac the quick panel opens over a full-screen app, on the Space the user is on, not on the desktop it was first shown on (#2141)
With Chrome full screen and Settings > Click the tray icon set to the
quick panel, a click on the menu bar icon flashed the icon and showed the
panel on the non-full-screen desktop instead, out of sight until the user
swiped back (witt-bit, macOS 27.0.1, v0.1.1230). The panel's window had no
collection behaviour of its own, so Wails gave it FullScreenPrimary alone:
an ordinary window, kept on the Space it was first ordered in on, and not
allowed on a full-screen app's Space. It now has CanJoinAllSpaces |
FullScreenAuxiliary, as a menu bar extra's panel (and Wails' own notch
window) does, so it is on every Space, full-screen ones too. It never
moves to the active Space as well (AppKit refuses that pair), and nothing
calls setMovesToActiveSpace on it (showHere is the main window's only).
The panel lightweight mode makes again takes the same options.

Tests:
- TestPanelOnEverySpaceOnMac (panel_options_test.go) checks the options.
- TestPanelJoinsFullScreenSpaces (AppKit, runAppKit) makes the real panel
  through panelWin, at start and again after lightweight mode let it go,
  shows and hides it, and reads NSWindow.collectionBehavior
  (joinsFullScreenSpaces).
- Without the change both fail: "panel collection behaviour 0 is not on
  every Space and over full-screen ones" and "made at start: the panel
  isn't on every Space and over full-screen ones".

Run: gofmt -l (clean); go vet ./internal/gui/ (darwin),
GOOS=linux go vet -tags nogui, GOOS=windows go vet; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build; go test
./internal/gui/ under a sandbox HOME with pinned caches. In the package
run, at load average ~300-420 from other sessions, two tests unrelated to
the panel failed: TestMainWindowCorners (40s deadline killed; fails the
same on clean origin/main c4c3cafa2, filed as #1936) and
TestSetAnswersWhileDevinAndProvidersHang (filed as #1375; passed on clean
c4c3cafa2 right after). Panel, dock and Space tests pass.

Not tried: a real full-screen Space. A test can't make one, and doing it
by hand would take over the owner's screen; the reporter is asked to
confirm on the next release.
2026-10-14 16:12: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
yetone 31b903fed2 gui: a Dock click goes to the main window on its own Space, not pulls it to the current one (#1252)
The window has MoveToActiveSpace so that a first show, or an Open from
the menu bar, puts it on the Space the user is on (a window first shown
while another app was full screen belonged to that Space from then on).
The Dock's reopen also went through openMain's Show and Focus, so with
the window open on another Space a Dock click pulled it over instead of
switching to it, as other Mac apps do.

The window now carries MoveToActiveSpace only while it is shown
(showHere: set, Show, Focus, cleared 500ms later, since clearing it at
once loses the move). The Dock's reopen (reopenMain) activates the app
and leaves an open window where it is, so macOS switches to its Space; a
closed, hidden or minimised window, or one still loading, is shown on the
current Space as before. The menu bar panel and its Open are unchanged.

TestDockReopenKeepsTheWindowsSpace (darwin, cgo) runs a real Wails app:
open, reopen while open (the flag is never set, the window stays open),
hidden then reopened, and minimised then reopened. With the old reopen
it fails ("the shown window stays on its Space").

Tried for real on this Mac (macOS 26.2), on sandbox .app builds of the
old and new code under a sandbox HOME, with a second Space added and
removed afterwards. Old build: window open on Space 1, Dock reopen from
Space 2 left the user on Space 2 and moved the window there. New build:
the same reopen switched to Space 1 and the window stayed there. A
minimised or closed window was shown on Space 2, the current one. The
menu bar panel opened and closed on both Spaces. go test -tags nogui
./internal/gui/... and go test ./internal/gui (cgo) pass under a temp
HOME; go vet, and GOOS=linux / GOOS=windows go vet -tags nogui pass.
Not tried on a full-screen Space or with several displays.
2026-10-08 16:38:14 +08:00