Skip to content

Commit d1ca9af

Browse files
committed
Remove SIWA feedback buttons from nebula (#7142)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## 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}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 317211a commit d1ca9af

File tree

5 files changed

+2
-124
lines changed

5 files changed

+2
-124
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ export function ChatPageContent(props: {
339339

340340
{messages.length > 0 && (
341341
<Chats
342-
teamId={undefined}
343342
messages={messages}
344343
isChatStreaming={isChatStreaming}
345344
authToken={props.authToken}

apps/dashboard/src/app/nebula-app/(app)/components/Chats.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ function Variant(props: {
227227
}) {
228228
return (
229229
<Chats
230-
teamId={undefined}
231230
enableAutoScroll={false}
232231
setEnableAutoScroll={() => {}}
233232
client={storybookThirdwebClient}

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

Lines changed: 2 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { ScrollShadow } from "@/components/ui/ScrollShadow/ScrollShadow";
22
import { cn } from "@/lib/utils";
33
import { MarkdownRenderer } from "components/contract-components/published-contract/markdown-renderer";
4-
import { AlertCircleIcon, ThumbsDownIcon, ThumbsUpIcon } from "lucide-react";
5-
import { useEffect, useRef, useState } from "react";
4+
import { AlertCircleIcon } from "lucide-react";
5+
import { useEffect, useRef } from "react";
66
import type { ThirdwebClient } from "thirdweb";
7-
import { Button } from "../../../../@/components/ui/button";
8-
import { useTrack } from "../../../../hooks/analytics/useTrack";
97
import type { NebulaSwapData } from "../api/chat";
108
import type { NebulaUserMessage, NebulaUserMessageContent } from "../api/types";
119
import { NebulaIcon } from "../icons/NebulaIcon";
@@ -74,7 +72,6 @@ export function Chats(props: {
7472
enableAutoScroll: boolean;
7573
useSmallText?: boolean;
7674
sendMessage: (message: NebulaUserMessage) => void;
77-
teamId: string | undefined;
7875
}) {
7976
const { messages, setEnableAutoScroll, enableAutoScroll } = props;
8077
const scrollAnchorRef = useRef<HTMLDivElement>(null);
@@ -156,7 +153,6 @@ export function Chats(props: {
156153
nextMessage={props.messages[index + 1]}
157154
authToken={props.authToken}
158155
sessionId={props.sessionId}
159-
teamId={props.teamId}
160156
/>
161157
</div>
162158
);
@@ -176,7 +172,6 @@ function RenderMessage(props: {
176172
sendMessage: (message: NebulaUserMessage) => void;
177173
nextMessage: ChatMessage | undefined;
178174
authToken: string;
179-
teamId: string | undefined;
180175
sessionId: string | undefined;
181176
}) {
182177
const { message } = props;
@@ -229,41 +224,6 @@ function RenderMessage(props: {
229224
);
230225
}
231226

232-
// Feedback for assistant messages
233-
if (props.message.type === "assistant") {
234-
return (
235-
<div className="flex flex-col gap-2">
236-
<div className="flex gap-3">
237-
{/* Left Icon */}
238-
<div className="-translate-y-[2px] relative shrink-0">
239-
<div className="flex size-9 items-center justify-center rounded-full border bg-card">
240-
<NebulaIcon className="size-5 text-muted-foreground" />
241-
</div>
242-
</div>
243-
{/* Right Message */}
244-
<div className="min-w-0 grow">
245-
<ScrollShadow className="rounded-lg">
246-
<RenderResponse
247-
message={message}
248-
isMessagePending={props.isMessagePending}
249-
client={props.client}
250-
sendMessage={props.sendMessage}
251-
nextMessage={props.nextMessage}
252-
sessionId={props.sessionId}
253-
authToken={props.authToken}
254-
/>
255-
</ScrollShadow>
256-
<FeedbackButtons
257-
sessionId={props.sessionId}
258-
authToken={props.authToken}
259-
teamId={props.teamId}
260-
/>
261-
</div>
262-
</div>
263-
</div>
264-
);
265-
}
266-
267227
return (
268228
<div className="flex gap-3">
269229
{/* Left Icon */}
@@ -462,81 +422,3 @@ function StyledMarkdownRenderer(props: {
462422
/>
463423
);
464424
}
465-
466-
function FeedbackButtons({
467-
sessionId,
468-
authToken,
469-
teamId,
470-
}: {
471-
sessionId: string | undefined;
472-
authToken: string;
473-
teamId: string | undefined;
474-
}) {
475-
const [, setFeedback] = useState<1 | -1 | null>(null);
476-
const [loading, setLoading] = useState(false);
477-
const [thankYou, setThankYou] = useState(false);
478-
const trackEvent = useTrack();
479-
480-
async function sendFeedback(rating: 1 | -1) {
481-
setLoading(true);
482-
try {
483-
trackEvent({
484-
category: "siwa",
485-
action: "submit-feedback",
486-
rating: rating === 1 ? "good" : "bad",
487-
sessionId,
488-
teamId,
489-
});
490-
const apiUrl = process.env.NEXT_PUBLIC_SIWA_URL;
491-
await fetch(`${apiUrl}/v1/chat/feedback`, {
492-
method: "POST",
493-
headers: {
494-
"Content-Type": "application/json",
495-
Authorization: `Bearer ${authToken}`,
496-
...(teamId ? { "x-team-id": teamId } : {}),
497-
},
498-
body: JSON.stringify({
499-
conversationId: sessionId,
500-
feedbackRating: rating,
501-
}),
502-
});
503-
setFeedback(rating);
504-
setThankYou(true);
505-
} catch {
506-
// TODO handle error
507-
} finally {
508-
setLoading(false);
509-
}
510-
}
511-
512-
if (thankYou) {
513-
return (
514-
<div className="mt-2 text-muted-foreground text-xs">
515-
Thank you for your feedback!
516-
</div>
517-
);
518-
}
519-
520-
return (
521-
<div className="mt-2 flex gap-2">
522-
<Button
523-
className="rounded-full border p-2 hover:bg-muted-foreground/10"
524-
variant="ghost"
525-
onClick={() => sendFeedback(-1)}
526-
disabled={loading}
527-
aria-label="Thumbs down"
528-
>
529-
<ThumbsDownIcon className="size-4 text-red-500" />
530-
</Button>
531-
<Button
532-
className="rounded-full border p-2 hover:bg-muted-foreground/10"
533-
variant="ghost"
534-
onClick={() => sendFeedback(1)}
535-
disabled={loading}
536-
aria-label="Thumbs up"
537-
>
538-
<ThumbsUpIcon className="size-4 text-green-500" />
539-
</Button>
540-
</div>
541-
);
542-
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ function CustomChatContentLoggedIn(props: {
158158
/>
159159
) : (
160160
<Chats
161-
teamId={props.teamId}
162161
messages={messages}
163162
isChatStreaming={isChatStreaming}
164163
authToken={props.authToken}

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChatContent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ function FloatingChatContentLoggedIn(props: {
202202
/>
203203
) : (
204204
<Chats
205-
teamId={undefined}
206205
messages={messages}
207206
isChatStreaming={isChatStreaming}
208207
authToken={props.authToken}

0 commit comments

Comments
 (0)