Skip to content

Commit d3cb662

Browse files
authored
Feature/display asst messages (#331)
* Display asst messages in chat * Use array of array for child_ids in Tasks
1 parent 6a71d95 commit d3cb662

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

web/src/components/common/Tasks.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const TreeNode: React.FC<TreeNodeProps> = ({
5959
if (!Array.isArray(task.child_ids)) {
6060
return [];
6161
}
62-
return allTasks.filter(t => task.child_ids.includes(t.id));
62+
return allTasks.filter(t => task.child_ids.flat().includes(t.id));
6363
}, [task.child_ids, allTasks]);
6464

6565
const hasChildren = childTasks.length > 0;
@@ -305,10 +305,10 @@ export const Tasks: React.FC = () => {
305305
const rootTasks = useMemo(() => {
306306
if (!allTasks || allTasks.length === 0) return [];
307307
const taskMap = new Map(allTasks.map(t => [t.id, t]));
308-
const childIds = new Set<string>();
308+
const childIds = new Set<number>();
309309
allTasks.forEach(task => {
310310
if (Array.isArray(task.child_ids)) {
311-
task.child_ids.forEach(cid => childIds.add(cid));
311+
task.child_ids.flat().forEach(cid => childIds.add(cid));
312312
}
313313
});
314314
return allTasks.filter(task =>

web/src/components/common/TasksLite.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ const flattenTasks = (tasks: TasksInfo, expandedRootTasks: Set<string> = new Set
188188

189189
if (shouldShowChildren && Array.isArray(task.child_ids) && task.child_ids.length > 0) {
190190
const childTasks = task.child_ids
191+
.flat()
191192
.map(childId => taskMap.get(childId))
192193
.filter((child): child is Task => child !== undefined);
193194

@@ -201,10 +202,10 @@ const flattenTasks = (tasks: TasksInfo, expandedRootTasks: Set<string> = new Set
201202
};
202203

203204
// Find root tasks (tasks without parents or whose parents don't exist)
204-
const childIds = new Set<string>();
205+
const childIds = new Set<number>();
205206
tasks.forEach(task => {
206207
if (Array.isArray(task.child_ids)) {
207-
task.child_ids.forEach(cid => childIds.add(cid));
208+
task.child_ids.flat().forEach(cid => childIds.add(cid));
208209
}
209210
});
210211

@@ -240,10 +241,10 @@ export const TasksLite: React.FC = () => {
240241
const rootTasks = useMemo(() => {
241242
if (!allTasks || allTasks.length === 0) return [];
242243
const taskMap = new Map(allTasks.map(t => [t.id, t]));
243-
const childIds = new Set<string>();
244+
const childIds = new Set<number>();
244245
allTasks.forEach(task => {
245246
if (Array.isArray(task.child_ids)) {
246-
task.child_ids.forEach(cid => childIds.add(cid));
247+
task.child_ids.flat().forEach(cid => childIds.add(cid));
247248
}
248249
});
249250
return allTasks.filter(task =>

web/src/state/chat/reducer.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export interface Task {
135135
parent_id: number | null;
136136
run_id: string;
137137
debug: any;
138-
child_ids: number[];
138+
child_ids: Array<number[]>;
139139
result: any; // Key field for completion status
140140
}
141141

@@ -238,6 +238,17 @@ const taskResultToContent = (task: Task): ActionChatMessageContent => {
238238
? task.result
239239
: JSON.stringify(task.result)
240240

241+
if (task.agent == "TalkToUser") {
242+
return {
243+
type: 'DEFAULT',
244+
text: content,
245+
images: [],
246+
renderInfo: {
247+
text: content,
248+
code: undefined,
249+
}
250+
}
251+
}
241252
return {
242253
type: 'BLANK',
243254
content,

0 commit comments

Comments
 (0)