From 3ccf8d102e07e369d17cd48b9194e23b67eddb8b Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Sun, 26 Oct 2025 14:02:49 +0530 Subject: [PATCH] =?UTF-8?q?Fix=20file=20rendering=20timing=20on=20first=20?= =?UTF-8?q?launch=20-=20delay=20initialization=20until=20UI=20fully=20load?= =?UTF-8?q?s=20-=20Added=20500ms=20delay=20to=20renderer-ready=20signal=20?= =?UTF-8?q?to=20ensure=20all=20UI=20initialization=20completes=20before=20?= =?UTF-8?q?opening=20files=20-=20Added=20100ms=20delay=20in=20openFileFrom?= =?UTF-8?q?Path=20to=20ensure=20main=20process=20doesn't=20send=20file=20b?= =?UTF-8?q?efore=20renderer=20is=20fully=20prepared=20-=20Prevents=20race?= =?UTF-8?q?=20condition=20where=20files=20would=20open=20before=20theme=20?= =?UTF-8?q?is=20applied=20and=20interface=20is=20ready=20-=20Files=20now?= =?UTF-8?q?=20render=20properly=20on=20first=20launch=20regardless=20of=20?= =?UTF-8?q?app=20startup=20time=20-=20Improved=20startup=20UX=20by=20ensur?= =?UTF-8?q?ing=20smooth=20file=20rendering=20=F0=9F=A4=96=20Generated=20wi?= =?UTF-8?q?th=20[Claude=20Code](https://claude.com/claude-code)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 6 +++++- src/renderer.js | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 62d12d8..2b5fb44 100644 --- a/src/main.js +++ b/src/main.js @@ -1668,7 +1668,11 @@ function openFileFromPath(filePath) { currentFile = filePath; const content = fs.readFileSync(filePath, 'utf-8'); if (mainWindow && mainWindow.webContents && rendererReady) { - mainWindow.webContents.send('file-opened', { path: filePath, content }); + // Add a small delay to ensure renderer is fully prepared to display the file + // This prevents timing issues where file opens before UI is ready + setTimeout(() => { + mainWindow.webContents.send('file-opened', { path: filePath, content }); + }, 100); } else { // Store file to open after renderer is ready app.pendingFile = filePath; diff --git a/src/renderer.js b/src/renderer.js index 15d5d46..349acdb 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -1042,8 +1042,11 @@ document.addEventListener('DOMContentLoaded', () => { // Request current theme ipcRenderer.send('get-theme'); - // Signal that renderer is ready for file operations - ipcRenderer.send('renderer-ready'); + // Delay renderer-ready signal to ensure all UI initialization completes + // This prevents files from opening before the interface is fully loaded + setTimeout(() => { + ipcRenderer.send('renderer-ready'); + }, 500); // Set up auto-save interval setInterval(() => {