fix: expand switch cases
Some checks failed
Deploy Admin Frontend / build-and-deploy (push) Failing after 4s
Some checks failed
Deploy Admin Frontend / build-and-deploy (push) Failing after 4s
This commit is contained in:
parent
0efc78c656
commit
62b4963bb8
@ -82,14 +82,31 @@ function ChatPage() {
|
||||
try {
|
||||
await streamChat(prevMessages.map(m => ({ role: m.role, content: m.content })), activeId, (event: StreamEvent) => {
|
||||
switch (event.event) {
|
||||
case 'meta': completedConvId = event.conversationId; if (event.conversationId && event.conversationId !== activeId) { setActiveId(event.conversationId); loadConversations() } break
|
||||
case 'tool.started': currentTools.push({ tool: event.tool, preview: event.preview, done: false }); update({ toolCalls: [...currentTools] }) break
|
||||
case 'tool.completed': { const i = currentTools.findIndex((t: any) => t.tool === event.tool && !t.done); if (i >= 0) { currentTools[i] = { ...currentTools[i], done: true, duration: event.duration, error: event.error }; update({ toolCalls: [...currentTools] }) } } break
|
||||
case 'approval.request': setWaitingApproval(true); update({ approval: { command: event.command, description: event.description, choices: event.choices, runId: event.runId } }) break
|
||||
case 'message.delta': currentContent += event.delta || ''; update({ content: currentContent, streaming: true }) break
|
||||
case 'run.completed': if (event.output) currentContent = event.output; update({ content: currentContent, streaming: false }) break
|
||||
case 'done': completedConvId = event.conversationId || completedConvId; update({ streaming: false }) break
|
||||
case 'error': update({ content: 'Error: ' + event.error, streaming: false }) break
|
||||
case 'meta': completedConvId = event.conversationId
|
||||
if (event.conversationId && event.conversationId !== activeId) { setActiveId(event.conversationId); loadConversations() } break
|
||||
case 'tool.started':
|
||||
currentTools.push({ tool: event.tool, preview: event.preview, done: false });
|
||||
update({ toolCalls: [...currentTools] })
|
||||
break
|
||||
case 'tool.completed': {
|
||||
const i = currentTools.findIndex((t: any) => t.tool === event.tool && !t.done); if (i >= 0) { currentTools[i] = { ...currentTools[i], done: true, duration: event.duration, error: event.error }; update({ toolCalls: [...currentTools] })
|
||||
}
|
||||
break
|
||||
case 'approval.request':
|
||||
setWaitingApproval(true); update({ approval: { command: event.command, description: event.description, choices: event.choices, runId: event.runId } })
|
||||
break
|
||||
case 'message.delta':
|
||||
currentContent += event.delta || ''; update({ content: currentContent, streaming: true })
|
||||
break
|
||||
case 'run.completed':
|
||||
if (event.output) currentContent = event.output; update({ content: currentContent, streaming: false })
|
||||
break
|
||||
case 'done':
|
||||
completedConvId = event.conversationId || completedConvId; update({ streaming: false })
|
||||
break
|
||||
case 'error':
|
||||
update({ content: 'Error: ' + event.error, streaming: false })
|
||||
break
|
||||
}
|
||||
}, controller.signal)
|
||||
if (completedConvId) loadConversations()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user