Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/app/state/appNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Loading