Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: a browser tab's font rows show on a nogui magpie, and Text size no longer flashes
yetone7b63feb908da
diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.mdindex e64132ee5..176e50d0a 100644--- a/docs/subsystems/gui-shell.md+++ b/docs/subsystems/gui-shell.md@@ -258,17 +258,24 @@ CoreText on macOS and Fontconfig on Linux. Discovery is lazy, cached in thehandler, and refreshed by the menu. It returns names and CSS traits, neverfont files or paths. A failed refresh answers 503 and preserves the previouscollection; an empty successful collection is distinct from failure.-A `nogui` build can't read the catalogue and answers 404.+A `nogui` build can't read the catalogue and answers the app 404.-A browser tab (`magpie web`, or the app's page opened in a browser) has the-same rows when boot says `fonts` (Norcleeh on Discord). Its choice is the+A browser tab (`magpie web`, or the app's page opened in a browser) always+has the same rows (Norcleeh on Discord). Its choice is thebrowser's own, kept in `localStorage` under `magpie.fonts` and applied by`fonts.js` before the first paint: the tab can be on another computer, so-it neither changes nor takes the app's `settings.UIFont`/`CodeFont`. Its-list is `/api/fonts` less the families the browser doesn't draw-(`desktopFonts.here`: text in the family measures apart from a generic-family's on a canvas), so another computer's fonts, and Safari's-user-installed ones, aren't offered. In a nogui build the rows stay hidden.+it neither changes nor takes the app's `settings.UIFont`/`CodeFont`. A+tab's `/api/fonts` is the server's families (none in a nogui build such as+Docker or `magpie-cli`, and none when reading them fails, never an error)+plus `commonFamilies` in `internal/gui/fonts.go`, in regular and bold.+The tab keeps those it draws (`desktopFonts.here`: text in the family+measures apart from a generic family's on a canvas), so another computer's+fonts, and Safari's user-installed ones, aren't offered. When none is+kept, the rows still offer System default. Until 10-28 the rows were+gated on a boot `fonts` flag, so a nogui server had none, and what+"flashed and vanished" on a refresh was Text size: the rows a tab never+shows (Text size, the tray click, Open at login, the menu bar's+allowances) are `.app-only`, which `body.web` hides before the first paint.`settings.UIFont` and `settings.CodeFont` keep the family, style name,OpenType weight, CSS slope and width percentage. A missing choice keeps thediff --git a/internal/gui/api.go b/internal/gui/api.goindex fb92d11aa..121c06544 100644--- a/internal/gui/api.go+++ b/internal/gui/api.go@@ -855,12 +855,9 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {if s.Colorblind {boot["colorblind"] = true}- // a browser tab keeps its own font choice (fonts.js) and is told- // whether there is a list to choose from+ // a browser tab keeps its own font choice (fonts.js)if !isWeb(w) {boot["uiFont"], boot["codeFont"] = s.UIFont, s.CodeFont- } else if fonts.Available {- boot["fonts"] = true}// and whether it is a gateway's page alone (gatewaymode.go), so the// pages left out never show@@ -906,7 +903,7 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {writeJSON(rw, nil)})omarchyRoutes(mux, w)- fontRoutes(mux, !fonts.Available, fonts.List)+ fontRoutes(mux, isWeb(w), !fonts.Available, fonts.List)mux.HandleFunc("GET /api/state", func(rw http.ResponseWriter, r *http.Request) {// the panel and its model picker load from here: an account still// without its vendor's list (one whose try at start-up failed) isdiff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.cssindex bf1916be4..b0ae912bd 100644--- a/internal/gui/assets/app.css+++ b/internal/gui/assets/app.css@@ -159,6 +159,9 @@ button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); ouinput { font: inherit; color: var(--fg); }.grow { flex: 1; }[hidden] { display: none !important; }+/* the app's own rows (Text size, the tray, login, the menu bar's allowances)+ never paint in a browser tab, before renderSettings hides them too */+body.web .app-only { display: none !important; }code { font: var(--code-style, normal) var(--code-weight, 400) 11.5px var(--code-font, var(--code)); font-stretch: var(--code-stretch, 100%); }/* ---- brand icons: colour ones are images, mono ones take the text colour --- */diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 018aa631a..cd9b46c8a 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -18864,7 +18864,6 @@ if (!web) addEventListener("keydown", (e) => {// keep the family/style controls usable while the shared save queue drains.let fontList = null, fontListError = false, fontFlight = null, fontRevision = 0;const fontDrafts = {};-const fontsOn = !web || window.bootPrefs?.fonts;function fontChoices(s) {if (web) return { ...s, ...window.desktopFonts.own() };return { ...s, ...Object.fromEntries(Object.entries(fontDrafts).map(([k, d]) => [k, d.value])) };@@ -18880,7 +18879,7 @@ window.receiveFonts = (s) => {if (prefs && view === "settings") renderFonts(prefs);};async function loadFonts(refresh = false) {- if (!fontsOn || fontFlight || (fontList !== null && !refresh)) return fontFlight;+ if (fontFlight || (fontList !== null && !refresh)) return fontFlight;fontListError = false;fontFlight = api("fonts" + (refresh ? "?refresh=1" : "")).then((list) => {@@ -18918,7 +18917,7 @@ function renderFonts(s) {const current = fontChoices(s);for (const [key, id, label] of [["uiFont", "uiFontRow", "Interface font"], ["codeFont", "codeFontRow", "Code font"]]) {const row = $("#" + id);- if (row.hidden = !fontsOn) continue;+ row.hidden = false;const chosen = current[key], family = fontList?.find((f) => f.name === chosen?.family);const missing = chosen && !window.desktopFonts.available(chosen);const note = row.querySelector(".font-note");@@ -19061,7 +19060,7 @@ function renderLoginAllow(s) {async function loadSettings() {const since = prefsWrites;- if (fontsOn && fontList === null && !fontListError) loadFonts();+ if (fontList === null && !fontListError) loadFonts();if (window.bootPrefs?.omarchy && !barIcon) api("omarchy/widget").then((b) => { barIcon = b; renderBarIcon(); }).catch(() => {});const s = await api("settings");if (!prefsSettled(since) && prefs) return; // the save draws the page when it's indiff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.htmlindex 054402c06..21961f7b3 100644--- a/internal/gui/assets/index.html+++ b/internal/gui/assets/index.html@@ -180,7 +180,7 @@<div class="who"><div class="name" data-t>Gateway mode</div><div class="sub" id="gatewayModeSub"></div></div><div id="gatewayModeSegs"></div></div>- <div class="row pref" id="textSizeRow">+ <div class="row pref app-only" id="textSizeRow"><div class="who"><div class="name" data-t>Text size</div></div><div id="textSizeSegs"></div></div>@@ -200,7 +200,7 @@<div class="font-preview">Aa 0123 · 中文</div></div></div>- <div class="row pref">+ <div class="row pref app-only"><div class="who"><div class="name" data-t>Click the tray icon to</div></div><div id="traySegs"></div></div>@@ -214,7 +214,7 @@</div><!-- Codex's and Claude Code's own settings are on the Agents page (AGENT_PREFS); while searching, a row here says where --><div id="agentPrefLinks"></div>- <div class="row pref" id="loginRow">+ <div class="row pref app-only" id="loginRow"><div class="who"><div class="name" data-t>Open at login</div></div><div id="loginSegs"></div></div>@@ -242,7 +242,7 @@</section><section class="set-page" id="setPage-usage" role="tabpanel" aria-labelledby="setTab-usage"><div class="list prefs">- <div class="row pref" id="trayUsageRow">+ <div class="row pref app-only" id="trayUsageRow"><div class="who"><div class="name" data-t>Allowances in the menu bar</div><div class="sub" id="trayUsageSub"></div></div><div id="trayUsagePick"></div></div>diff --git a/internal/gui/fonts.go b/internal/gui/fonts.goindex 7ea5ed6e6..11ee1e801 100644--- a/internal/gui/fonts.go+++ b/internal/gui/fonts.go@@ -3,6 +3,8 @@ package guiimport ("encoding/json""net/http"+ "slices"+ "strings""sync""github.com/yetone/magpie/internal/fonts"@@ -22,30 +24,74 @@ func fontSettingsJS(s settings.Settings) string {}// The fonts installed on the computer magpie runs on, for its windows and-// for a browser tab (which keeps the families it draws itself, fonts.js);-// off where they can't be read (a nogui build). A failed refresh leaves-// the last successful collection intact.-func fontRoutes(mux *http.ServeMux, off bool, discover func() ([]fonts.Family, error)) {+// for a browser tab (which keeps the families it draws itself, fonts.js).+// A browser tab is also offered common families: it may be on another+// computer, and a nogui build (Docker, magpie-cli) reads no fonts at all,+// where its rows were left out and only Text size flashed by (Norcleeh).+// A failed refresh leaves the last successful collection intact.+func fontRoutes(mux *http.ServeMux, web, off bool, discover func() ([]fonts.Family, error)) {var mu sync.Mutexvar cached []fonts.Familymux.HandleFunc("GET /api/fonts", func(rw http.ResponseWriter, r *http.Request) {- if off {+ if off && !web {http.Error(rw, "installed fonts can't be read by this magpie", http.StatusNotFound)return}mu.Lock()defer mu.Unlock()- if cached == nil || r.URL.Query().Get("refresh") == "1" {+ if !off && (cached == nil || r.URL.Query().Get("refresh") == "1") {found, err := discover()- if err != nil {+ switch {+ case err == nil && found == nil:+ cached = []fonts.Family{}+ case err == nil:+ cached = found+ case !web: // a tab still has the common familieshttp.Error(rw, "could not read installed fonts", http.StatusServiceUnavailable)return}- cached = found- if cached == nil {- cached = []fonts.Family{}- }+ }+ if web {+ writeJSON(rw, withCommon(cached))+ return}writeJSON(rw, cached)})}++// Families most computers have, by system and script; the tab keeps those+// it draws. Each is offered in its regular and bold weights.+var commonFamilies = []string{+ "Arial", "Avenir Next", "Calibri", "Cambria", "Cascadia Code", "Cascadia Mono", "Consolas", "Courier New",+ "DejaVu Sans", "DejaVu Sans Mono", "Fira Code", "Fira Sans", "Georgia", "Helvetica", "Helvetica Neue",+ "Hiragino Sans", "Hiragino Sans GB", "IBM Plex Mono", "IBM Plex Sans", "Inter", "JetBrains Mono",+ "Liberation Mono", "Liberation Sans", "Lucida Grande", "LXGW WenKai", "Malgun Gothic", "Maple Mono", "Menlo",+ "Microsoft JhengHei", "Microsoft YaHei", "Monaco", "Noto Sans", "Noto Sans CJK SC", "Noto Sans Mono",+ "Noto Serif", "Noto Serif CJK SC", "Palatino", "PingFang SC", "PingFang TC", "Roboto", "Roboto Mono",+ "Sarasa Gothic SC", "Segoe UI", "SF Mono", "SimHei", "SimSun", "Songti SC", "Source Code Pro",+ "Source Han Sans SC", "Tahoma", "Times New Roman", "Trebuchet MS", "Ubuntu", "Ubuntu Mono", "Verdana",+ "WenQuanYi Micro Hei", "Yu Gothic",+}++// withCommon adds the common families the list lacks, by name in any case,+// and keeps it in the order fonts.List gives (case-insensitive names).+func withCommon(found []fonts.Family) []fonts.Family {+ out := slices.Clone(found)+ have := map[string]bool{}+ for _, f := range found {+ have[strings.ToLower(f.Name)] = true+ }+ for _, name := range commonFamilies {+ if have[strings.ToLower(name)] {+ continue+ }+ face := fonts.Face{Family: name, Name: "Regular", Weight: 400, Style: "normal", Stretch: 100}+ bold := face+ bold.Name, bold.Weight = "Bold", 700+ out = append(out, fonts.Family{Name: name, Styles: []fonts.Face{face, bold}})+ }+ slices.SortStableFunc(out, func(a, b fonts.Family) int {+ return strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name))+ })+ return out+}diff --git a/internal/gui/fonts_test.go b/internal/gui/fonts_test.goindex d92949f55..9b07734e3 100644--- a/internal/gui/fonts_test.go+++ b/internal/gui/fonts_test.go@@ -6,6 +6,7 @@ import ("net/http""net/http/httptest""reflect"+ "slices""strings""testing"@@ -19,7 +20,7 @@ func TestFontDiscoveryCacheAndFailure(t *testing.T) {want := []fonts.Family{{Name: face.Family, Styles: []fonts.Face{face}}}calls, broken := 0, falsemux := http.NewServeMux()- fontRoutes(mux, false, func() ([]fonts.Family, error) {+ fontRoutes(mux, false, false, func() ([]fonts.Family, error) {calls++if broken {return nil, errors.New("font service unavailable")@@ -57,15 +58,70 @@ func TestFontDiscoveryCacheAndFailure(t *testing.T) {if calls != 3 {t.Fatalf("refresh did not re-read fonts: %d", calls)}- web := http.NewServeMux()- fontRoutes(web, true, func() ([]fonts.Family, error) { t.Fatal("fonts read where they can't be"); return nil, nil })+ off := http.NewServeMux()+ fontRoutes(off, false, true, func() ([]fonts.Family, error) { t.Fatal("fonts read where they can't be"); return nil, nil })r = httptest.NewRecorder()- web.ServeHTTP(r, httptest.NewRequest("GET", "/api/fonts", nil))+ off.ServeHTTP(r, httptest.NewRequest("GET", "/api/fonts", nil))if r.Code != 404 {t.Fatalf("font discovery turned off returned %d", r.Code)}}+// Norcleeh: a nogui magpie's browser tab had no font rows. A tab is offered+// the server's families and the common ones, whatever the server can read.+func TestBrowserTabFontsWithoutInstalledFonts(t *testing.T) {+ read := func(off bool, discover func() ([]fonts.Family, error)) []fonts.Family {+ t.Helper()+ mux := http.NewServeMux()+ fontRoutes(mux, true, off, discover)+ r := httptest.NewRecorder()+ mux.ServeHTTP(r, httptest.NewRequest("GET", "/api/fonts", nil))+ if r.Code != 200 {+ t.Fatalf("a browser tab's fonts answered %d %s", r.Code, r.Body)+ }+ var got []fonts.Family+ if err := json.Unmarshal(r.Body.Bytes(), &got); err != nil {+ t.Fatal(err)+ }+ return got+ }+ names := func(list []fonts.Family) []string {+ var out []string+ for _, f := range list {+ out = append(out, f.Name)+ }+ return out+ }+ nogui := read(true, func() ([]fonts.Family, error) { t.Fatal("fonts read where they can't be"); return nil, nil })+ if len(nogui) != len(commonFamilies) {+ t.Fatalf("a nogui magpie's tab got %v", names(nogui))+ }+ for _, f := range nogui {+ if len(f.Styles) != 2 || f.Styles[0].Family != f.Name || fonts.Validate(&f.Styles[0]) != nil || fonts.Validate(&f.Styles[1]) != nil {+ t.Fatalf("common family %#v", f)+ }+ }+ if failed := read(false, func() ([]fonts.Family, error) { return nil, errors.New("no font service") }); len(failed) != len(commonFamilies) {+ t.Fatalf("a failed read left the tab %v", names(failed))+ }+ own := fonts.Face{Family: "georgia", Name: "Light", Weight: 300, Style: "normal", Stretch: 100}+ odd := fonts.Face{Family: "Zzz Own Family", Name: "Regular", Weight: 400, Style: "normal", Stretch: 100}+ got := read(false, func() ([]fonts.Family, error) {+ return []fonts.Family{{Name: own.Family, Styles: []fonts.Face{own}}, {Name: odd.Family, Styles: []fonts.Face{odd}}}, nil+ })+ if len(got) != len(commonFamilies)+1 {+ t.Fatalf("the server's own families and the common ones: %v", names(got))+ }+ if !slices.IsSortedFunc(got, func(a, b fonts.Family) int { return strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) }) {+ t.Fatalf("not in name order: %v", names(got))+ }+ for _, f := range got {+ if strings.EqualFold(f.Name, "Georgia") && !reflect.DeepEqual(f.Styles, []fonts.Face{own}) {+ t.Fatalf("the server's Georgia was replaced: %#v", f)+ }+ }+}+func TestFontSettingsAPIAndBoot(t *testing.T) {testenv.SetHome(t, t.TempDir())notices := 0@@ -114,9 +170,11 @@ func TestFontSettingsAPIAndBoot(t *testing.T) {if _, ok := webBoot["uiFont"]; ok {t.Fatal("browser received a desktop font override")}- // a browser tab is offered the font list wherever magpie can read one- if _, ok := webBoot["fonts"]; ok != fonts.Available {- t.Fatalf("browser boot fonts = %v, want %v", ok, fonts.Available)+ // a browser tab's rows show wherever it is served, nogui too+ r := httptest.NewRecorder()+ web.ServeHTTP(r, httptest.NewRequest("GET", "/api/fonts", nil))+ if r.Code != 200 || !strings.Contains(r.Body.String(), `"Georgia"`) {+ t.Fatalf("a browser tab's fonts answered %d", r.Code)}post(h, map[string]any{"uiFont": map[string]any{"family": "bad", "name": "Regular", "weight": 1001}}, 400)if !reflect.DeepEqual(settings.Load().UIFont, face) {diff --git a/internal/gui/tests/fonts.test.cjs b/internal/gui/tests/fonts.test.cjsindex ea53de1e9..6b72677ca 100644--- a/internal/gui/tests/fonts.test.cjs+++ b/internal/gui/tests/fonts.test.cjs@@ -17,7 +17,7 @@ const catalogue = [async function open(browser, lang = "en", options = {}) {const context = await browser.newContext({ locale: lang === "zh" ? "zh-CN" : "en-US", viewport: options.viewport || { width: 1000, height: 820 } });- const api = { posts: [], reads: 0, fonts: structuredClone(catalogue), fontError: false, saveError: false, delay: 0,+ const api = { posts: [], reads: 0, fonts: structuredClone(options.list || catalogue), fontError: false, saveError: false, delay: 0,cur: { lang, theme: "light", textSize: 100, currency: "usd", tray: "panel", version: "0.1.0", visionModels: [], imageGenModels: [], ...options.settings } };const page = await context.newPage();page.setDefaultTimeout(5000);@@ -26,13 +26,14 @@ async function open(browser, lang = "en", options = {}) {await page.route("**/*", async route => {const req = route.request(), url = new URL(req.url());const json = data => route.fulfill({ json: data });- if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs=${JSON.stringify({ ...api.cur, web: !!options.web, ...(options.fonts ? { fonts: true } : {}), ...(options.omarchy ? { omarchy: { mode: "dark", stamp: "one", name: "Test theme", vars: { "--font": '"Theme Font", sans-serif', "--code": '"Theme Mono", monospace' } } } : {}) })};` });+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs=${JSON.stringify({ ...api.cur, web: !!options.web, ...(options.omarchy ? { omarchy: { mode: "dark", stamp: "one", name: "Test theme", vars: { "--font": '"Theme Font", sans-serif', "--code": '"Theme Mono", monospace' } } } : {}) })};` });if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });if (url.pathname === "/api/fonts") {api.reads++;return api.fontError ? route.fulfill({ status: 503, body: "could not read installed fonts" }) : json(api.fonts);}if (url.pathname === "/api/settings") {+ if (options.settingsDelay) await new Promise(r => setTimeout(r, options.settingsDelay));if (req.method() === "POST") {const body = req.postDataJSON();api.posts.push(body);@@ -53,6 +54,17 @@ async function open(browser, lang = "en", options = {}) {try { return await route.fulfill({ body: await fs.readFile(file), contentType }); }catch { return route.fulfill({ status: 404, body: "not found" }); }});+ // every frame's rows, from the first paint (Norcleeh: a row flashed and went)+ if (options.frames) await page.addInitScript(() => {+ window.__frames = [];+ const ids = ["uiFontRow", "codeFontRow", "textSizeRow", "loginRow", "trayUsageRow"];+ const look = () => {+ const tray = document.getElementById("traySegs")?.parentElement;+ if (document.getElementById("uiFontRow")) window.__frames.push(Object.fromEntries([...ids.map(id => [id, !!document.getElementById(id)?.getClientRects().length]), ["tray", !!tray?.getClientRects().length]]));+ requestAnimationFrame(look);+ };+ requestAnimationFrame(look);+ });await watchSettingsReads(page);await page.goto("http://magpie.test/?view=settings&tab=general");await settingsDrawn(page); // rows found are the ones that stay (#1659)@@ -60,7 +72,8 @@ async function open(browser, lang = "en", options = {}) {// A real assertion, also usable against the original assets, rather than// a timeout or a compile error as the negative-control result.assert.equal(await page.locator("#uiFontRow").count(), 1, "Settings must offer an interface font picker");- if (!options.web || options.fonts) await page.waitForFunction(() => fontList !== null || fontListError);+ // (a row left hidden, as before 10-28 in a nogui magpie's tab, fails at its assertion, not here)+ await page.waitForFunction(() => fontList !== null || fontListError || document.getElementById("uiFontRow").hidden);await page.evaluate(async () => {await document.fonts.ready;await Promise.all(document.getAnimations().map(a => a.finished.catch(() => {})));@@ -272,12 +285,6 @@ for (const [engine, runtime] of engines) {assert.match((await css(page, "body")).family, /Theme Font/);assert.match((await css(page, "#codeFontRow .font-preview")).family, /Consolas/);assert.deepEqual(errors, []);- // a magpie that can't read its fonts (nogui) offers none to a browser- const web = await open(browser, "en", { web: true, settings: { uiFont: harmony[1] } });- assert.equal(await web.page.locator("#uiFontRow").isVisible(), false);- assert.equal(web.api.reads, 0);- assert.doesNotMatch((await css(web.page, "body")).family, /HarmonyOS/);- assert.deepEqual(web.errors, []);} finally { await browser.close(); }});@@ -288,7 +295,7 @@ for (const [engine, runtime] of engines) {try {const real = ["Georgia", "Courier New", "DejaVu Serif", "Liberation Serif"];const list = [{ name: "No Such Family Here", styles: [face("No Such Family Here")] }, ...real.map(n => ({ name: n, styles: [face(n), face(n, "Bold", 700)] }))];- const { page, api, errors } = await open(browser, lang, { web: true, fonts: true, settings: { uiFont: harmony[1] } });+ const { page, api, errors } = await open(browser, lang, { web: true, settings: { uiFont: harmony[1] } });api.fonts = list;assert.equal(await page.locator("#uiFontRow").isVisible(), true, "a browser tab offers the interface font");assert.equal(await page.locator("#codeFontRow").isVisible(), true, "and the code font");@@ -321,6 +328,44 @@ for (const [engine, runtime] of engines) {} finally { await browser.close(); }});+ // Norcleeh again, after v0.1.1788: on a refresh a row "flashed and went".+ // A nogui magpie (Docker, magpie-cli) has no boot `fonts`, so the font+ // rows never showed, and Text size painted until the settings hid it.+ // The tab's rows show whatever the server can read, with System default+ // when the browser draws none of its families, and stay through every+ // later settings read; the app's own rows never paint at all.+ for (const lang of ["en", "zh"]) test(`${engine} ${lang}: a browser tab's font rows show on a nogui magpie and nothing flashes`, async () => {+ const browser = await runtime.launch();+ try {+ for (const fonts of [[{ name: "Georgia", styles: [face("Georgia"), face("Georgia", "Bold", 700)] }, { name: "No Such Family Here", styles: [face("No Such Family Here")] }], []]) {+ const { page, errors, close } = await open(browser, lang, { web: true, frames: true, settingsDelay: 300, list: fonts, settings: { uiFont: harmony[1] } });+ // what a later refresh of the settings or the state redraws+ await page.evaluate(() => loadSettings());+ await page.evaluate(() => new Promise(r => setTimeout(r, 500)));+ const frames = await page.evaluate(() => window.__frames);+ assert(frames.length > 5, "frames were watched: " + frames.length);+ for (const row of ["uiFontRow", "codeFontRow"]) {+ assert.equal(await page.locator("#" + row).isVisible(), true, row + " shows in a browser tab");+ const first = frames.findIndex(f => f[row]);+ assert(first >= 0, row + " never painted");+ assert(frames.slice(first).every(f => f[row]), row + " painted and then went: " + frames.map(f => +f[row]).join(""));+ }+ for (const row of ["textSizeRow", "loginRow", "trayUsageRow", "tray"]) {+ assert(!frames.some(f => f[row]), row + " is the app's and painted in a browser tab: " + frames.map(f => +f[row]).join(""));+ }+ const shown = await page.evaluate(() => fontList.map(f => f.name));+ assert(!shown.includes("No Such Family Here"), "a family this browser doesn't draw isn't offered: " + shown);+ await page.locator("#codeFontRow .font-family").click();+ const names = await page.locator(".font-menu .pm-item .pm-name").allTextContents();+ assert.equal(names[0], lang === "zh" ? "系统默认" : "System default", "System default is offered: " + names);+ if (!fonts.length) assert.deepEqual(shown, [], "no family this browser draws");+ await page.keyboard.press("Escape");+ assert.deepEqual(errors, []);+ await close();+ }+ } finally { await browser.close(); }+ });+test(`${engine}: native notifications update the other webview without another save`, async () => {const browser = await runtime.launch();try {