diff --git a/src/components/TopBar/index.tsx b/src/components/TopBar/index.tsx index 907c56b0..e190cbc2 100644 --- a/src/components/TopBar/index.tsx +++ b/src/components/TopBar/index.tsx @@ -53,6 +53,7 @@ function HeaderWin() { const exportLog = async () => { try { const response = await window.electronAPI.exportLog(); + if (!response.success) { alert("Export cancelled:" + response.error); return; @@ -67,6 +68,20 @@ function HeaderWin() { } }; + // create new project handler reused by plus icon and label + const createNewProject = () => { + const taskId = Object.keys(chatStore.tasks).find((taskId) => { + return chatStore.tasks[taskId].messages.length === 0; + }); + if (taskId) { + chatStore.setActiveTaskId(taskId); + navigate("/"); + return; + } + chatStore.create(); + navigate("/"); + }; + const activeTaskTitle = useMemo(() => { if ( chatStore.activeTaskId && @@ -117,27 +132,24 @@ function HeaderWin() { variant="ghost" size="icon" className="mr-2 no-drag" - onClick={() => { - const taskId = Object.keys(chatStore.tasks).find((taskId) => { - console.log(chatStore.tasks[taskId].messages.length); - return chatStore.tasks[taskId].messages.length === 0; - }); - if (taskId) { - chatStore.setActiveTaskId(taskId); - navigate(`/`); - return; - } - chatStore.create(); - navigate("/"); - }} + onClick={createNewProject} > {location.pathname !== "/history" && ( <> -
- {activeTaskTitle} -
+ {activeTaskTitle === "New Project" ? ( + + ) : ( +
{activeTaskTitle}
+ )} )}