fix(ui): stop settings save echoes from clobbering theme preferences

Every updateDesktopSettings PUT replays the server's full settings
document as an openchamber:settings-synced event, and the theme listener
adopted it unconditionally - so switching sessions across directories
(any lastDirectory/activeProjectId write) could flip the theme to
whatever the server document held at that moment. A bootstrap GET with
missing theme fields made it worse: materializeAuthoritativeUiSettings
invented useSystemTheme + openchamber defaults and the persist effect
wrote them back to the server and the scoped localStorage entry.

Theme is now adopted only from bootstrap-grade syncs (the renamed
bootstrap flag, formerly adoptWorkspace), missing fields mean 'not set'
and keep the current preference, and the materializer no longer invents
theme defaults. Cross-window same-instance theme sync still rides the
scoped-key storage event; runtime endpoint switches still adopt the new
instance's server theme.

Closes the 'theme flashes to OpenChamber when switching sessions' report;
same family as the pre-#2897 'color mode forced to light' symptom.
This commit is contained in:
Pablo
2026-08-31 21:18:43 +02:00
parent 715c33b83c
commit a42fb91daf
7 changed files with 174 additions and 53 deletions
+1 -1
View File
@@ -1112,7 +1112,7 @@ if (typeof window !== 'undefined') {
const detail = (event as CustomEvent<SettingsSyncedDetail>).detail;
if (detail && typeof detail === 'object' && detail.settings) {
useProjectsStore.getState().synchronizeFromSettings(detail.settings, {
adoptActiveProject: detail.adoptWorkspace,
adoptActiveProject: detail.bootstrap,
});
}
});