mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
chore: linting
This commit is contained in:
parent
62e698d8aa
commit
eb17850274
15 changed files with 127 additions and 108 deletions
|
|
@ -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}`);
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export default function ErrorPage({
|
export default function ErrorPage({
|
||||||
|
|
|
||||||
|
|
@ -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}]`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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,7 +66,8 @@ interface ChunkCardProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChunkCard = memo(
|
const ChunkCard = memo(
|
||||||
forwardRef<HTMLDivElement, ChunkCardProps>(({ chunk, localIndex, chunkNumber, totalChunks, isCited }, ref) => {
|
forwardRef<HTMLDivElement, ChunkCardProps>(
|
||||||
|
({ chunk, localIndex, chunkNumber, totalChunks, isCited }, ref) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|
@ -82,7 +93,9 @@ const ChunkCard = memo(
|
||||||
>
|
>
|
||||||
{chunkNumber}
|
{chunkNumber}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-sm text-muted-foreground">Chunk {chunkNumber} of {totalChunks}</span>
|
<span className="text-sm text-muted-foreground">
|
||||||
|
Chunk {chunkNumber} of {totalChunks}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{isCited && (
|
{isCited && (
|
||||||
<Badge variant="default" className="gap-1.5 px-3 py-1">
|
<Badge variant="default" className="gap-1.5 px-3 py-1">
|
||||||
|
|
@ -97,7 +110,8 @@ const ChunkCard = memo(
|
||||||
</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" in documentData
|
||||||
? (documentData.total_chunks ?? documentData.chunks.length)
|
? (documentData.total_chunks ?? documentData.chunks.length)
|
||||||
: (documentData?.chunks?.length ?? 0);
|
: (documentData?.chunks?.length ?? 0);
|
||||||
const [beforeChunks, setBeforeChunks] = useState<Array<{ id: number; content: string; created_at: string }>>([]);
|
const [beforeChunks, setBeforeChunks] = useState<
|
||||||
const [afterChunks, setAfterChunks] = useState<Array<{ id: number; content: string; created_at: string }>>([]);
|
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 {
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
|
||||||
|
|
@ -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(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue