From 78ad19dd6a6ba3deb45eaa533e7e9435d817f8fe Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Tue, 19 May 2026 12:59:02 +0530 Subject: [PATCH] refactor: enhance PromptsContent with dropdown menu for actions, update loading states, and improve styling consistency --- .../components/PromptsContent.tsx | 96 +++++++++++-------- .../assistant-ui/markdown-code-block.tsx | 23 +---- .../components/assistant-ui/markdown-text.tsx | 29 ++---- .../components/assistant-ui/thread.tsx | 10 +- surfsense_web/components/ui/tooltip.tsx | 2 +- 5 files changed, 68 insertions(+), 92 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/PromptsContent.tsx b/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/PromptsContent.tsx index 10885957b..e9415a1f2 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/PromptsContent.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/user-settings/components/PromptsContent.tsx @@ -1,7 +1,7 @@ "use client"; import { useAtomValue } from "jotai"; -import { AlertTriangle, Globe, Lock, Pencil, Sparkles, Trash2 } from "lucide-react"; +import { AlertTriangle, Globe, Lock, MoreHorizontal, Pencil, Sparkles, Trash2 } from "lucide-react"; import { useCallback, useState } from "react"; import { toast } from "sonner"; import { @@ -10,6 +10,7 @@ import { updatePromptMutationAtom, } from "@/atoms/prompts/prompts-mutation.atoms"; import { promptsAtom } from "@/atoms/prompts/prompts-query.atoms"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { AlertDialog, AlertDialogAction, @@ -20,7 +21,6 @@ import { AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; -import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { @@ -31,10 +31,14 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import { ShortcutKbd } from "@/components/ui/shortcut-kbd"; -import { Skeleton } from "@/components/ui/skeleton"; import { Select, SelectContent, @@ -42,6 +46,8 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { ShortcutKbd } from "@/components/ui/shortcut-kbd"; +import { Skeleton } from "@/components/ui/skeleton"; import { Spinner } from "@/components/ui/spinner"; import { Switch } from "@/components/ui/switch"; import type { PromptRead } from "@/contracts/types/prompts.types"; @@ -221,8 +227,12 @@ export function PromptsContent() { - Transform — rewrites or modifies your text - Explore — answers a question about your text + + Transform — rewrites or modifies your text + + + Explore — answers a question about your text + @@ -333,41 +343,45 @@ export function PromptsContent() { )} -
- - - -
+ + + + + + handleTogglePublic(prompt)} + disabled={togglingPublicIds.has(prompt.id)} + > + {togglingPublicIds.has(prompt.id) ? ( + + ) : prompt.is_public ? ( + + ) : ( + + )} + {prompt.is_public ? "Make private" : "Share with community"} + + handleEdit(prompt)}> + + Edit + + setDeleteTarget(prompt.id)} + className="text-destructive focus:text-destructive" + > + + Delete + + + ))} diff --git a/surfsense_web/components/assistant-ui/markdown-code-block.tsx b/surfsense_web/components/assistant-ui/markdown-code-block.tsx index 3c8d79ec9..e6c735d1e 100644 --- a/surfsense_web/components/assistant-ui/markdown-code-block.tsx +++ b/surfsense_web/components/assistant-ui/markdown-code-block.tsx @@ -7,7 +7,6 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { materialDark, materialLight } from "react-syntax-highlighter/dist/esm/styles/prism"; import { Button } from "@/components/ui/button"; -import { Skeleton } from "@/components/ui/skeleton"; import { cn, copyToClipboard } from "@/lib/utils"; type MarkdownCodeBlockProps = { @@ -49,7 +48,7 @@ function MarkdownCodeBlockComponent({ }, [hasCopied]); return ( -
+
{language}
- ); -} diff --git a/surfsense_web/components/assistant-ui/markdown-text.tsx b/surfsense_web/components/assistant-ui/markdown-text.tsx index 43d435d20..69c1831ca 100644 --- a/surfsense_web/components/assistant-ui/markdown-text.tsx +++ b/surfsense_web/components/assistant-ui/markdown-text.tsx @@ -22,7 +22,6 @@ import { MentionChip } from "@/components/assistant-ui/mention-chip"; import "katex/dist/katex.min.css"; import { toast } from "sonner"; import { processChildrenWithCitations } from "@/components/citations/citation-renderer"; -import { Skeleton } from "@/components/ui/skeleton"; import { tryGetHostname } from "@/lib/url"; import { @@ -39,30 +38,14 @@ import { getVirtualPathDisplay } from "@/lib/chat/virtual-path-display"; import { type CitationUrlMap, preprocessCitationMarkdown } from "@/lib/citations/citation-parser"; import { cn } from "@/lib/utils"; -function MarkdownCodeBlockSkeleton() { - return ( -
-
- - -
-
- - - - -
-
- ); +function MarkdownCodeBlockLoading() { + return
; } const LazyMarkdownCodeBlock = dynamic( () => import("./markdown-code-block").then((mod) => mod.MarkdownCodeBlock), { - loading: () => , + loading: () => , } ); @@ -443,7 +426,7 @@ const defaultComponents = memoizeMarkdownComponents({
), table: ({ className, ...props }) => ( -
+
), @@ -520,7 +503,7 @@ const defaultComponents = memoizeMarkdownComponents({ return ( = ({ isBlockedByOtherUser = false