Skip to content

Commit 04ed5f2

Browse files
committed
fixes
1 parent cad8002 commit 04ed5f2

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatContent.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { useCallback, useState } from "react";
88
import type { ThirdwebClient } from "thirdweb";
99
import { useActiveWalletConnectionStatus } from "thirdweb/react";
1010
import type { NebulaContext } from "../../api/chat";
11-
import type { NebulaUserMessage } from "../../api/types";
1211
import type { ExamplePrompt } from "../../data/examplePrompts";
1312
import { NebulaIcon } from "../../icons/NebulaIcon";
1413
import { ChatBar } from "../ChatBar";
1514
import { type CustomChatMessage, CustomChats } from "./CustomChats";
15+
import type { UserMessage, UserMessageContent } from "./CustomChats";
1616

1717
export default function CustomChatContent(props: {
1818
authToken: string | undefined;
@@ -60,13 +60,15 @@ function CustomChatContentLoggedIn(props: {
6060
const connectionStatus = useActiveWalletConnectionStatus();
6161

6262
const handleSendMessage = useCallback(
63-
async (userMessage: NebulaUserMessage) => {
63+
async (userMessage: UserMessage) => {
6464
const abortController = new AbortController();
6565
setUserHasSubmittedMessage(true);
6666
setIsChatStreaming(true);
6767
setEnableAutoScroll(true);
6868

69-
const textMessage = userMessage.content.find((x) => x.type === "text");
69+
const textMessage = userMessage.content.find(
70+
(x: UserMessageContent) => x.type === "text",
71+
);
7072

7173
trackEvent({
7274
category: "siwa",
@@ -79,7 +81,7 @@ function CustomChatContentLoggedIn(props: {
7981
...prev,
8082
{
8183
type: "user",
82-
content: userMessage.content,
84+
content: userMessage.content as UserMessageContent[],
8385
},
8486
// instant loading indicator feedback to user
8587
{
@@ -92,7 +94,7 @@ function CustomChatContentLoggedIn(props: {
9294
// deep clone `userMessage` to avoid mutating the original message, its a pretty small object so JSON.parse is fine
9395
const messageToSend = JSON.parse(
9496
JSON.stringify(userMessage),
95-
) as NebulaUserMessage;
97+
) as UserMessage;
9698

9799
try {
98100
setChatAbortController(abortController);
@@ -256,7 +258,15 @@ function CustomChatContentLoggedIn(props: {
256258
}}
257259
isChatStreaming={isChatStreaming}
258260
prefillMessage={undefined}
259-
sendMessage={handleSendMessage}
261+
sendMessage={(input) => {
262+
// Ensure input is a string
263+
const text = typeof input === "string" ? input : "";
264+
const userMessage: UserMessage = {
265+
type: "user",
266+
content: [{ type: "text", text }],
267+
};
268+
handleSendMessage(userMessage);
269+
}}
260270
className="rounded-none border-x-0 border-b-0"
261271
allowImageUpload={false}
262272
/>
@@ -301,7 +311,7 @@ function LoggedOutStateChatContent() {
301311
}
302312

303313
function EmptyStateChatPageContent(props: {
304-
sendMessage: (message: NebulaUserMessage) => void;
314+
sendMessage: (message: UserMessage) => void;
305315
examplePrompts: { title: string; message: string }[];
306316
}) {
307317
return (
@@ -328,7 +338,7 @@ function EmptyStateChatPageContent(props: {
328338
size="sm"
329339
onClick={() =>
330340
props.sendMessage({
331-
role: "user",
341+
type: "user",
332342
content: [
333343
{
334344
type: "text",

apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChats.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import type { ThirdwebClient } from "thirdweb";
1212
import { Reasoning } from "../Reasoning/Reasoning";
1313

1414
// Define local types
15-
type UserMessageContent = { type: "text"; text: string };
16-
type UserMessage = {
15+
export type UserMessageContent = { type: "text"; text: string };
16+
export type UserMessage = {
1717
type: "user";
1818
content: UserMessageContent[];
1919
};
2020

21-
type CustomChatMessage =
21+
export type CustomChatMessage =
2222
| UserMessage
2323
| {
2424
text: string;

0 commit comments

Comments
 (0)