Skip to content

Commit f0ba5fc

Browse files
Fix: show toast when project creation fails in desktop Electron mode
In desktop Electron mode, shouldBrowseForProjectImmediately is always true, making shouldShowProjectPathEntry always false. The addProjectError message was only rendered inside the shouldShowProjectPathEntry conditional block, so errors from addProjectFromPath were stored in state but never displayed. Use toastManager to show a visible error notification in the desktop path, while preserving the existing inline error display for the non-desktop path. Co-authored-by: Julius Marminge <[email protected]>
1 parent 56023cc commit f0ba5fc

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

apps/web/src/components/Sidebar.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,29 @@ export default function Sidebar() {
531531
});
532532
await handleNewThread(projectId).catch(() => undefined);
533533
} catch (error) {
534+
const message =
535+
error instanceof Error ? error.message : "An error occurred while adding the project.";
534536
setIsAddingProject(false);
535-
setAddProjectError(
536-
error instanceof Error ? error.message : "An error occurred while adding the project.",
537-
);
537+
if (shouldBrowseForProjectImmediately) {
538+
toastManager.add({
539+
type: "error",
540+
title: "Could not add project",
541+
description: message,
542+
});
543+
} else {
544+
setAddProjectError(message);
545+
}
538546
return;
539547
}
540548
finishAddingProject();
541549
},
542-
[focusMostRecentThreadForProject, handleNewThread, isAddingProject, projects],
550+
[
551+
focusMostRecentThreadForProject,
552+
handleNewThread,
553+
isAddingProject,
554+
projects,
555+
shouldBrowseForProjectImmediately,
556+
],
543557
);
544558

545559
const handleAddProject = () => {

0 commit comments

Comments
 (0)