Skip to content

Commit 4b35d70

Browse files
committed
refac
1 parent 6512e08 commit 4b35d70

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

src/lib/components/chat/MessageInput.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
export let history;
123123
export let taskIds = null;
124124
125+
$: isActive = (taskIds && taskIds.length > 0) || (history.currentId && history.messages[history.currentId]?.done != true) || generating;
126+
125127
export let prompt = '';
126128
export let files = [];
127129
@@ -1240,9 +1242,9 @@
12401242
/>
12411243

12421244
<!-- Task list display -->
1243-
{#if chatTasks.length > 0}
1245+
{#if isActive && chatTasks.length > 0}
12441246
<div class="mx-1">
1245-
<TaskList tasks={chatTasks} done={!generating} />
1247+
<TaskList tasks={chatTasks} />
12461248
</div>
12471249
{/if}
12481250

@@ -1857,7 +1859,7 @@
18571859
</div>
18581860

18591861
<div class="self-end flex space-x-1 mr-1 shrink-0 gap-[0.5px]">
1860-
{#if (taskIds && taskIds.length > 0) || (history.currentId && history.messages[history.currentId]?.done != true) || generating}
1862+
{#if isActive}
18611863
<div class=" flex items-center">
18621864
<Tooltip content={$i18n.t('Stop')}>
18631865
<button

src/lib/components/chat/Messages/ResponseMessage/TaskList.svelte

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,12 @@
88
const i18n = getContext('i18n');
99
1010
export let tasks: Array<{ id: string; content: string; status: string }> = [];
11-
export let done = false;
1211
1312
let collapsed = false;
1413
1514
$: completedCount = tasks.filter((t) => t.status === 'completed').length;
1615
$: totalCount = tasks.length;
17-
$: inProgressCount = tasks.filter((t) => t.status === 'in_progress').length;
18-
$: pendingCount = tasks.filter((t) => t.status === 'pending').length;
19-
20-
// Hide once all work is effectively done:
21-
// - no active tasks at all, OR
22-
// - message is done and the only remaining active tasks are in_progress (no pending)
23-
$: hasActive =
24-
tasks.some((t) => t.status === 'pending' || t.status === 'in_progress') &&
25-
!(done && pendingCount === 0 && inProgressCount > 0);
16+
$: hasActive = tasks.some((t) => t.status === 'pending' || t.status === 'in_progress');
2617
</script>
2718

2819
{#if tasks.length > 0 && hasActive}

0 commit comments

Comments
 (0)