Skip to content

Commit 176ae7c

Browse files
committed
fix: duplicated task shown in frontend
1 parent 0fd1798 commit 176ae7c

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body:
1212
id: version
1313
attributes:
1414
label: What version of eigent are you using?
15-
placeholder: E.g., 0.0.63
15+
placeholder: E.g., 0.0.64
1616
validations:
1717
required: true
1818

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eigent",
3-
"version": "0.0.63",
3+
"version": "0.0.64",
44
"main": "dist-electron/main/index.js",
55
"description": "Eigent",
66
"author": "Eigent.AI",

src/store/chatStore.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -605,23 +605,29 @@ const chatStore = create<ChatStore>()(
605605

606606
// The following logic is for when the task actually starts executing (running)
607607
if (taskAssigning && taskAssigning[assigneeAgentIndex]) {
608-
// const exist = taskAssigning[assigneeAgentIndex].tasks.find(item => item.id === task_id);
609-
let taskTemp = null
610-
if (task) {
611-
taskTemp = JSON.parse(JSON.stringify(task))
612-
taskTemp.failure_count = 0
613-
taskTemp.status = "running"
614-
taskTemp.toolkits = []
615-
taskTemp.report = ""
608+
// Check if task already exists in the agent's task list
609+
const existingTaskIndex = taskAssigning[assigneeAgentIndex].tasks.findIndex(item => item.id === task_id);
610+
611+
if (existingTaskIndex !== -1) {
612+
// Task already exists, update its status
613+
taskAssigning[assigneeAgentIndex].tasks[existingTaskIndex].status = "running";
614+
} else {
615+
// Task doesn't exist, add it
616+
let taskTemp = null
617+
if (task) {
618+
taskTemp = JSON.parse(JSON.stringify(task))
619+
taskTemp.failure_count = 0
620+
taskTemp.status = "running"
621+
taskTemp.toolkits = []
622+
taskTemp.report = ""
623+
}
624+
taskAssigning[assigneeAgentIndex].tasks.push(taskTemp ?? { id: task_id, content, status: "running", });
616625
}
617-
taskAssigning[assigneeAgentIndex].tasks.push(taskTemp ?? { id: task_id, content, status: "running", });
618-
// if (exist) {
619-
// exist.status = "running";
620-
// } else {
621-
// taskAssigning[assigneeAgentIndex].tasks.push(taskTemp ?? { id: task_id, content, status: "running", });
622-
// }
623626
}
627+
628+
// Only update or add to taskRunning, never duplicate
624629
if (taskRunningIndex === -1) {
630+
// Task not in taskRunning, add it
625631
taskRunning!.push(
626632
task ?? {
627633
id: task_id,
@@ -631,6 +637,7 @@ const chatStore = create<ChatStore>()(
631637
}
632638
);
633639
} else {
640+
// Task already in taskRunning, update it
634641
taskRunning![taskRunningIndex] = {
635642
...taskRunning![taskRunningIndex],
636643
content,

0 commit comments

Comments
 (0)