perf: trim session IPC hot paths and fix clear-effects idle render

Skip full project broadcast on graph/NPC position commits, send session.stateChanged only to consumer windows, and force one Pixi render before stopping the idle ticker so Clear effects actually clears the canvas.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-07-23 12:32:03 +08:00
parent d9fbecf5a7
commit a797162f16
7 changed files with 121 additions and 8 deletions
+27 -1
View File
@@ -10,7 +10,7 @@ import { safeConsoleError } from '../safeConsole';
import { getBootSplashWindow } from './bootWindow';
import { loadBrandingWindowIcon } from './brandingIcon';
type WindowKind =
export type WindowKind =
| 'editor'
| 'presentation'
| 'control'
@@ -19,6 +19,15 @@ type WindowKind =
| 'npcsEditor'
| 'npcs';
/** Окна, которые реально слушают session.stateChanged (редактор синхронизируется через invoke). */
export const SESSION_STATE_WINDOW_KINDS: readonly WindowKind[] = [
'presentation',
'control',
'materials',
'npcs',
'npcsEditor',
] as const;
const windows = new Map<WindowKind, BrowserWindow>();
let appQuitting = false;
@@ -63,6 +72,23 @@ export function markAppQuitting(): void {
appQuitting = true;
}
/** Точечная рассылка в известные окна приложения (без splash / чужих BrowserWindow). */
export function sendToAppWindows(
channel: string,
payload: unknown,
kinds: readonly WindowKind[] = SESSION_STATE_WINDOW_KINDS,
): void {
for (const kind of kinds) {
const win = windows.get(kind);
if (!win || win.isDestroyed() || win.webContents.isDestroyed()) continue;
try {
win.webContents.send(channel, payload);
} catch {
/* окно могло закрыться между проверкой и send */
}
}
}
function quitAppFromEditorClose(): void {
markAppQuitting();
app.quit();