Fix reload race: use main-process webContents.reload() instead of renderer window.location.reload()

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.
This commit is contained in:
Cursor Agent committed 2026-02-17 23:44:24 +00:00
1 parent 4df79f1c40
commit e42d1b3d4e
1 file changed
+1 -1
+1 -1
View File
@@ -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<number> {