perf(settings): batch store registrations and defer font enumeration (#4058)

Settings pages, parent action proxies and template actions registered one by one, cloning the store map and notifying subscribers per item (~1,650 action and ~172 page updates per Settings open). registerActions now disposes in one update too, and the new registerSettingsPages batches page registration and disposal; both keep later per-id overrides. Disabled font pickers no longer enumerate system fonts; enabled ones defer it to idle and load at once on interaction, and the icon-font probe waits past startup.

Co-authored-by: dengliu <[email protected]>
Цей коміт міститься в:
Deng Liuтаdengliu authored and GitHub committed 2026-11-18 09:10:40 +08:00
1 джерело 0e169cc653
коміт 606a66b5dd
14 files changed
+290 -103

No files matched your search

+12 -16
Переглянути файл
@@ -2,7 +2,7 @@
import { useMemo, useRef, useState } from "react";
import { tx } from "@/platform/i18n";
import { Button, Checkbox, IconButton, Input, Select, T } from "@/ui";
import { registerSettingsPage, useSettingsForm } from "@/workbench/contributions";
import { registerSettingsPages, useSettingsForm } from "@/workbench/contributions";
import { pluginsBackend } from "./backend";
import { localizeContributions, usePluginCatalogs } from "./pluginText";
import { itemsOf } from "./projection";
@@ -372,24 +372,20 @@ function PluginSecrets({ pluginId }: { pluginId: string }) {
export function projectSettings(pluginId: string, decl: SettingsDecl): () => void {
const id = pluginSettingsPageId(pluginId);
const pages = decl.pages ?? [];
const dispose = [
registerSettingsPage({
return registerSettingsPages([
{
id,
title: decl.title,
projectScope: true,
keywords: ["plugin", pluginId, ...keywords(decl)],
component: pages.length ? undefined : settingsPage(pluginId, decl),
}),
];
for (const p of pages)
dispose.push(
registerSettingsPage({
id: `${id}.settings:${p.id}`,
title: p.title,
projectScope: true,
keywords: [pluginId, decl.title, ...keywords(p)],
component: settingsPage(pluginId, p),
}),
);
return () => dispose.forEach((d) => d());
},
...pages.map((p) => ({
id: `${id}.settings:${p.id}`,
title: p.title,
projectScope: true,
keywords: [pluginId, decl.title, ...keywords(p)],
component: settingsPage(pluginId, p),
})),
]);
}