mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-02 01:45:52 +02:00
fix(hooks): handle agent_error events in useGatewayChat
Desktop path already forwards agent_error to chat.setError() via use-local-chat.ts, but the Web/Gateway path was missing this handling. Add agent_error interception in the StreamAction branch so Web clients render LLM errors the same way Desktop does. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,6 +50,12 @@ export function useGatewayChat({ client, hubId, agentId }: UseGatewayChatOptions
|
||||
client.onMessage((msg) => {
|
||||
if (msg.action === StreamAction) {
|
||||
const payload = msg.payload as StreamPayload;
|
||||
if (payload.event.type === "agent_error") {
|
||||
const errorMsg = (payload.event as { error?: string }).error ?? "Unknown error";
|
||||
chat.setError({ code: "AGENT_ERROR", message: errorMsg });
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
chat.handleStream(payload);
|
||||
if (payload.event.type === "message_start") setIsLoading(true);
|
||||
if (payload.event.type === "message_end") setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user