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:
@@ -1369,7 +1369,7 @@ const maybeShowNativeNotification = (rawInput) => {
|
||||
notification.on('click', () => {
|
||||
focusForegroundWindow();
|
||||
if (sessionId) {
|
||||
emitToAllWindows('openchamber:open-session', { sessionId, directory });
|
||||
emitToPrimaryWindow('openchamber:open-session', { sessionId, directory });
|
||||
}
|
||||
release();
|
||||
});
|
||||
@@ -1997,6 +1997,18 @@ const emitToAllWindows = (event, detail) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Session navigation must land in ONE window. Broadcasting it makes every
|
||||
// open window adopt the same session, hijacking whatever the other windows
|
||||
// were doing.
|
||||
const emitToPrimaryWindow = (event, detail) => {
|
||||
const windows = BrowserWindow.getAllWindows().filter((window) => !window.isDestroyed());
|
||||
if (windows.length === 0) return;
|
||||
const target = (state.mainWindow && !state.mainWindow.isDestroyed())
|
||||
? state.mainWindow
|
||||
: windows.find((window) => window.isFocused()) || windows.find((window) => window.isVisible()) || windows[0];
|
||||
emitToWindow(target, event, detail);
|
||||
};
|
||||
|
||||
const setTaskbarProgress = (value) => {
|
||||
if (process.platform !== 'win32') return;
|
||||
for (const browserWindow of BrowserWindow.getAllWindows()) {
|
||||
@@ -2278,7 +2290,7 @@ const dispatchDeepLink = (link) => {
|
||||
}
|
||||
|
||||
if (link.type === 'session' && link.value) {
|
||||
emitToAllWindows('openchamber:open-session', { sessionId: link.value });
|
||||
emitToPrimaryWindow('openchamber:open-session', { sessionId: link.value });
|
||||
return;
|
||||
}
|
||||
if (link.type === 'host' && link.value) {
|
||||
|
||||
Reference in New Issue
Block a user