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.
This commit is contained in:
yetone
2026-11-18 14:56:22 +08:00
parent 42181fdd27
commit 48fffb60c5
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -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) {
+1 -1
View File
@@ -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");