fix: Aktivitäts-Liste — grüner Puls-Punkt bleibt nicht mehr hängen
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 <noreply@anthropic.com>
This commit is contained in:
parent
50c92072f5
commit
94c7b9358d
2 changed files with 30 additions and 17 deletions
|
|
@ -246,8 +246,8 @@ export function updateAgentStatus(id: string, status: Agent['status']) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addToolCall(agentId: string, tool: string, args: Record<string, unknown>): string {
|
export function addToolCall(agentId: string, tool: string, args: Record<string, unknown>, fixedId?: string): string {
|
||||||
const id = crypto.randomUUID();
|
const id = fixedId || crypto.randomUUID();
|
||||||
const call: ToolCall = {
|
const call: ToolCall = {
|
||||||
id,
|
id,
|
||||||
agentId,
|
agentId,
|
||||||
|
|
@ -270,18 +270,30 @@ export function addToolCall(agentId: string, tool: string, args: Record<string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function completeToolCall(id: string, result: unknown, failed = false) {
|
export function completeToolCall(id: string, result: unknown, failed = false) {
|
||||||
toolCalls.update((calls) =>
|
toolCalls.update((calls) => {
|
||||||
calls.map((c) =>
|
// Exakte ID-Suche
|
||||||
|
let found = calls.some((c) => c.id === id);
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
return calls.map((c) =>
|
||||||
c.id === id
|
c.id === id
|
||||||
? {
|
? { ...c, status: (failed ? 'failed' : 'completed') as ToolCall['status'], completedAt: new Date(), result }
|
||||||
...c,
|
|
||||||
status: failed ? 'failed' : 'completed',
|
|
||||||
completedAt: new Date(),
|
|
||||||
result
|
|
||||||
}
|
|
||||||
: c
|
: 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() {
|
export function clearAll() {
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,8 @@ export async function initEventListeners(): Promise<void> {
|
||||||
// Tool Start
|
// Tool Start
|
||||||
listeners.push(
|
listeners.push(
|
||||||
await listen<ToolEvent>('tool-start', async (event) => {
|
await listen<ToolEvent>('tool-start', async (event) => {
|
||||||
const { tool, input } = event.payload;
|
const { id, tool, input } = event.payload;
|
||||||
console.log('🔧 Tool Start:', tool);
|
console.log('🔧 Tool Start:', tool, id);
|
||||||
|
|
||||||
// Inline-Aktivitätsanzeige aktualisieren
|
// Inline-Aktivitätsanzeige aktualisieren
|
||||||
currentTool.set({ tool: tool || 'unknown', input: input || {} });
|
currentTool.set({ tool: tool || 'unknown', input: input || {} });
|
||||||
|
|
@ -236,7 +236,8 @@ export async function initEventListeners(): Promise<void> {
|
||||||
agents.update((ags) => {
|
agents.update((ags) => {
|
||||||
const activeAgent = ags.find((a) => a.status === 'active');
|
const activeAgent = ags.find((a) => a.status === 'active');
|
||||||
if (activeAgent) {
|
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;
|
return ags;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue