diff --git a/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts b/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts index 56976c74741..e7dba4b98d2 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts +++ b/apps/dashboard/src/app/nebula-app/(app)/api/chat.ts @@ -152,6 +152,24 @@ export async function promptNebula(params: { break; } + case "error": { + const data = JSON.parse(event.data) as { + code: number; + error: { + message: string; + }; + }; + + params.handleStream({ + event: "error", + data: { + code: data.code, + errorMessage: data.error.message, + }, + }); + break; + } + case "init": { const data = JSON.parse(event.data); params.handleStream({ @@ -242,6 +260,13 @@ type ChatStreamedResponse = chain_ids: number[]; networks: NebulaContext["networks"]; }; + } + | { + event: "error"; + data: { + code: number; + errorMessage: string; + }; }; type ChatStreamedEvent = @@ -269,4 +294,8 @@ type ChatStreamedEvent = | { event: "context"; data: string; + } + | { + event: "error"; + data: string; }; diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx index bdf6a718e89..e0d28857a65 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx @@ -578,6 +578,20 @@ export async function handleNebulaPrompt(params: { }); return; } + + case "error": { + hasReceivedResponse = true; + setMessages((prev) => { + return [ + ...prev, + { + text: res.data.errorMessage, + type: "error", + }, + ]; + }); + return; + } } }, context: contextFilters,