From 67ad02f5502872be7a9ba42fea1ea397591897e4 Mon Sep 17 00:00:00 2001 From: sw3205933776 <3205933776@qq.com> Date: Sat, 11 Oct 2025 15:52:32 +0800 Subject: [PATCH 1/2] fix: prevent app freeze and white screen after clicking Task Hub --- src/components/HistorySidebar/index.tsx | 217 +++++++++++++----------- src/pages/History.tsx | 12 +- 2 files changed, 123 insertions(+), 106 deletions(-) diff --git a/src/components/HistorySidebar/index.tsx b/src/components/HistorySidebar/index.tsx index 141b55256..874f089c7 100644 --- a/src/components/HistorySidebar/index.tsx +++ b/src/components/HistorySidebar/index.tsx @@ -299,7 +299,8 @@ export default function HistorySidebar() { />
- {task?.messages[0]?.content || t("task-hub.new-project")} + {task?.messages?.[0]?.content || + t("task-hub.new-project")}
- {task?.messages[0]?.content || + {task?.messages?.[0]?.content || t("task-hub.new-project")}

- {task?.messages[0]?.content || + {task?.messages?.[0]?.content || t("task-hub.new-project")}

@@ -449,7 +450,7 @@ export default function HistorySidebar() {
{historyTasks .filter((task) => - task.question + task?.question ?.toLowerCase() .includes(searchValue.toLowerCase()) ) @@ -457,11 +458,14 @@ export default function HistorySidebar() { return (
- handleSetActive(task.task_id, task.question) + handleSetActive( + task?.task_id, + task?.question + ) } key={task.task_id} className={`${ - chatStore.activeTaskId === task.task_id + chatStore.activeTaskId === task?.task_id ? "!bg-white-100%" : "" } max-w-full relative cursor-pointer transition-all duration-300 bg-white-30% hover:bg-white-100% rounded-3xl w-[316px] h-[180px] p-6 shadow-history-item`} @@ -475,16 +479,16 @@ export default function HistorySidebar() { alt="folder-icon" /> - # Token {task.tokens || 0} + # Token {task?.tokens || 0}
- {task?.question.split("|")[0] || + {task?.question?.split("|")?.[0] || t("task-hub.new-project")}
- {task?.question.split("|")[1] || + {task?.question?.split("|")?.[1] || t("task-hub.new-project")}
@@ -494,98 +498,111 @@ export default function HistorySidebar() { ) : ( // List
- {historyTasks.map((task) => { - return ( -
{ - handleSetActive(task.task_id, task.question); - }} - key={task.task_id} - className={`${ - chatStore.activeTaskId === task.task_id - ? "!bg-white-100%" - : "" - } max-w-full relative cursor-pointer transition-all duration-300 bg-white-30% hover:bg-white-100% rounded-2xl flex justify-between items-center gap-md w-full p-3 h-14 shadow-history-item border border-solid border-border-disabled`} - > - folder-icon - -
- - - - {" "} - {task?.question.split("|")[0] || t("task-hub.new-project")} - - - -
- {" "} - {task?.question.split("|")[0] || t("task-hub.new-project")} -
-
-
-
- { + return ( +
{ + handleSetActive( + task?.task_id, + task?.question + ); + }} + key={task.task_id} + className={`${ + chatStore.activeTaskId === task?.task_id + ? "!bg-white-100%" + : "" + } max-w-full relative cursor-pointer transition-all duration-300 bg-white-30% hover:bg-white-100% rounded-2xl flex justify-between items-center gap-md w-full p-3 h-14 shadow-history-item border border-solid border-border-disabled`} > - # Token {task.tokens || 0} - - - - - - - -
- - - - - - - -
-
-
-
- ); - })} -
+ folder-icon + +
+ + + + {" "} + {(task?.question && + task?.question?.split("|")?.[0]) || + t("task-hub.new-project")} + + + +
+ {" "} + {task?.question?.split("|")?.[0] || + t("task-hub.new-project")} +
+
+
+
+ + # Token {task?.tokens || 0} + + + + + + + +
+ + + + + + + +
+
+
+
+ ); + })} +
)} )} diff --git a/src/pages/History.tsx b/src/pages/History.tsx index c0e8548e7..e2ed0271e 100644 --- a/src/pages/History.tsx +++ b/src/pages/History.tsx @@ -571,7 +571,7 @@ export default function Home() { variant="primary" className="text-xs leading-17 font-medium text-nowrap" > - # Token {task.tokens || 0} + # Token {task?.tokens || 0} @@ -609,7 +609,7 @@ export default function Home() { {" "} - {task?.question.split("|")[0] || t("task-hub.new-project")} + {task?.question?.split("|")?.[0] || t("task-hub.new-project")}
{" "} - {task?.question.split("|")[0] || t("task-hub.new-project")} + {task?.question?.split("|")?.[0] || t("task-hub.new-project")}
@@ -627,7 +627,7 @@ export default function Home() { variant="primary" className="text-xs leading-17 font-medium text-nowrap" > - # Token {task.tokens || 0} + # Token {task?.tokens || 0} @@ -649,7 +649,7 @@ export default function Home() { className="w-full" onClick={(e) => { e.stopPropagation(); - handleShare(task.task_id); + handleShare(task?.task_id); }} > @@ -664,7 +664,7 @@ export default function Home() { className="w-full" onClick={(e) => { e.stopPropagation(); - handleDelete(task.id); + handleDelete(task?.id); }} > Date: Mon, 20 Oct 2025 05:23:23 +0800 Subject: [PATCH 2/2] enhance: prevent app freeze and white screen after clicking Task Hub PR491 --- src/components/HistorySidebar/index.tsx | 3 +-- src/pages/History.tsx | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/HistorySidebar/index.tsx b/src/components/HistorySidebar/index.tsx index f5bb5e944..059f1456b 100644 --- a/src/components/HistorySidebar/index.tsx +++ b/src/components/HistorySidebar/index.tsx @@ -536,8 +536,7 @@ export default function HistorySidebar() { {" "} - {(task?.question && - task?.question?.split("|")?.[0]) || + {task?.question?.split("|")?.[0] || t("task-hub.new-project")} diff --git a/src/pages/History.tsx b/src/pages/History.tsx index efcbe6dae..5b6d47bab 100644 --- a/src/pages/History.tsx +++ b/src/pages/History.tsx @@ -565,10 +565,10 @@ export default function Home() { {historyTasks.map((task) => { return (
handleSetActive(task.task_id, task.question)} + onClick={() => handleSetActive(task?.task_id, task?.question)} key={task.task_id} className={`${ - chatStore.activeTaskId === task.task_id + chatStore.activeTaskId === task?.task_id ? "!bg-white-100%" : "" } relative cursor-pointer transition-all duration-300 bg-white-30% hover:bg-white-100% rounded-3xl flex justify-between items-center flex-wrap gap-md flex-initial w-[calc(33%-48px)] min-w-[300px] max-w-[500px] h-[180px] p-6 shadow-history-item border border-solid border-border-disabled`} @@ -607,11 +607,11 @@ export default function Home() { return (
{ - handleSetActive(task.task_id, task.question); + handleSetActive(task?.task_id, task?.question); }} key={task.task_id} className={`${ - chatStore.activeTaskId === task.task_id + chatStore.activeTaskId === task?.task_id ? "!bg-white-100%" : "" } max-w-full relative cursor-pointer transition-all duration-300 bg-white-30% hover:bg-white-100% rounded-2xl flex justify-between items-center gap-md w-full p-3 h-14 shadow-history-item border border-solid border-border-disabled`} @@ -625,7 +625,7 @@ export default function Home() { {" "} - {task?.question.split("|")[0] || + {task?.question?.split("|")?.[0] || t("task-hub.new-project")} @@ -635,7 +635,7 @@ export default function Home() { >
{" "} - {task?.question.split("|")[0] || + {task?.question?.split("|")?.[0] || t("task-hub.new-project")}