diff --git a/src/components/layout/celebi-panel.tsx b/src/components/layout/celebi-panel.tsx index 12dd1ff..6828f98 100644 --- a/src/components/layout/celebi-panel.tsx +++ b/src/components/layout/celebi-panel.tsx @@ -7,8 +7,9 @@ import { CelebiMarkdown } from "@/components/layout/celebi-markdown"; import { CelebiReplyActions } from "@/components/layout/celebi-reply-actions"; import { CelebiThinkingLabel } from "@/components/layout/celebi-thinking-label"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; +import { DataTableSearch } from "@/components/ui/data-table-search"; import { EmptyInline } from "@/components/ui/empty-inline"; -import { IconAlert, IconBotSquare, IconCopy, IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; +import { IconAlert, IconBotSquare, IconChevronDown, IconCopy, IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; import { SidePanel } from "@/components/ui/side-panel"; import { cn } from "@/lib/cn"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -34,6 +35,8 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean const [threads, setThreads] = createSignal([]); const [sending, setSending] = createSignal(false); const [copiedId, setCopiedId] = createSignal(); + const [searchQuery, setSearchQuery] = createSignal(""); + const [showScrollToLatest, setShowScrollToLatest] = createSignal(false); const copyMessage = async (message: PanelMessage) => { await navigator.clipboard.writeText(message.content); @@ -94,7 +97,18 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean const NEAR_BOTTOM_PX = 64; const scrollToLatest = () => { if (!transcript) return; - transcript.scrollTop = transcript.scrollHeight; + transcript.scrollTo({ top: transcript.scrollHeight, behavior: "smooth" }); + setShowScrollToLatest(false); + }; + const handleTranscriptScroll = () => { + if (!transcript) return; + const distance = transcript.scrollHeight - transcript.scrollTop - transcript.clientHeight; + setShowScrollToLatest(distance > NEAR_BOTTOM_PX); + }; + const filteredMessages = () => { + const query = searchQuery().trim().toLocaleLowerCase(locale()); + if (!query) return messages(); + return messages().filter((message) => message.content.toLocaleLowerCase(locale()).includes(query)); }; createEffect(() => { const items = messages(); @@ -217,7 +231,7 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean }; return ( - +
-
+
+ + + + +
+
0} fallback={ } > + 0} + fallback={

{t("ai.noSearchResults")}

} + >
- + {(message) => (
@@ -312,6 +344,7 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean
+
, ) { // Kobalte's modal Dialog hides the app with aria-hidden before its focus @@ -74,7 +75,7 @@ export function SidePanel(
-
+
{props.children}
diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 968bee6..6b79a5d 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -25,6 +25,9 @@ export type MessageKey = | "ai.goTo" | "ai.didYouMean" | "ai.skipTyping" + | "ai.searchPlaceholder" + | "ai.scrollToLatest" + | "ai.noSearchResults" | "nav.today" | "nav.classes" | "nav.classGroups" @@ -1908,6 +1911,9 @@ const en: Dict = { "ai.goTo": "Go to the page", "ai.didYouMean": "Did you mean one of these?", "ai.skipTyping": "Show the whole answer", + "ai.searchPlaceholder": "Search this chat...", + "ai.scrollToLatest": "Latest", + "ai.noSearchResults": "No messages match your search.", "nav.today": "Today", "nav.classes": "Courses", "nav.classGroups": "Classes", @@ -3802,6 +3808,9 @@ const tr: Dict = { "ai.goTo": "Sayfaya git", "ai.didYouMean": "Bunu mu demek istedin?", "ai.skipTyping": "Cevabın tamamını göster", + "ai.searchPlaceholder": "Bu sohbette ara...", + "ai.scrollToLatest": "En alta git", + "ai.noSearchResults": "Aramanla eşleşen mesaj yok.", "nav.today": "Bugün", "nav.classes": "Dersler", "nav.classGroups": "Şubeler",