From e42d1b3d4e74152fb8bd63d832c6cbe15fbec9cb Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 17 Feb 2026 23:44:24 +0000 Subject: [PATCH] Fix reload race: use main-process webContents.reload() instead of renderer window.location.reload() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The renderer-side window.location.reload() inside executeJavaScript schedules a navigation task asynchronously — the IIFE completes and executeJavaScript resolves before the reload actually starts. This causes waitForDidFinishLoad to see isLoadingMainFrame() as false and resolve immediately, allowing the automation to proceed before the page has reloaded with the seeded state. Move the reload back to the main process via window.webContents.reload(), which synchronously puts the frame into a loading state from the main process perspective. --- apps/desktop/src/desktopPerfAutomation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop/src/desktopPerfAutomation.ts b/apps/desktop/src/desktopPerfAutomation.ts index 357ee90e5c..a0d6cca295 100644 --- a/apps/desktop/src/desktopPerfAutomation.ts +++ b/apps/desktop/src/desktopPerfAutomation.ts @@ -433,10 +433,10 @@ async function seedRendererState( (() => { const key = "t3code:renderer-state:v7"; localStorage.setItem(key, JSON.stringify(${JSON.stringify(state)})); - window.location.reload(); })(); `; await window.webContents.executeJavaScript(script, true); + window.webContents.reload(); } async function readRendererPersistedThreadCount(window: BrowserWindow): Promise {