Files
magpie/internal/gui/assets/settingsunread.js
T
yetone c2924c36d4 gui: Settings left blank after a restart say why and are read again; a view entrance plays out of sight (WaiooT on X)
WaiooT on X, v0.1.4573 on the Mac: after Restart only or Restart to
update the window came back on Settings › About with nothing under the
header and sidebar.

Two ways the page leaves that pane blank, both fixed:
- Every page of Settings is drawn from one read of /api/settings. One
  that failed (a magpie just restarted still starting, or its read
  erring) left them all empty, and only the footer said why, for 8 s;
  nothing read them again. The view now says "Couldn't read the
  settings" with the reason and Try again, and reads them again by
  itself at 2, 4, 8 s up to every 30 s; the line goes once they are
  read. It lives in settingsunread.js, imported only when a read fails,
  so app.js stays under its budget with no raise (TestCoreScriptBudget
  ok). Words in zh, zh-TW, ja and de.
- A page out of sight (the Mac's window hidden, #4293) paused every CSS
  animation, a view's one-shot entrance too, so a view shown then sat at
  its first frame, opacity 0, until the page heard it was back. A view's
  entrance now plays out of sight (app.css), and a page told it is back
  finishes any view entrance still running (playViews).

Run (mote):
- settings-unread.test.cjs (new): 14 pass at this tree, both engines,
  en/zh/ja; on the old app.js, app.css and i18n.js all 14 red (no line,
  About empty; the out-of-sight view's opacity "0").
- settings-*.test.cjs, window-visibility, window-asleep, version-restart,
  i18n-keys, i18n-en-no-cjk, old-webkit, panel-units-follow,
  sidebar-settings-steady and refresh-page, both engines: 510 pass, 2
  red, both old-webkit and both red on the base 76b490576 as well:
  guideback.js unlisted (#6570) and a :has() in app.css (#7235).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestAssets'
  ok.
- A real restart of a built magpie in a sandbox HOME (POST /api/restart,
  the handover, the new window's page reporting back): /api/settings
  answered in ~2 ms and About drew 18 rows, so an empty sandbox config
  didn't reproduce it; the new page's view did read opacity "0" while
  its window was out of sight.

Not tried: a visible window on a real Mac (over ssh the window never
shows), so which of the two the reporter met is not confirmed; the
reporter's own config.
2026-11-20 11:27:11 +08:00

27 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Settings that couldn't be read, imported from settingsUnread (app.js) when
// a read fails, so it weighs nothing on the core. A window back after a
// restart found Settings › About blank under its header and sidebar
// (WaiooT on X): every page of Settings is drawn from that read, and only
// the footer said, for 8 s, that it had failed. The view now says so, with
// Try again, and reads the settings again by itself, sooner first.
let timer, tries = 0;
export function unread(e) {
if (prefs || view !== "settings") return;
let line = $("#setUnread");
if (!line) {
line = el("div", "empty-state");
line.id = "setUnread";
$("#view-settings .set-head").after(line);
}
const again = el("button", "link", t("Try again"));
again.onclick = () => {
clearTimeout(timer);
if (prefs || view !== "settings") return;
(settingsLoad = loadSettings()).then(() => { tries = 0; backAfterLoad($("#view-settings")); }, settingsUnread);
};
line.replaceChildren(el("b", "", t("Couldn't read the settings")), e.message || "", " ", again);
clearTimeout(timer);
timer = setTimeout(() => again.click(), Math.min(30, 2 ** ++tries) * 1e3);
}