bug fix wendong

This commit is contained in:
Wendong-Fan 2025-11-20 14:01:34 +08:00
parent 9e43a59445
commit 416d7f8acf
3 changed files with 8 additions and 9 deletions

View file

@ -148,14 +148,13 @@ function HeaderWin() {
//TODO: Mark ChatStore details as completed
const handleEndProject = async () => {
const taskId = chatStore.activeTaskId;
const currentProjectId = projectStore.activeProjectId;
const projectId = projectStore.activeProjectId;
if (!taskId) {
toast.error(t("layout.no-active-project-to-end"));
return;
}
const projectId = projectStore.activeProjectId;
const historyId = projectId ? projectStore.getHistoryId(projectId) : null;
try {
@ -170,7 +169,7 @@ function HeaderWin() {
// Stop Workforce
try {
await fetchDelete(`/chat/${currentProjectId}`);
await fetchDelete(`/chat/${projectId}`);
} catch (error) {
console.log("Task may not exist on backend:", error);
}

View file

@ -24,7 +24,7 @@ const useChatStoreAdapter = ():{
}
// Subscribe to store changes
const unsubscribe = activeChatStore.subscribe((state) => {
const unsubscribe = activeChatStore.subscribe((state: ChatStore) => {
setChatState(state);
});
// Set initial state

View file

@ -105,6 +105,7 @@ export interface ChatStore {
export type VanillaChatStore = {
getState: () => ChatStore;
subscribe: (listener: (state: ChatStore) => void) => () => void;
};
@ -1085,7 +1086,7 @@ const chatStore = (initial?: Partial<ChatStore>) => createStore<ChatStore>()(
return toolkit.toolkitName === agentMessages.data.toolkit_name && toolkit.toolkitMethods === agentMessages.data.method_name && toolkit.toolkitStatus === 'running'
})
if (task.toolkits && index !== -1) {
if (task.toolkits && index !== -1 && index !== undefined) {
task.toolkits[index].message += '\n' + message.data.message as string
task.toolkits[index].toolkitStatus = "completed"
}
@ -1223,10 +1224,9 @@ const chatStore = (initial?: Partial<ChatStore>) => createStore<ChatStore>()(
// Complete the current task with error status
setStatus(currentTaskId, 'finished');
setIsPending(currentTaskId, false);
setHasWaitComfirm(newTaskId, true);
// Add error message to the new clean task
addMessages(newTaskId, {
// Add error message to the current task
addMessages(currentTaskId, {
id: generateUniqueId(),
role: "agent",
content: `❌ **Error**: ${errorMessage}`,