From 54bad910c59d00f4308a0af859fa379a670ca35a Mon Sep 17 00:00:00 2001 From: SylvainDruaux Date: Tue, 20 Oct 2026 22:43:17 +0200 Subject: [PATCH] fix(desktop): start the project watch before panels read project files Problem: the main process allows file access only inside the open project, which it records when the project watch starts. The watch started after the scan and the dependency check, so the column guide read its settings first and showed "Refusing to touch a file outside the open project". Solution: start the watch before the first await, so the main process knows the open project before any panel reads its files. --- src/app/state/appNavigation.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app/state/appNavigation.ts b/src/app/state/appNavigation.ts index 3e982f39..d3882810 100644 --- a/src/app/state/appNavigation.ts +++ b/src/app/state/appNavigation.ts @@ -89,6 +89,18 @@ export function useSelectPage( // last project isn't a choice the user made about this one. setDevice('desktop'); void addRecentProject(projectPath).catch(() => {}); + // Starting the watch records the open project in the main process, which + // allows file access only inside it. It goes out before the first await, so + // it reaches main before any panel that mounts with the project reads a file. + void watchProject(projectPath) + .then((started) => { + if (!started) { + showToast('Couldn’t watch project files. External edits may need a refresh.', 'error'); + } + }) + .catch((error: unknown) => { + showToast(`Couldn’t watch project files: ${cleanError(error)}`, 'error'); + }); const result = await rescan(projectPath); const hasDeps = await projectHasNodeModules(projectPath); @@ -102,15 +114,6 @@ export function useSelectPage( } // startPreview reports its own failure in the preview area. void startPreview(projectPath); - void watchProject(projectPath) - .then((started) => { - if (!started) { - showToast('Couldn’t watch project files. External edits may need a refresh.', 'error'); - } - }) - .catch((error: unknown) => { - showToast(`Couldn’t watch project files: ${cleanError(error)}`, 'error'); - }); const first = result.pages.find((page) => page.name === 'index.astro') || result.pages[0] || undefined;