From 48fffb60c581dcc3e2116835a36b8600b8aae188 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 18 Nov 2026 14:56:22 +0800 Subject: [PATCH] gui: the provider editor waits for its Advanced headings before it draws (#7051) 31575f71a grouped the editor's Advanced rows from advgroups.js, imported as Providers first draws. An editor opened before the import landed drew its rows ungrouped and moved them under headings a moment later, so a reader saw the rows jump and settings-groups read either order (red 6 of 14 on origin/main 61c714ed0, both engines, en and zh). renderProviders now waits for the import (a local file, a few ms) before it draws an open editor, and groupAdvanced groups in the same draw. A failed import draws the editor ungrouped rather than not at all. settings-groups lists Claude's rows in the grouped order. Run (mote, at this tree): - settings-groups 3 runs, advanced-headings, provider-prefs, settings-search, provider-unsaved-paths, Chromium and WebKit: all pass (14, 10, 20, 18, 4). - go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok. Broken by hand, then put back: - the wait removed and the import held 400ms: settings-groups 6 of 14 red. - the wait kept and the import held 400ms: settings-groups and advanced-headings green. Not tried: the real app window, the full GUI suite. --- internal/gui/assets/app.js | 6 ++++-- internal/gui/tests/settings-groups.test.cjs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 7a449471b..34a7ed1a7 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -6180,7 +6180,9 @@ const setupPaste = (q) => { }; function renderProviders(quiet) { pasteLoad(); + // an editor waits for advgroups.js, so its rows never move after it draws (#7051) advMod(); + if (!advMod.done && editing) return void advMod.p.then(() => renderProviders(quiet)); if (accountArranging || providerArranging) { accountRenderPending = true; return; } providersBehind = false; // a rebuild clamps the scroll to the top: put it back @@ -8080,8 +8082,8 @@ document.addEventListener("click", (e) => { // groupAdvanced: the editor's Advanced rows under small headings // (advgroups.js, fetched as Providers first draws, so an editor opens with // them in place) -const advMod = () => (advMod.p ||= import("./advgroups.js")); -const groupAdvanced = (b) => self.advGroups ? advGroups(b) : advMod().then(() => b.isConnected && advGroups(b), () => {}); +const advMod = () => (advMod.p ||= import("./advgroups.js").catch(() => {}).finally(() => advMod.done = true)); +const groupAdvanced = (b) => self.advGroups?.(b); // advancedSet says whether a setting under the editor's Advanced is set, // which opens it: none hides behind a fold function advancedSet(d, p) { diff --git a/internal/gui/tests/settings-groups.test.cjs b/internal/gui/tests/settings-groups.test.cjs index 8284dc99e..3b0c0ac03 100644 --- a/internal/gui/tests/settings-groups.test.cjs +++ b/internal/gui/tests/settings-groups.test.cjs @@ -216,7 +216,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await edit("claude"); assert.deepEqual(await panes(page), ["claude"]); // Claude Code's own run row is Claude's too - assert.deepEqual(await visibleRows(), [w.lean, w.extra, w.reset, w.daily]); + assert.deepEqual(await visibleRows(), [w.reset, w.daily, w.lean, w.extra]); await thumbsUnderPicks("claude"); await press(page.locator(".editor #claudeWarmSegs .opt").nth(2)); await last("claudeWarmup", "all");