Skip to content

Remove SIWA feedback buttons from nebula #7142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ export function ChatPageContent(props: {

{messages.length > 0 && (
<Chats
teamId={undefined}
messages={messages}
isChatStreaming={isChatStreaming}
authToken={props.authToken}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ function Variant(props: {
}) {
return (
<Chats
teamId={undefined}
enableAutoScroll={false}
setEnableAutoScroll={() => {}}
client={storybookThirdwebClient}
Expand Down
122 changes: 2 additions & 120 deletions apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { ScrollShadow } from "@/components/ui/ScrollShadow/ScrollShadow";
import { cn } from "@/lib/utils";
import { MarkdownRenderer } from "components/contract-components/published-contract/markdown-renderer";
import { AlertCircleIcon, ThumbsDownIcon, ThumbsUpIcon } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { AlertCircleIcon } from "lucide-react";
import { useEffect, useRef } from "react";
import type { ThirdwebClient } from "thirdweb";
import { Button } from "../../../../@/components/ui/button";
import { useTrack } from "../../../../hooks/analytics/useTrack";
import type { NebulaSwapData } from "../api/chat";
import type { NebulaUserMessage, NebulaUserMessageContent } from "../api/types";
import { NebulaIcon } from "../icons/NebulaIcon";
Expand Down Expand Up @@ -74,7 +72,6 @@ export function Chats(props: {
enableAutoScroll: boolean;
useSmallText?: boolean;
sendMessage: (message: NebulaUserMessage) => void;
teamId: string | undefined;
}) {
const { messages, setEnableAutoScroll, enableAutoScroll } = props;
const scrollAnchorRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -156,7 +153,6 @@ export function Chats(props: {
nextMessage={props.messages[index + 1]}
authToken={props.authToken}
sessionId={props.sessionId}
teamId={props.teamId}
/>
</div>
);
Expand All @@ -176,7 +172,6 @@ function RenderMessage(props: {
sendMessage: (message: NebulaUserMessage) => void;
nextMessage: ChatMessage | undefined;
authToken: string;
teamId: string | undefined;
sessionId: string | undefined;
}) {
const { message } = props;
Expand Down Expand Up @@ -229,41 +224,6 @@ function RenderMessage(props: {
);
}

// Feedback for assistant messages
if (props.message.type === "assistant") {
return (
<div className="flex flex-col gap-2">
<div className="flex gap-3">
{/* Left Icon */}
<div className="-translate-y-[2px] relative shrink-0">
<div className="flex size-9 items-center justify-center rounded-full border bg-card">
<NebulaIcon className="size-5 text-muted-foreground" />
</div>
</div>
{/* Right Message */}
<div className="min-w-0 grow">
<ScrollShadow className="rounded-lg">
<RenderResponse
message={message}
isMessagePending={props.isMessagePending}
client={props.client}
sendMessage={props.sendMessage}
nextMessage={props.nextMessage}
sessionId={props.sessionId}
authToken={props.authToken}
/>
</ScrollShadow>
<FeedbackButtons
sessionId={props.sessionId}
authToken={props.authToken}
teamId={props.teamId}
/>
</div>
</div>
</div>
);
}

return (
<div className="flex gap-3">
{/* Left Icon */}
Expand Down Expand Up @@ -462,81 +422,3 @@ function StyledMarkdownRenderer(props: {
/>
);
}

function FeedbackButtons({
sessionId,
authToken,
teamId,
}: {
sessionId: string | undefined;
authToken: string;
teamId: string | undefined;
}) {
const [, setFeedback] = useState<1 | -1 | null>(null);
const [loading, setLoading] = useState(false);
const [thankYou, setThankYou] = useState(false);
const trackEvent = useTrack();

async function sendFeedback(rating: 1 | -1) {
setLoading(true);
try {
trackEvent({
category: "siwa",
action: "submit-feedback",
rating: rating === 1 ? "good" : "bad",
sessionId,
teamId,
});
const apiUrl = process.env.NEXT_PUBLIC_SIWA_URL;
await fetch(`${apiUrl}/v1/chat/feedback`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
...(teamId ? { "x-team-id": teamId } : {}),
},
body: JSON.stringify({
conversationId: sessionId,
feedbackRating: rating,
}),
});
setFeedback(rating);
setThankYou(true);
} catch {
// TODO handle error
} finally {
setLoading(false);
}
}

if (thankYou) {
return (
<div className="mt-2 text-muted-foreground text-xs">
Thank you for your feedback!
</div>
);
}

return (
<div className="mt-2 flex gap-2">
<Button
className="rounded-full border p-2 hover:bg-muted-foreground/10"
variant="ghost"
onClick={() => sendFeedback(-1)}
disabled={loading}
aria-label="Thumbs down"
>
<ThumbsDownIcon className="size-4 text-red-500" />
</Button>
<Button
className="rounded-full border p-2 hover:bg-muted-foreground/10"
variant="ghost"
onClick={() => sendFeedback(1)}
disabled={loading}
aria-label="Thumbs up"
>
<ThumbsUpIcon className="size-4 text-green-500" />
</Button>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ function CustomChatContentLoggedIn(props: {
/>
) : (
<Chats
teamId={props.teamId}
messages={messages}
isChatStreaming={isChatStreaming}
authToken={props.authToken}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ function FloatingChatContentLoggedIn(props: {
/>
) : (
<Chats
teamId={undefined}
messages={messages}
isChatStreaming={isChatStreaming}
authToken={props.authToken}
Expand Down
Loading