fix(desktop): stop windows from adopting each other's active project

Every window shares one server settings document, and every PUT returns the
merged whole, so one window's activeProjectId write was adopted by the
other on its next unrelated settings save — its sidebar then auto-selected
a session in that project and wrote the pointer back, converging both
windows onto one session. settings-synced now carries an adoptWorkspace
flag: only bootstrap-grade syncs (startup, runtime switch) may adopt the
shared workspace pointers; reconcile responses keep the window's own active
project while it exists. Notification clicks and session deep links also
stopped broadcasting the session switch to every window.
This commit is contained in:
Bohdan Triapitsyn
2026-08-26 18:36:50 +03:00
parent f7a006dc6a
commit 098034dc33
9 changed files with 114 additions and 33 deletions
@@ -11,7 +11,7 @@ import type { DesktopSettings } from '@/lib/desktop';
import { isDesktopLocalOriginActive, isDesktopShell as detectDesktopShell, isVSCodeRuntime } from '@/lib/desktop';
import { setDesktopWindowTheme } from '@/lib/desktopNative';
import { CSSVariableGenerator } from '@/lib/theme/cssGenerator';
import { updateDesktopSettings } from '@/lib/persistence';
import { type SettingsSyncedDetail, updateDesktopSettings } from '@/lib/persistence';
import {
themes,
getThemeById,
@@ -622,7 +622,7 @@ export function ThemeSystemProvider({ children, defaultThemeId }: ThemeSystemPro
return;
}
const handleSettingsSynced = (event: Event) => {
const detail = (event as CustomEvent<DesktopSettings>).detail;
const detail = (event as CustomEvent<SettingsSyncedDetail>).detail?.settings;
if (!detail) {
return;
}