chore: linting

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-04-02 19:45:28 -07:00
parent 62e698d8aa
commit eb17850274
15 changed files with 127 additions and 108 deletions

View file

@ -947,36 +947,36 @@ export function DocumentsTableShell({
WebkitMaskImage: `linear-gradient(to bottom, ${previewScrollPos === "top" ? "black" : "transparent"}, black 16px, black calc(100% - 16px), ${previewScrollPos === "bottom" ? "black" : "transparent"})`, WebkitMaskImage: `linear-gradient(to bottom, ${previewScrollPos === "top" ? "black" : "transparent"}, black 16px, black calc(100% - 16px), ${previewScrollPos === "bottom" ? "black" : "transparent"})`,
}} }}
> >
{viewingLoading ? ( {viewingLoading ? (
<div className="flex items-center justify-center py-12"> <div className="flex items-center justify-center py-12">
<Spinner size="lg" className="text-muted-foreground" /> <Spinner size="lg" className="text-muted-foreground" />
</div> </div>
) : ( ) : (
<> <>
<MarkdownViewer content={viewingContent} maxLength={50_000} /> <MarkdownViewer content={viewingContent} maxLength={50_000} />
{viewingDoc && ( {viewingDoc && (
<div className="mt-4 flex justify-center"> <div className="mt-4 flex justify-center">
<Button <Button
variant="outline" variant="outline"
size="sm" size="sm"
onClick={() => { onClick={() => {
if (viewingDoc) { if (viewingDoc) {
openEditor({ openEditor({
documentId: viewingDoc.id, documentId: viewingDoc.id,
searchSpaceId: Number(searchSpaceId), searchSpaceId: Number(searchSpaceId),
title: viewingDoc.title, title: viewingDoc.title,
}); });
handleCloseViewer(); handleCloseViewer();
} }
}} }}
> >
<Eye className="h-3.5 w-3.5 mr-1.5" /> <Eye className="h-3.5 w-3.5 mr-1.5" />
View full document View full document
</Button> </Button>
</div> </div>
)} )}
</> </>
)} )}
</div> </div>
</DrawerContent> </DrawerContent>
</Drawer> </Drawer>

View file

