From 94c7b9358dab0f9f3be2944ed82fa27b3b8b360c Mon Sep 17 00:00:00 2001 From: Eddy Date: Tue, 21 Apr 2026 15:04:32 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Aktivit=C3=A4ts-Liste=20=E2=80=94=20gr?= =?UTF-8?q?=C3=BCner=20Puls-Punkt=20bleibt=20nicht=20mehr=20h=C3=A4ngen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tool-Start und Tool-End hatten unterschiedliche IDs: tool-start generierte eine zufällige UUID, tool-end suchte nach der Backend-ID → kein Match → alle Tool-Calls blieben ewig auf "running" mit pulsierendem grünen Punkt. Fix: Backend-ID wird jetzt bei tool-start durchgereicht + Fallback auf letzten laufenden Tool-Call wenn ID nicht matcht. Co-Authored-By: Claude Opus 4.6 --- src/lib/stores/app.ts | 40 ++++++++++++++++++++++++++-------------- src/lib/stores/events.ts | 7 ++++--- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/lib/stores/app.ts b/src/lib/stores/app.ts index 8af544f..07f9637 100644 --- a/src/lib/stores/app.ts +++ b/src/lib/stores/app.ts @@ -246,8 +246,8 @@ export function updateAgentStatus(id: string, status: Agent['status']) { ); } -export function addToolCall(agentId: string, tool: string, args: Record): string { - const id = crypto.randomUUID(); +export function addToolCall(agentId: string, tool: string, args: Record, fixedId?: string): string { + const id = fixedId || crypto.randomUUID(); const call: ToolCall = { id, agentId, @@ -270,18 +270,30 @@ export function addToolCall(agentId: string, tool: string, args: Record - calls.map((c) => - c.id === id - ? { - ...c, - status: failed ? 'failed' : 'completed', - completedAt: new Date(), - result - } - : c - ) - ); + toolCalls.update((calls) => { + // Exakte ID-Suche + let found = calls.some((c) => c.id === id); + + if (found) { + return calls.map((c) => + c.id === id + ? { ...c, status: (failed ? 'failed' : 'completed') as ToolCall['status'], completedAt: new Date(), result } + : c + ); + } + + // Fallback: Letzten laufenden Tool-Call abschließen (für Events ohne passende ID) + const lastRunning = [...calls].reverse().find((c) => c.status === 'running'); + if (lastRunning) { + return calls.map((c) => + c.id === lastRunning.id + ? { ...c, status: (failed ? 'failed' : 'completed') as ToolCall['status'], completedAt: new Date(), result } + : c + ); + } + + return calls; + }); } export function clearAll() { diff --git a/src/lib/stores/events.ts b/src/lib/stores/events.ts index 12b955f..225af5c 100644 --- a/src/lib/stores/events.ts +++ b/src/lib/stores/events.ts @@ -226,8 +226,8 @@ export async function initEventListeners(): Promise { // Tool Start listeners.push( await listen('tool-start', async (event) => { - const { tool, input } = event.payload; - console.log('🔧 Tool Start:', tool); + const { id, tool, input } = event.payload; + console.log('🔧 Tool Start:', tool, id); // Inline-Aktivitätsanzeige aktualisieren currentTool.set({ tool: tool || 'unknown', input: input || {} }); @@ -236,7 +236,8 @@ export async function initEventListeners(): Promise { agents.update((ags) => { const activeAgent = ags.find((a) => a.status === 'active'); if (activeAgent) { - addToolCall(activeAgent.id, tool || 'unknown', input || {}); + // Backend-ID durchreichen damit tool-end den Call matchen kann + addToolCall(activeAgent.id, tool || 'unknown', input || {}, id); } return ags; });