From bea46980eaf13d0fd5e2e34c59be907a9605f781 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Thu, 23 Jul 2026 23:44:21 +0530 Subject: [PATCH] refactor(thread-ui): simplify Composer component by removing unused props and ConnectToolsBanner --- .../components/assistant-ui/thread.tsx | 116 +----------------- 1 file changed, 3 insertions(+), 113 deletions(-) diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index 120af4bfe..5c31af139 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -22,7 +22,6 @@ import { Wrench, X, } from "lucide-react"; -import { AnimatePresence, motion } from "motion/react"; import Image from "next/image"; import { useParams, useRouter } from "next/navigation"; import { type FC, useCallback, useEffect, useMemo, useRef, useState } from "react"; @@ -89,7 +88,6 @@ import { Popover, PopoverAnchor } from "@/components/ui/popover"; import { Skeleton } from "@/components/ui/skeleton"; import { Switch } from "@/components/ui/switch"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; -import { getConnectorIcon } from "@/contracts/enums/connectorIcons"; import { CONNECTOR_ICON_TO_TYPES, CONNECTOR_TOOL_ICON_PATHS, @@ -172,7 +170,7 @@ const ThreadContent: FC = ({ footer={ <> - + } > @@ -312,103 +310,6 @@ const ThreadWelcome: FC = () => { ); }; -const BANNER_CONNECTORS = [ - { type: "GOOGLE_DRIVE_CONNECTOR", label: "Google Drive" }, - { type: "GOOGLE_GMAIL_CONNECTOR", label: "Gmail" }, - { type: "NOTION_CONNECTOR", label: "Notion" }, - { type: "YOUTUBE_CONNECTOR", label: "YouTube" }, - { type: "SLACK_CONNECTOR", label: "Slack" }, -] as const; - -const BANNER_DISMISSED_KEY = "surfsense-connect-tools-banner-dismissed"; - -const ConnectToolsBanner: FC<{ - isThreadEmpty: boolean; - onVisibleChange?: (visible: boolean) => void; -}> = ({ isThreadEmpty, onVisibleChange }) => { - const { data: connectors } = useAtomValue(connectorsAtom); - const router = useRouter(); - const params = useParams(); - const bannerWorkspaceId = getWorkspaceIdNumber(params); - const [dismissed, setDismissed] = useState(() => { - if (typeof window === "undefined") return false; - return localStorage.getItem(BANNER_DISMISSED_KEY) === "true"; - }); - const [dismissRequested, setDismissRequested] = useState(false); - - const hasConnectors = (connectors?.length ?? 0) > 0; - const isVisible = !dismissed && !hasConnectors && isThreadEmpty; - const shouldShowTray = isVisible && !dismissRequested; - - useEffect(() => { - onVisibleChange?.(isVisible); - }, [isVisible, onVisibleChange]); - - const handleDismiss = (e: React.MouseEvent) => { - e.stopPropagation(); - setDismissRequested(true); - }; - - return ( - { - if (!dismissRequested) return; - setDismissed(true); - localStorage.setItem(BANNER_DISMISSED_KEY, "true"); - }} - > - {shouldShowTray ? ( - - -
- - {BANNER_CONNECTORS.map(({ type }, i) => ( - - - {getConnectorIcon(type, "size-3")} - - - ))} - - - - ) : null} - - ); -}; - const PendingScreenImageStrip: FC = () => { const [urls, setUrls] = useAtom(pendingUserImageDataUrlsAtom); if (urls.length === 0) return null; @@ -488,8 +389,7 @@ const ClipboardChip: FC<{ text: string; onDismiss: () => void }> = ({ text, onDi }; /** - * Inline "this workspace can't chat yet" tray, mirrored on top of the composer - * (same visual treatment as the "Connect your tools" tray below it). + * Inline "this workspace can't chat yet" tray, mirrored on top of the composer. * * Replaces the old full-screen onboarding redirect: a workspace with no usable * chat model (fresh install, or an admin deleted the last model) renders the @@ -534,14 +434,10 @@ const ChatUnavailableNotice: FC<{ workspaceId: number; canConfigure: boolean }> }; interface ComposerProps { - hasActiveThread?: boolean; isLoadingMessages?: boolean; } -const Composer: FC = ({ - hasActiveThread = false, - isLoadingMessages = false, -}) => { +const Composer: FC = ({ isLoadingMessages = false }) => { const [mentionedDocuments, setMentionedDocuments] = useAtom(mentionedDocumentsAtom); const setSubmittedMentions = useSetAtom(submittedMentionsAtom); const [showDocumentPopover, setShowDocumentPopover] = useState(false); @@ -578,7 +474,6 @@ const Composer: FC = ({ const isThreadEmpty = useAuiState(({ thread }) => thread.isEmpty); const isThreadRunning = useAuiState(({ thread }) => thread.isRunning); - const [connectToolsTrayVisible, setConnectToolsTrayVisible] = useState(false); const { data: chatSetupStatus } = useAtomValue(llmSetupStatusAtomFamily(workspaceId ?? 0)); const isChatUnavailable = !!chatSetupStatus && chatSetupStatus.status !== "ready"; @@ -1040,7 +935,6 @@ const Composer: FC = ({
@@ -1074,10 +968,6 @@ const Composer: FC = ({ onChatModelSelected={handleChatModelSelected} />
- {!isLoadingMessages && isThreadEmpty && isComposerInputEmpty ? (