@ -232,7 +232,7 @@ export default function NewChatPage() {
const prevById = new Map(prev.map((m) => [m.id, m])); const prevById = new Map(prev.map((m) => [m.id, m]));
return syncedMessages.map((msg) => { return syncedMessages.map((msg) => {
const member = msg.author_id ? memberById.get(msg.author_id) ?? null : null; const member = msg.author_id ? (memberById.get(msg.author_id) ?? null) : null;
// Preserve existing author info if member lookup fails (e.g., cloned chats) // Preserve existing author info if member lookup fails (e.g., cloned chats)
const existingMsg = prevById.get(`msg-${msg.id}`); const existingMsg = prevById.get(`msg-${msg.id}`);

View file

@ -1,8 +1,8 @@
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from "fumadocs-ui/page"; import { DocsBody, DocsDescription, DocsPage, DocsTitle } from "fumadocs-ui/page";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
import { cache } from "react";
import { source } from "@/lib/source"; import { source } from "@/lib/source";
import { getMDXComponents } from "@/mdx-components"; import { getMDXComponents } from "@/mdx-components";
import { cache } from "react";
const getDocPage = cache((slug?: string[]) => { const getDocPage = cache((slug?: string[]) => {
return source.getPage(slug); return source.getPage(slug);

View file

@ -1,6 +1,5 @@
"use client"; "use client";
import { useEffect } from "react"; import { useEffect } from "react";
export default function ErrorPage({ export default function ErrorPage({

View file

@ -16,10 +16,7 @@ function convertDisplayToData(displayContent: string, mentions: InsertedMention[
const sortedMentions = [...mentions].sort((a, b) => b.displayName.length - a.displayName.length); const sortedMentions = [...mentions].sort((a, b) => b.displayName.length - a.displayName.length);
const mentionPatterns = sortedMentions.map((mention) => ({ const mentionPatterns = sortedMentions.map((mention) => ({
pattern: new RegExp( pattern: new RegExp(`@${escapeRegExp(mention.displayName)}(?=\\s|$|[.,!?;:])`, "g"),
`@${escapeRegExp(mention.displayName)}(?=\\s|$|[.,!?;:])`,
"g"
),
dataFormat: `@[${mention.id}]`, dataFormat: `@[${mention.id}]`,
})); }));

View file

@ -223,7 +223,9 @@ export function EditorPanelContent({
<FileText className="size-4" /> <FileText className="size-4" />
<AlertDescription className="flex items-center justify-between gap-4"> <AlertDescription className="flex items-center justify-between gap-4">
<span> <span>
This document is too large for the editor ({Math.round((editorDoc.content_size_bytes ?? 0) / 1024 / 1024)}MB, {editorDoc.chunk_count ?? 0} chunks). Showing a preview below. This document is too large for the editor (
{Math.round((editorDoc.content_size_bytes ?? 0) / 1024 / 1024)}MB,{" "}
{editorDoc.chunk_count ?? 0} chunks). Showing a preview below.
</span> </span>
<Button <Button
variant="outline" variant="outline"

View file

@ -253,7 +253,9 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen
<FileText className="size-4" /> <FileText className="size-4" />
<AlertDescription className="flex items-center justify-between gap-4"> <AlertDescription className="flex items-center justify-between gap-4">
<span> <span>
This document is too large for the editor ({Math.round((doc.content_size_bytes ?? 0) / 1024 / 1024)}MB, {doc.chunk_count ?? 0} chunks). Showing a preview below. This document is too large for the editor (
{Math.round((doc.content_size_bytes ?? 0) / 1024 / 1024)}MB,{" "}
{doc.chunk_count ?? 0} chunks). Showing a preview below.
</span> </span>
<Button <Button
variant="outline" variant="outline"

View file

@ -176,7 +176,8 @@ export function MarkdownViewer({ content, className, maxLength }: MarkdownViewer
</Streamdown> </Streamdown>
{isTruncated && ( {isTruncated && (
<p className="mt-4 text-sm text-muted-foreground italic"> <p className="mt-4 text-sm text-muted-foreground italic">
Content truncated ({Math.round(content.length / 1024)}KB total). Showing first {Math.round(maxLength / 1024)}KB. Content truncated ({Math.round(content.length / 1024)}KB total). Showing first{" "}
{Math.round(maxLength / 1024)}KB.
</p> </p>
)} )}
</div> </div>

View file

@ -1,7 +1,17 @@
"use client"; "use client";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { BookOpen, ChevronDown, ChevronUp, ExternalLink, FileText, Hash, Loader2, Sparkles, X } from "lucide-react"; import {
BookOpen,
ChevronDown,
ChevronUp,
ExternalLink,
FileText,
Hash,
Loader2,
Sparkles,
X,
} from "lucide-react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import type React from "react"; import type React from "react";
@ -56,48 +66,52 @@ interface ChunkCardProps {
} }
const ChunkCard = memo( const ChunkCard = memo(
forwardRef<HTMLDivElement, ChunkCardProps>(({ chunk, localIndex, chunkNumber, totalChunks, isCited }, ref) => { forwardRef<HTMLDivElement, ChunkCardProps>(
return ( ({ chunk, localIndex, chunkNumber, totalChunks, isCited }, ref) => {
<div return (
ref={ref} <div
data-chunk-index={localIndex} ref={ref}
className={cn( data-chunk-index={localIndex}
"group relative rounded-2xl border-2 transition-all duration-300", className={cn(
isCited "group relative rounded-2xl border-2 transition-all duration-300",
? "bg-linear-to-br from-primary/5 via-primary/10 to-primary/5 border-primary shadow-lg shadow-primary/10" isCited
: "bg-card border-border/50 hover:border-border hover:shadow-md" ? "bg-linear-to-br from-primary/5 via-primary/10 to-primary/5 border-primary shadow-lg shadow-primary/10"
)} : "bg-card border-border/50 hover:border-border hover:shadow-md"
>
{isCited && <div className="absolute inset-0 rounded-2xl bg-primary/5 blur-xl -z-10" />}
<div className="flex items-center justify-between px-5 py-4 border-b border-border/50">
<div className="flex items-center gap-3">
<div
className={cn(
"flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold transition-colors",
isCited
? "bg-primary text-primary-foreground"
: "bg-muted text-muted-foreground group-hover:bg-muted/80"
)}
>
{chunkNumber}
</div>
<span className="text-sm text-muted-foreground">Chunk {chunkNumber} of {totalChunks}</span>
</div>
{isCited && (
<Badge variant="default" className="gap-1.5 px-3 py-1">
<Sparkles className="h-3 w-3" />
Cited Source
</Badge>
)} )}
</div> >
{isCited && <div className="absolute inset-0 rounded-2xl bg-primary/5 blur-xl -z-10" />}
<div className="p-5 overflow-hidden"> <div className="flex items-center justify-between px-5 py-4 border-b border-border/50">
<MarkdownViewer content={chunk.content} maxLength={100_000} /> <div className="flex items-center gap-3">
<div
className={cn(
"flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold transition-colors",
isCited
? "bg-primary text-primary-foreground"
: "bg-muted text-muted-foreground group-hover:bg-muted/80"
)}
>
{chunkNumber}
</div>
<span className="text-sm text-muted-foreground">
Chunk {chunkNumber} of {totalChunks}
</span>
</div>
{isCited && (
<Badge variant="default" className="gap-1.5 px-3 py-1">
<Sparkles className="h-3 w-3" />
Cited Source
</Badge>
)}
</div>
<div className="p-5 overflow-hidden">
<MarkdownViewer content={chunk.content} maxLength={100_000} />
</div>
</div> </div>
</div> );
); }
}) )
); );
ChunkCard.displayName = "ChunkCard"; ChunkCard.displayName = "ChunkCard";
@ -142,11 +156,16 @@ export function SourceDetailPanel({
staleTime: 5 * 60 * 1000, staleTime: 5 * 60 * 1000,
}); });
const totalChunks = (documentData && "total_chunks" in documentData) const totalChunks =
? (documentData.total_chunks ?? documentData.chunks.length) documentData && "total_chunks" in documentData
: (documentData?.chunks?.length ?? 0); ? (documentData.total_chunks ?? documentData.chunks.length)
const [beforeChunks, setBeforeChunks] = useState<Array<{ id: number; content: string; created_at: string }>>([]); : (documentData?.chunks?.length ?? 0);
const [afterChunks, setAfterChunks] = useState<Array<{ id: number; content: string; created_at: string }>>([]); const [beforeChunks, setBeforeChunks] = useState<
Array<{ id: number; content: string; created_at: string }>
>([]);
const [afterChunks, setAfterChunks] = useState<
Array<{ id: number; content: string; created_at: string }>
>([]);
const [loadingBefore, setLoadingBefore] = useState(false); const [loadingBefore, setLoadingBefore] = useState(false);
const [loadingAfter, setLoadingAfter] = useState(false); const [loadingAfter, setLoadingAfter] = useState(false);
@ -155,8 +174,8 @@ export function SourceDetailPanel({
setAfterChunks([]); setAfterChunks([]);
}, [chunkId, open]); }, [chunkId, open]);
const chunkStartIndex = (documentData && "chunk_start_index" in documentData) const chunkStartIndex =
? (documentData.chunk_start_index ?? 0) : 0; documentData && "chunk_start_index" in documentData ? (documentData.chunk_start_index ?? 0) : 0;
const initialChunks = documentData?.chunks ?? []; const initialChunks = documentData?.chunks ?? [];
const allChunks = [...beforeChunks, ...initialChunks, ...afterChunks]; const allChunks = [...beforeChunks, ...initialChunks, ...afterChunks];
const absoluteStart = chunkStartIndex - beforeChunks.length; const absoluteStart = chunkStartIndex - beforeChunks.length;
@ -177,11 +196,11 @@ export function SourceDetailPanel({
page_size: count, page_size: count,
start_offset: absoluteStart - count, start_offset: absoluteStart - count,
}); });
const existingIds = new Set(allChunks.map(c => c.id)); const existingIds = new Set(allChunks.map((c) => c.id));
const newChunks = result.items const newChunks = result.items
.filter(c => !existingIds.has(c.id)) .filter((c) => !existingIds.has(c.id))
.map(c => ({ id: c.id, content: c.content, created_at: c.created_at })); .map((c) => ({ id: c.id, content: c.content, created_at: c.created_at }));
setBeforeChunks(prev => [...newChunks, ...prev]); setBeforeChunks((prev) => [...newChunks, ...prev]);
} catch (err) { } catch (err) {
console.error("Failed to load earlier chunks:", err); console.error("Failed to load earlier chunks:", err);
} finally { } finally {
@ -199,11 +218,11 @@ export function SourceDetailPanel({
page_size: EXPAND_SIZE, page_size: EXPAND_SIZE,
start_offset: absoluteEnd, start_offset: absoluteEnd,
}); });
const existingIds = new Set(allChunks.map(c => c.id)); const existingIds = new Set(allChunks.map((c) => c.id));
const newChunks = result.items const newChunks = result.items
.filter(c => !existingIds.has(c.id)) .filter((c) => !existingIds.has(c.id))
.map(c => ({ id: c.id, content: c.content, created_at: c.created_at })); .map((c) => ({ id: c.id, content: c.content, created_at: c.created_at }));
setAfterChunks(prev => [...prev, ...newChunks]); setAfterChunks((prev) => [...prev, ...newChunks]);
} catch (err) { } catch (err) {
console.error("Failed to load later chunks:", err); console.error("Failed to load later chunks:", err);
} finally { } finally {
@ -400,12 +419,12 @@ export function SourceDetailPanel({
{documentData && "document_type" in documentData {documentData && "document_type" in documentData
? formatDocumentType(documentData.document_type) ? formatDocumentType(documentData.document_type)
: sourceType && formatDocumentType(sourceType)} : sourceType && formatDocumentType(sourceType)}
{totalChunks > 0 && ( {totalChunks > 0 && (
<span className="ml-2"> <span className="ml-2">
{totalChunks} chunk{totalChunks !== 1 ? "s" : ""} {totalChunks} chunk{totalChunks !== 1 ? "s" : ""}
{allChunks.length < totalChunks && ` (showing ${allChunks.length})`} {allChunks.length < totalChunks && ` (showing ${allChunks.length})`}
</span> </span>
)} )}
</p> </p>
</div> </div>
<div className="flex items-center gap-3 shrink-0"> <div className="flex items-center gap-3 shrink-0">

View file

@ -273,8 +273,7 @@ export function DocumentUploadTab({
<Alert className="border border-border bg-slate-400/5 dark:bg-white/5"> <Alert className="border border-border bg-slate-400/5 dark:bg-white/5">
<Info className="h-4 w-4 shrink-0 mt-0.5" /> <Info className="h-4 w-4 shrink-0 mt-0.5" />
<AlertDescription className="text-xs sm:text-sm leading-relaxed pt-0.5"> <AlertDescription className="text-xs sm:text-sm leading-relaxed pt-0.5">
{t("file_size_limit", { maxMB: MAX_FILE_SIZE_MB })}{" "} {t("file_size_limit", { maxMB: MAX_FILE_SIZE_MB })} {t("upload_limits")}
{t("upload_limits")}
</AlertDescription> </AlertDescription>
</Alert> </Alert>

View file

@ -1,7 +1,7 @@
"use client"; "use client";
import { CheckIcon } from "lucide-react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { CheckIcon } from "lucide-react";
import type * as React from "react"; import type * as React from "react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";

View file

@ -1,7 +1,7 @@
"use client"; "use client";
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
import type * as React from "react"; import type * as React from "react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";

View file

@ -1,7 +1,7 @@
"use client"; "use client";
import type { VariantProps } from "class-variance-authority";
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"; import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
import type { VariantProps } from "class-variance-authority";
import * as React from "react"; import * as React from "react";
import { toggleVariants } from "@/components/ui/toggle"; import { toggleVariants } from "@/components/ui/toggle";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";

View file

@ -1,7 +1,7 @@
"use client"; "use client";
import { cva, type VariantProps } from "class-variance-authority";
import * as TogglePrimitive from "@radix-ui/react-toggle"; import * as TogglePrimitive from "@radix-ui/react-toggle";
import { cva, type VariantProps } from "class-variance-authority";
import type * as React from "react"; import type * as React from "react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";

View file

@ -1,6 +1,6 @@
"use client"; "use client";
import dynamic from "next/dynamic";
import { QueryClientAtomProvider } from "jotai-tanstack-query/react"; import { QueryClientAtomProvider } from "jotai-tanstack-query/react";
import dynamic from "next/dynamic";
import { queryClient } from "./client"; import { queryClient } from "./client";
const ReactQueryDevtools = dynamic( const ReactQueryDevtools = dynamic(