From d1ca9af2f43f8c5a5f56bc8c87da7cccd5a97e16 Mon Sep 17 00:00:00 2001 From: MananTank Date: Fri, 23 May 2025 16:02:33 +0000 Subject: [PATCH] Remove SIWA feedback buttons from nebula (#7142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR primarily focuses on refactoring the `Chats` component and its related functionalities. It removes unused code and simplifies the props being passed, particularly the `teamId`. Additionally, it eliminates the feedback buttons and associated functionality. ### Detailed summary - Removed `teamId` prop from various instances of the `Chats` component. - Deleted the `FeedbackButtons` component and its related logic. - Simplified imports in the `Chats` component by removing unused imports. - Cleaned up the `RenderMessage` function by omitting `teamId` from props. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit - **New Features** - None. - **Bug Fixes** - None. - **Refactor** - Removed the feedback feature, including thumbs up/down buttons and related tracking, from chat components. - Simplified chat components by removing the unused or redundant team selection prop. - **Chores** - Cleaned up code by deleting unnecessary feedback-related imports and props. --- .../(app)/components/ChatPageContent.tsx | 1 - .../(app)/components/Chats.stories.tsx | 1 - .../app/nebula-app/(app)/components/Chats.tsx | 122 +----------------- .../CustomChat/CustomChatContent.tsx | 1 - .../FloatingChat/FloatingChatContent.tsx | 1 - 5 files changed, 2 insertions(+), 124 deletions(-) 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 6f57961bd79..0673aa4fa8c 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx @@ -339,7 +339,6 @@ export function ChatPageContent(props: { {messages.length > 0 && ( {}} client={storybookThirdwebClient} diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx index 76ac13d49f9..484c0e0c0d7 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx @@ -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"; @@ -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(null); @@ -156,7 +153,6 @@ export function Chats(props: { nextMessage={props.messages[index + 1]} authToken={props.authToken} sessionId={props.sessionId} - teamId={props.teamId} /> ); @@ -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; @@ -229,41 +224,6 @@ function RenderMessage(props: { ); } - // Feedback for assistant messages - if (props.message.type === "assistant") { - return ( -
-
- {/* Left Icon */} -
-
- -
-
- {/* Right Message */} -
- - - - -
-
-
- ); - } - return (
{/* Left Icon */} @@ -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 ( -
- Thank you for your feedback! -
- ); - } - - return ( -
- - -
- ); -} diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatContent.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatContent.tsx index 6eb1b3767a0..2547afc0db0 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatContent.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatContent.tsx @@ -158,7 +158,6 @@ function CustomChatContentLoggedIn(props: { /> ) : ( ) : (