Save interface-scale changes from every window

Ctrl/Cmd +/-/0 in editor and connection-manager windows called
SettingsService.persist() -> saveSettings, but only the main window's RPC
served that request: it went unanswered, the new scale applied locally, and
the next broadcast from main snapped it back.

All three window RPCs now serve saveSettings through one shared
saveSettingsHandler (persist, then hand off). index.ts's settingsSaved() is
the single place settings side effects run — transfer concurrency, locale +
app menu, the preload snapshot — whichever window saved, and it rebroadcasts
to every window EXCEPT the sender: an echo arriving behind a newer local
change (a held Cmd+) would drag it backwards. Editors are skipped by their
registry key, main and the manager by name.

Known ceiling, noted at the handler: whole-object writes, so two windows
saving in the same instant means the later one wins.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-23 16:24:27 +02:00
co-authored by Claude
parent f7f02083fe
commit c3d97ce524
6 changed files with 64 additions and 18 deletions
+16 -4
View File
@@ -92,6 +92,7 @@ const editors = new EditorWindows({
currentSettings: () => currentSettings,
mainFrame: () => win.getFrame(),
notifyMain: { pathRefresh: (info) => rpc.send.pathRefresh(info) },
onSettingsSaved: (s, key) => settingsSaved(s, { editor: key }),
});
const manager = new ManagerWindow({
store,
@@ -105,19 +106,30 @@ const manager = new ManagerWindow({
menuAction: (info) => rpc.send.menuAction(info),
},
rebuildMenu: () => void applyApplicationMenu(store),
onSettingsSaved: (s) => settingsSaved(s, "manager"),
});
events.openEditor = (ctx) => editors.open(ctx);
events.settingsChanged = (s) => {
/**
* Every settings save lands here, whichever window made it (editor and manager
* windows save too — the scale shortcuts): side effects run once, then every
* OTHER window follows. The sender is skipped — it already shows the new
* values, and an echo arriving behind a newer local change (a held Cmd+) would
* drag it backwards.
*/
function settingsSaved(s: AppSettings, sender: "main" | "manager" | { editor: string }): void {
engine.setConcurrency(effectiveConcurrency(s));
const localeChanged = s.locale !== currentSettings.locale;
currentSettings = s; // future windows' preloads bake the fresh theme
if (localeChanged) {
setBackendLocale(s.locale);
void applyApplicationMenu(store); // relabel the native menu in the new language
}
editors.broadcastSettings(s);
manager.broadcastSettings(s);
};
if (sender !== "main") rpc.send.settingsChanged({ settings: s });
if (sender !== "manager") manager.broadcastSettings(s);
editors.broadcastSettings(s, typeof sender === "object" ? sender.editor : undefined);
}
events.settingsChanged = (s) => settingsSaved(s, "main");
events.openConnectionManager = () => manager.open();
function showAbout(): void {