Commit Graph
11 Commits
Author SHA1 Message Date
yetone d5873b0d85 gui: Windows on ARM puts the text size on WebView2 itself, since Wails can't pass it a double there (#2212, EdwinDigital)
On windows/arm64 Wails beta.24's SetZoom fails with
ErrDoubleArgUnsupported and only logs it: Go's stdcall on arm64 loads
x0-x7 and never d0 (golang/go#62583), so ICoreWebView2Controller::
put_ZoomFactor(double) can't be called through SyscallN. The text size
was saved and never applied.

zoom_windows_arm64.go calls put_ZoomFactor (vtbl slot 8) through a
two-instruction thunk in VirtualAlloc'd executable memory,
`fmov d0, x1; br x2`, called as SyscallN(thunk, this, bits, fn). The
controller is reached by reflection (WebviewWindow.impl.chromium.
controller). The window's Zoom option goes through the same broken call,
so on that platform the size is put on each page once navigation
completes (zoomsAfterLoad), on the UI thread. Other platforms are
unchanged: setPageZoom moves to zoom_other.go.

Run:
- The thunk's encoding in a C harness on macOS arm64 (MAP_JIT): it
  passed 1.25 in d0, returned the callee's HRESULT, kept `this`.
- On the Windows 11 AMD64 box, in a sandbox profile on its own port, a
  check build of this change (same reflection path and vtbl slot, the
  call made directly since amd64 passes doubles in X1): put_ZoomFactor
  returned S_OK for both windows at 110% and 150%, and screenshots show
  the page drawn at 150%.
- gofmt -l; go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows,
  and GOOS=windows GOARCH=arm64 (vet + build); go test ./internal/gui/.

Not tried: the thunk on real Windows on ARM hardware; the reporter is
asked to confirm. No GUI assets changed, so the Playwright suite wasn't run.
2026-10-15 00:34:14 +08:00
yetone 751ebe8f5a gui: magpie leads Command-Tab's order after opening its window on a busy Mac too, not only when the main thread keeps up (#1651)
TestDockJoinLeadsCommandTab failed under a full local go test ./...: the
test app was LaunchServices' front app, yet last in Command-Tab's order
(lsappinfo visibleProcessList), kitty first.

Cause: setDock decided whether to activate magpie again by way of the
Dock (#1381's fix) from [NSApp isActive]. The Mac makes an activated app
the front app at once, but NSApp says it is active only once its main
thread has taken the activation in. On a loaded machine the join came
first, isActive read NO, dockStep chose a plain activate (a no-op for
the front app), and magpie stayed last. A temporary print in setDock
showed active=false in every failing run (3 of 5 at load ~120) and true
in the passing ones. The same can happen to a user when the panel's
focus and Open come close together on a busy Mac.

Fix: joining the Dock to the front always goes by way of the Dock
(activateAgain), whatever NSApp says. When magpie truly isn't active
(the tray's Open), the Dock's turn in front changes nothing: magpie is
activated after it either way. dockStep loses its active argument and
appActive is gone. docs/subsystems/gui-shell.md item 7 says so.

The test now activates magpie, waits for LaunchServices to call it the
front app, and joins, all in one turn of the main thread, so the join
always comes before NSApp knows: the busy-machine order, made certain.

Run:
- New test on the old dockStep: 5 of 5 red (magpie not first, kitty first).
  With the fix: 25 of 25 green at load ~120-135.
- The old test (no injected order) with the fix: 10 of 10 green at load
  ~180; before the fix 3 of 5 red at load ~120.
- TestDockStep (table without active). go test ./internal/gui (GUI
  build, darwin) 5 runs green. One run before them failed and its
  output wasn't kept, so which test failed is unknown. After rebasing
  onto 18e82adc6, one package run failed TestTrayCellClickReleasedPanel
  (its own AppKit child, no setDock on its path); it passed alone and in
  3 package runs after. Filed as #1661, cause not found.
  go test -tags nogui ./internal/gui green. gofmt -l clean; go vet
  ./internal/gui (darwin), GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gui clean.

Not tried: a real magpie build with osascript Command-Tabs (as 15872d977
did) after this change; the full-screen join (dockOnFullscreen), which
still reads isActive at NSWindowWillEnterFullScreen, long after any
activation, and is unchanged.
2026-10-12 00:57:27 +08:00
yetone 15872d977a gui: with the window open, magpie leads Command-Tab's order, so one Command-Tab away and one back returns to it (#1381, ttmouse)
ttmouse on v0.1.1168: open magpie's window, Command-Tab to another app,
Command-Tab back, and magpie is last in the switcher.

Cause: magpie is out of the Dock (Accessory) until the window opens.
With Settings > Dock set to "while the window is open" (or a full-screen
window), the quick panel's focus activates magpie while it is still
Accessory, and it joins the Dock (Regular) after that. An app activated
before it joins stays last in LaunchServices' front-to-back order
(lsappinfo visibleProcessList), which Command-Tab follows, though it is
frontmost. Wails' Focus only calls activateIgnoringOtherApps when the
app isn't active, and calling it again while active is a no-op. setDock
also ran async (dispatch_async), so openMain's Show/Focus could come
before the policy change.

Fix:
- setDock runs on the main thread at once (InvokeSync), so openMain
  joins before it shows the window.
- A pure dockStep(regular, on, active, front) decides the move. Joining
  while already active activates the Dock and then magpie again
  (activateAgain), which puts magpie first in the order. Joining while
  not active just activates it; leaving never re-activates.
- The full-screen join does the same once the window is in full screen
  (DidEnterFullScreen) if magpie was active when it joined.
- Dock "off" (the default) is unchanged: magpie stays out of the Dock
  and out of Command-Tab, by design. The tray panel's behaviour is
  unchanged.
- docs/subsystems/gui-shell.md: Runtime path item 7 for the Dock setting.

Run:
- TestDockStep (table, pure). TestDockJoinLeadsCommandTab (darwin GUI
  build): a real Accessory Wails app activated, then setDock(true,
  true) + window Show/Focus, asserts it is first in lsappinfo's order.
  Red with `again` forced false (front was the test, kitty first in the
  order), green with the fix.
- go test ./internal/gui (GUI build, darwin) passes; full
  go test -tags nogui ./... passes; gofmt -l clean; go vet ./internal/gui
  (darwin) and GOOS=linux / GOOS=windows go vet -tags nogui clean.
- Real build on this Mac, sandbox HOME, own bundle id, port 3481,
  DockWindow on: launched with the quick panel, window opened through the
  Mac's reopen, then two osascript Command-Tabs. Old build: magpie front
  but 11th of 11 in the order (the report). New build: magpie 1st; after
  Command-Tab, the other app 1st and magpie 2nd; Command-Tab again brings
  magpie back. Dock "always": magpie 1st, round trip works. Dock "off":
  stays UIElement, not in the order.

Not tried: the full-screen path in the real build, a human Command-Tab
(only osascript keystrokes), real accounts (not involved).
2026-10-11 19:30:17 +08:00
lainbo 9bfb7a5870 fix(gui): keep the full-screen window's title bar when the Dock is set to Hide
With Dock on "Hide", magpie runs as an Accessory app. A full-screen
window's title bar comes down only with the menu bar, and an Accessory app
has none, so the full-screen main window had no close, minimize or
full-screen button, and only Esc left full screen.

magpie now joins the Dock as a window starts entering full screen, from a
native NSWindowWillEnterFullScreenNotification observer: Wails hands that
event to Go later, and switching once the window is full screen doesn't
bring the title bar back. dock counts a full-screen main window (inDock),
so reopening the app or changing the Dock setting during full screen keeps
magpie in the Dock, and WindowDidExitFullScreen applies the setting again.

TestFullscreenKeepsDock checks inDock; it doesn't compile on main. On
macOS 27.0.1 with Dock on "Hide", main stays out of the Dock in full screen
with no title bar; this branch joins the Dock with the title bar and its
buttons, and leaves it after the green button, View > Toggle Full Screen
or Esc.

Fixes #763
2026-10-05 17:37:49 +08:00
yetone 4a2f538c61 gui: lightweight mode, off by default, lets a closed panel's or window's webview go and makes it again when it is opened (somls on #580: GUI版可否增加轻量模式,关闭面板退出webview,减少资源占用) — closing the tray panel or the main window only hid it, so each kept its page and, on a Mac, its WebKit WebContent process (about 65 MB each at start, 95–100 MB after use) for as long as magpie ran. Settings → General now has Lightweight mode (轻量模式), shown in the app only (not on a browser's page) and kept as this computer's own through a sync or a restored backup (KeepOwn): with it on, a window found closed on two looks in a row 30 s apart (lightStep) is let go 30–60 s after it was closed, so a panel opened again soon after is still the same one at once. Letting go happens on the main thread under a new h.winMu: the window field is set to nil, the panel is unhooked from the tray icon (AttachWindow(nil); left click goes through magpie's own OnClick), and the main window is marked gone so its closing hook, which otherwise cancels a close and hides, lets it close; on the Mac the WKWebView is taken out of the window first (stopLoading, delegates and script handlers cleared, removed from its superview), since Wails' NSWindow close alone left the WebContent process alive for minutes. Opening it again (the tray icon, ShowMain, an import link, the Dock) makes the window anew with the options it was started with (makeMain/makePanel, moved out of Run with their hooks), its text size and title bar or Hyprland name (madeAgain), on Windows shown only once its page has loaded; every other path that reached h.main or h.panel (fit, tint, zoom, hide, glide, the Windows title-bar tint, the Hyprland click watch, the folder picker) now goes through the main thread and does nothing to a window let go; Linux keeps running with no window left (DisableQuitOnLastWindowClosed). Measured in a sandbox build under a temp HOME on other ports: started in the tray with the setting on, two WebContent processes of ~65 MB each; about a minute later both windows were let go and both processes ended (GPU and Networking, ~56 MB, are shared and stay; magpie's own process is unchanged), so the saving is ~130 MB idle and up to ~200 MB after use; the main window and the panel were then opened again with their pages, tinted and at the tray icon, closed, let go a second time, and magpie quit cleanly, with fit/tint/zoom calls every 0.2 s through a release crashing nothing. Windows and Linux build but were not run. TestLightStep and TestLightweightKeptAndOwn are new; lightweight.test.cjs (WebKit, en and zh: the row, off by default, On/Off posted as lightweight true/false, another setting's save keeping it, no scroll, no left-border accent, no row on a browser's page) is new and passes, as do click-scroll, settings-sections and searcher-pick. go vet ./internal/..., go build (darwin GUI), go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-03 00:24:49 +08:00
yetone 575e694ed7 settings: a Text size preference (文字大小) that makes everything in magpie's windows larger, 100/110/125/150%, with Ctrl/Cmd + = − 0 in the window and the tray panel, and Windows' text drawn in its own UI faces (Discord, Clarence Dan: the font size is hard on the eyes on Windows) — Settings → Preferences gains a Text size row under Language whose pick posts to a new POST /api/settings/text-size (saved as settings.TextSize, validated against 100/110/125/150, 0 read as 100, and kept by the Settings page's general save, which never sends it). The size is each webview's own zoom, as a browser zooms, not CSS zoom: CSS zoom leaves getBoundingClientRect and clientX in zoomed pixels while offsets, scrollTop and 100vh are not, and app.js, routing.js and library.js place menus, popovers and the panel's height by those measures; under the webview's zoom the page is laid out again in fewer, larger CSS pixels and every measure agrees. Windows and Linux use Wails' SetZoom (WebView2's zoom factor, WebKitGTK's zoom level; the Zoom window option at creation, so the pages open at the saved size), the Mac WKWebView.pageZoom through cgo (macOS 11+), since Wails' Mac zoom is magnification, which lays nothing out again. None is under 100% because Wails clamps SetZoom below 1 on Windows and Linux. The windows grow around the pages: the panel's width and the height its page asks for (still in CSS pixels) are multiplied by the zoom, capped at the screen's work area (textsize.go panelFrame), and resized at once when the size changes; the main window's minimum is 560×420 CSS pixels at the size, capped by the screen, so a window smaller than that grows. Runtime changes wait for the app to be ready (whenReady), and at startup the Mac applies the zoom once its webviews exist. The Mac header, drawn under the native traffic lights which do not grow, divides its height, left padding and the modal's top by --zoom (set from boot.js before the first paint and from the settings), so it stays 50 points tall and level with them. The shortcuts are Cmd on the Mac and Ctrl elsewhere (the other modifier does nothing), step through the sizes and 0 goes back to 100%, with a "Text size 125%" toast; in magpie web the row is hidden and the keys are left to the browser's own zoom. On Windows the page names its faces (html.win): Segoe UI Variable Text, Segoe UI, then Microsoft YaHei UI for Chinese rather than whatever WebView2 falls back to; the Mac and Linux stack is unchanged, and there is no automatic size bump. New strings in en and zh. Tested: internal/gui/tests/text-size.test.cjs in Chromium and WebKit, en and zh, light and dark — a pick posts and does not scroll the settings page, stays picked after a reload with --zoom from boot.js, the Settings page's other saves leave it, the shortcuts step and reset in the window and the panel, and at 150% (the smallest window, 840×630 points, as 560×420 CSS pixels at device scale 1.5) no view, the header or the panel runs off to the side, the Mac header is 50 points; screenshots at 100% and 150% looked at. currency.test.cjs's viewport is 480 tall instead of 420, as settings-groups' is: the new row put the Currency control under the footer, where WebKit's hover could not reach it. Go: TestTextSizeFrames (panel and window sizes) and TestTextSizeSetting (the endpoint saves, zooms the windows, rejects 133, survives the general save, boot.js carries it) in internal/gui, and the settings round trip. go build -tags nogui (and GOOS=linux, GOOS=windows, plain darwin), go test -tags nogui ./... (TestUserPath flaked once under load and passes alone) and the whole GUI suite with --test-concurrency=2 pass. Not tried in the real Wails window on any platform: the Mac pageZoom, WebView2's zoom factor with the resized panel and the Windows font are untested there. 2026-09-30 02:51:17 +08:00
yetone 59e4f417b2 web: magpie web serves the app's window to a browser, with the gateway beside it — for a computer that can't show the app: no desktop, WSL, a server over SSH, or the CLI-only build, which now carries the page too (what of the app needs Wails is left out of nogui builds). Every request needs this run's key, which the printed link carries and trades for a cookie other sites' pages can't send with a POST; --lan serves it on the network too, with a warning, --addr elsewhere, --no-open leaves the browser shut. In the browser the page opens links and sign-ins itself, names a folder instead of opening it, and leaves out the tray, the Dock and open at login. Tested from a nogui build in a sandbox: no key, a wrong key and a cookieless POST are refused; with the link Agents, Providers and Settings load and a setting saves. Issue #102 2026-09-27 16:21:26 +08:00
yetone dad2787f55 settings: the Dock can follow the window — Hide, With window, Show. With window, magpie is in the Dock (and Cmd-Tab) while its window is open and leaves it when the window is closed, so it can be switched to without an icon kept there the rest of the time. Tested on a sandboxed bundle: shown at start, gone on close, back on reopen; Show and Hide behave as before. Issue #101 2026-09-27 16:14:54 +08:00
yetone 0423553454 gui: magpie can stay in the Mac's Dock — Settings → Dock → Show keeps it there as well as in the menu bar, for a menu bar too full to show its icon; it takes effect at once and at every start, the Dock icon opens the window (only the window: Wails would have shown the panel too), and it stays each computer's own in sync and backups 2026-09-25 21:13:30 +08:00
yetone b225ace50c gui(panel): no dark band at the bottom while the tray panel grows — WebKit draws the page a frame or two after the panel's frame moves and filled the new edge with its own dark background; on the Mac the panel's webview now draws no background of its own and the page's colour is painted in a view under it that the system sizes with the panel, so the new edge comes in the page's colour until the page catches up. It looks as before; a change of theme fades it along; elsewhere, or when the webview won't, the page paints itself as it did 2026-09-25 02:19:32 +08:00
yetone db59d15ed4 gui(panel): the tray panel's height glides with the agents' scroll as it unrolls and rolls up, on the same beat and curve, its top edge held under the menu bar — on the Mac the system animates the frame on its own display clock, elsewhere it steps a frame at a time; a fit that doesn't ask to glide still sizes at once, and make dev shells from before still size 2026-09-25 01:53:21 +08:00