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:
parent
be71614cf5
commit
56ebe613db
1 changed files with 6 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue