diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 5f5f0bbb8..59e3717a5 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -692,6 +692,7 @@ covers it in both engines, every language and a narrow window. - On Linux the panel is a solid window, as the main window is, and its page paints `--bg` whole (`panelOptions`, `body.linux.panel` in `app.css`). The Mac's and Windows' panels stay translucent. A see-through panel is an RGBA, app-paintable GTK window under a transparent webview, and on KDE Plasma 6 its page, painted at 93%, left a fainter copy of the old scroll position as it scrolled (Wayland and XWayland, compositing mode on or off) while the main window never did (#1803, `TestPanelSolidOnLinux`, `panel-linux-opaque.test.cjs`). Xvfb with picom on WebKitGTK 2.54 doesn't show the ghost either way, so the fix rests on the reporter's machine. - A Wayland window can't place itself, so under Hyprland and niri the compositor is asked to put the panel under the bar. Under Hyprland `placePanel` gives it a window rule at the cursor (`omarchy.PlacePanel`) and closes it on a click outside (`omarchy.ReportClicks`). The rule names the monitor under the cursor and moves the panel to x, y from that monitor's corner (`omarchy.PanelAt`): Hyprland adds the window's monitor's place to a `move`, so a position across the whole layout put the panel off a monitor not at 0,0 (#1785, `TestPanelAtMonitorOffScreenOrigin`). The cursor and the clients' places that `omarchy.ClickedOutside` compares are both across the layout. niri (`omarchy.Niri`, `NIRI_SOCKET` set) takes no rules at runtime and doesn't report the cursor. There `omarchy.NiriPanel` watches niri's event stream and moves the panel each time it opens: the window of magpie's pid titled `panelTitle`, moved with `MoveFloatingWindow` (after `MoveWindowToFloating` if it was tiled). It goes 6 px under the working area's top, centred on the x the tray host passed to `Activate(x, y)`. Wails keeps that x in its Linux tray (`trayClick`, `TestTrayClickIsWails`), and it is taken across the bar, since that's all a Wayland bar knows. With no click (`magpie panel`), or with one off the output, it goes top right. Wails' `HideOnFocusLost` closes it, since a click on another window takes niri's focus. It still opens in the middle and slides up, and a bar at the bottom or the side isn't accounted for (#1670). - Wails calls the tray's click handler both for the icon's click (`Activate`) and when the tray host opens the icon's menu (dbusmenu's "opened" event). KDE opens the menu on a right-click, and the panel that click opened took the focus and shut the menu on Wayland. On Linux the handler ignores the call when it comes from the menu opening (`menuOpening` in [`trayclick.go`](../../internal/gui/trayclick.go), which looks for Wails' `(*linuxSystemTray).Event` among its callers; `TestTrayMenuOpenFrameIsWails` fails if Wails renames it or stops calling the handler there) (#1430). +- On Linux the app draws without backdrop blur (`body.linux` rules at the end of `app.css`; `linux-no-backdrop-blur.test.cjs`): `webkit_linux.go` turns accelerated compositing off under Wayland and without a GPU, and there a blur is repainted by the CPU on every frame (a full-window modal took 25ms a frame against 16ms with none, in WebKitGTK 2.52 on Xvfb). The modal, pickers and Settings' sticky head are 92% or more opaque, so the blur is barely seen. Not reproduced on NVIDIA under Wayland (no such machine), so a report of lag there may have another part (#3150). - On GTK 3 builds, the app gives GDK a font DPI before the first webview when it has none (`fontDPI`, [`fontdpi_gtk3.h`](../../internal/gui/fontdpi_gtk3.h)). GDK's unset value is -1, and WebKitGTK 2.54's GTK 3 settings reader multiplies it by 1024 unchecked, so every page lays out at a negative width with a 9000000px font (#1371). An unset DPI takes `gtk-xft-dpi`, or 96, times a valid `GDK_DPI_SCALE`; a positive one is left alone. Wails initialises GTK (its GtkApplication) only inside `Run` and makes each window from a default-idle-priority callback on the main loop, so `fontDPI`, called just before `Run`, queues the check as a `G_PRIORITY_HIGH` idle: it runs on the main thread after GTK's own start, before the first window. `TestFontDPIUnset` opens a real WebKitGTK page through `magpie_font_dpi` and needs a display (Xvfb). - Tests never touch a live agent config. The package's `TestMain` runs under `testenv`'s home of its own. A macOS test that shows windows runs them in a process of its own through `runAppKit` ([`appkit_darwin_test.go`](../../internal/gui/appkit_darwin_test.go)). AppKit and WebKit take their home from the account, not from HOME, so `runAppKit` gives them a temporary one with `CFFIXED_USER_HOME`; appearance, contrast and languages still come from the account. The test fails when that process leaves a folder in the real `~/Library/WebKit` or `~/Library/Caches`. Playwright tests serve `assets/` with isolated `/api` fixtures. - `POST /api/settings/codex-auto-review` accepts an empty value (Codex's own choice, or the session's model when Codex's sign-in is on a Free plan), `session` (the session's own model when it is one of magpie's; "Same as the session" in the picker), or an exact model/group ID in `provider.Served`, including unlisted providers. A known provider with an unknown or empty model name is rejected without changing the saved reviewer or catalog tag. Generic gateway request resolution remains permissive; it is not the validator for this setting. See `Handler` in [`api.go`](../../internal/gui/api.go) and `TestCodexAutoReviewSetting` in [`codex_auto_review_test.go`](../../internal/gui/codex_auto_review_test.go). diff --git a/internal/gateway/history.go b/internal/gateway/history.go index 743fb6dd4..c138de401 100644 --- a/internal/gateway/history.go +++ b/internal/gateway/history.go @@ -533,12 +533,17 @@ type tallied struct { Tries []Try `json:"tries"` } -// tallyKey is what the page groups an account by: its provider and its -// user, however it is weighed into a request (its sign-in may move); a +// tallyKey is what the page groups an account by: its provider, its user +// and its plan (two seats of one email on different plans are two +// accounts, not one), however it is weighed into a request (its sign-in may move); a // key or a provider by its own id. func tallyKey(w Weighed) string { if w.Kind == "account" && w.Who != "" { - b, _ := json.Marshal([]string{w.Provider, strings.ToLower(strings.TrimSpace(w.Who))}) + k := []string{w.Provider, strings.ToLower(strings.TrimSpace(w.Who))} + if plan := strings.ToLower(strings.TrimSpace(w.Plan)); plan != "" { + k = append(k, plan) // a plan-less seat keeps the two-part key + } + b, _ := json.Marshal(k) return string(b) } return w.ID diff --git a/internal/gateway/history_tallies_test.go b/internal/gateway/history_tallies_test.go index 0c07bafa9..7479ed4eb 100644 --- a/internal/gateway/history_tallies_test.go +++ b/internal/gateway/history_tallies_test.go @@ -144,3 +144,21 @@ func TestDayTalliesCountARateLimitAsOne(t *testing.T) { t.Errorf("tallied %v, want 1 rate and 2 quota", a.Fails) } } + +// Two seats of one email on different plans are two accounts in the day's +// tallies, as the Routing page's list keys them (RayYanOnline on X); a +// seat with no plan keeps the two-part key. +func TestTallyKeyTellsPlansApart(t *testing.T) { + seat := func(plan string) Weighed { + return Weighed{ID: "codex", Provider: "codex", Kind: "account", Who: "Jd@Example.com", Plan: plan} + } + if a, b := tallyKey(seat("team")), tallyKey(seat("prolite")); a == b { + t.Errorf("a Team seat and a Pro Lite login share the key %s", a) + } + if got, want := tallyKey(seat("")), `["codex","jd@example.com"]`; got != want { + t.Errorf("a seat with no plan: %s, want %s", got, want) + } + if got, want := tallyKey(seat(" Team ")), `["codex","jd@example.com","team"]`; got != want { + t.Errorf("a plan: %s, want %s", got, want) + } +} diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index d46aaad80..25ceee610 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -5290,3 +5290,11 @@ body .row.agent .ag-prefs .row.pref .who { display: block; } .server-pin .hint.err { color: var(--red); overflow-wrap: anywhere; } .server-pin .pin-acts { display: flex; flex-wrap: wrap; gap: 12px; } .server-pin .pin-peek.busy { pointer-events: none; opacity: .6; } +/* WebKitGTK draws without accelerated compositing (webkit_linux.go), so a + backdrop blur is redone by the CPU for its whole box on every frame: a + full-window modal took 25ms a frame where the same page took 16ms with none + (lagging scroll, Lsheng2012 on X, KDE). Each of these grounds is 92% opaque + or a dim, so the blur is barely seen; the Linux app draws without it. */ +body.linux .modal, body.linux .pop, body.linux.panel .profiles.open, +body.linux:not(.side-nav) #view-settings .set-head::before, +body.linux .action-confirm::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; } diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index d6f4451a8..5fb361d6e 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -4744,7 +4744,8 @@ function routingPage(part) { // that same account uses provider@user and the base ID names another. // Group accounts by their identity, resolving each try in its own route. const keyOf = (w) => w.kind === "account" && w.who - ? JSON.stringify([w.provider, w.who.trim().toLowerCase()]) : w.id; + ? JSON.stringify(w.plan && String(w.plan).trim() + ? [w.provider, w.who.trim().toLowerCase(), String(w.plan).trim().toLowerCase()] : [w.provider, w.who.trim().toLowerCase()]) : w.id; // Live: the day's counts come with the history read the page already // asks for (#3351) — the Usage page's own reading of the day, not the // last few requests the gateway keeps. What that read cannot say (the diff --git a/internal/gui/tests/linux-no-backdrop-blur.test.cjs b/internal/gui/tests/linux-no-backdrop-blur.test.cjs new file mode 100644 index 000000000..2081513e6 --- /dev/null +++ b/internal/gui/tests/linux-no-backdrop-blur.test.cjs @@ -0,0 +1,35 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// The Linux app's WebKitGTK draws without accelerated compositing, where a +// backdrop blur is repainted by the CPU on every frame (a full-window modal +// cost 25ms a frame against 16ms with none). On Linux the app's modals, +// pickers and sticky Settings head draw without the blur; elsewhere they keep it. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const css = path.resolve(__dirname, "../assets/app.css"); +const probe = `
+