mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
chore: fix linting
This commit is contained in:
parent
4dbadbf159
commit
275e2c9e83
16 changed files with 33 additions and 74 deletions
|
|
@ -208,7 +208,10 @@ const MentionedDocumentInfoSchema = z.object({
|
|||
id: z.number(),
|
||||
title: z.string(),
|
||||
document_type: z.string(),
|
||||
kind: z.union([z.literal("doc"), z.literal("folder")]).optional().default("doc"),
|
||||
kind: z
|
||||
.union([z.literal("doc"), z.literal("folder")])
|
||||
.optional()
|
||||
.default("doc"),
|
||||
});
|
||||
|
||||
const MentionedDocumentsPartSchema = z.object({
|
||||
|
|
@ -1029,9 +1032,7 @@ export default function NewChatPage() {
|
|||
mentioned_surfsense_doc_ids: hasSurfsenseDocIds
|
||||
? mentionedDocumentIds.surfsense_doc_ids
|
||||
: undefined,
|
||||
mentioned_folder_ids: hasFolderIds
|
||||
? mentionedDocumentIds.folder_ids
|
||||
: undefined,
|
||||
mentioned_folder_ids: hasFolderIds ? mentionedDocumentIds.folder_ids : undefined,
|
||||
// Full mention metadata (docs + folders, with
|
||||
// ``kind`` discriminator) so the BE can embed a
|
||||
// ``mentioned-documents`` ContentPart on the
|
||||
|
|
@ -1900,12 +1901,10 @@ export default function NewChatPage() {
|
|||
filesystem_mode: selection.filesystem_mode,
|
||||
client_platform: selection.client_platform,
|
||||
local_filesystem_mounts: selection.local_filesystem_mounts,
|
||||
mentioned_document_ids:
|
||||
regenerateDocIds.length > 0 ? regenerateDocIds : undefined,
|
||||
mentioned_document_ids: regenerateDocIds.length > 0 ? regenerateDocIds : undefined,
|
||||
mentioned_surfsense_doc_ids:
|
||||
regenerateSurfsenseDocIds.length > 0 ? regenerateSurfsenseDocIds : undefined,
|
||||
mentioned_folder_ids:
|
||||
regenerateFolderIds.length > 0 ? regenerateFolderIds : undefined,
|
||||
mentioned_folder_ids: regenerateFolderIds.length > 0 ? regenerateFolderIds : undefined,
|
||||
// Full mention metadata for the regenerate-specific
|
||||
// source list. Only meaningful for edit (the BE only
|
||||
// re-persists a user row when ``user_query`` is set);
|
||||
|
|
|
|||
|
|
@ -97,9 +97,7 @@ export const mentionedDocumentIdsAtom = atom((get) => {
|
|||
surfsense_doc_ids: docs
|
||||
.filter((doc) => doc.document_type === "SURFSENSE_DOCS")
|
||||
.map((doc) => doc.id),
|
||||
document_ids: docs
|
||||
.filter((doc) => doc.document_type !== "SURFSENSE_DOCS")
|
||||
.map((doc) => doc.id),
|
||||
document_ids: docs.filter((doc) => doc.document_type !== "SURFSENSE_DOCS").map((doc) => doc.id),
|
||||
folder_ids: folders.map((f) => f.id),
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -47,10 +47,7 @@ export interface InlineMentionEditorRef {
|
|||
setText: (text: string) => void;
|
||||
getText: () => string;
|
||||
getMentionedDocuments: () => MentionedDocument[];
|
||||
insertMentionChip: (
|
||||
mention: MentionChipInput,
|
||||
options?: { removeTriggerText?: boolean }
|
||||
) => void;
|
||||
insertMentionChip: (mention: MentionChipInput, options?: { removeTriggerText?: boolean }) => void;
|
||||
/**
|
||||
* @deprecated Use ``insertMentionChip``. Kept for one transition
|
||||
* cycle so we don't break ad-hoc callers; prefer the new name.
|
||||
|
|
@ -364,8 +361,7 @@ export const InlineMentionEditor = forwardRef<InlineMentionEditorRef, InlineMent
|
|||
const selection = editor.selection;
|
||||
const kind: MentionKind = mention.kind ?? "doc";
|
||||
const document_type =
|
||||
mention.document_type ??
|
||||
(kind === "folder" ? FOLDER_MENTION_DOCUMENT_TYPE : undefined);
|
||||
mention.document_type ?? (kind === "folder" ? FOLDER_MENTION_DOCUMENT_TYPE : undefined);
|
||||
const mentionNode: MentionElementNode = {
|
||||
type: MENTION_TYPE,
|
||||
id: mention.id,
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ import {
|
|||
} from "@/components/ui/table";
|
||||
import { useElectronAPI } from "@/hooks/use-platform";
|
||||
import { documentsApiService } from "@/lib/apis/documents-api.service";
|
||||
import { type CitationUrlMap, preprocessCitationMarkdown } from "@/lib/citations/citation-parser";
|
||||
import { getVirtualPathDisplay } from "@/lib/chat/virtual-path-display";
|
||||
import { type CitationUrlMap, preprocessCitationMarkdown } from "@/lib/citations/citation-parser";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function MarkdownCodeBlockSkeleton() {
|
||||
|
|
@ -222,11 +222,7 @@ function FilePathLink({ path, className }: { path: string; className?: string })
|
|||
: undefined;
|
||||
|
||||
const { displayName, isFolder } = getVirtualPathDisplay(path);
|
||||
const icon = isFolder ? (
|
||||
<FolderIcon className="size-3.5" />
|
||||
) : (
|
||||
<FileIcon className="size-3.5" />
|
||||
);
|
||||
const icon = isFolder ? <FolderIcon className="size-3.5" /> : <FileIcon className="size-3.5" />;
|
||||
|
||||
const handleClick = useCallback(
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
|
|
|
|||
|
|
@ -111,11 +111,7 @@ const UserTextPart: FC = () => {
|
|||
icon={icon}
|
||||
label={segment.doc.title}
|
||||
tooltip={isFolder ? `Folder: ${segment.doc.title}` : segment.doc.title}
|
||||
onClick={
|
||||
isFolder
|
||||
? undefined
|
||||
: () => handleOpenDoc(segment.doc.id, segment.doc.title)
|
||||
}
|
||||
onClick={isFolder ? undefined : () => handleOpenDoc(segment.doc.id, segment.doc.title)}
|
||||
className="mx-0.5"
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -170,16 +170,10 @@ export function PlateEditor({
|
|||
: markdown
|
||||
? (editor) => {
|
||||
if (!enableCitations) {
|
||||
return safeDeserializeMarkdown(
|
||||
editor,
|
||||
escapeMdxExpressions(markdown)
|
||||
) as Value;
|
||||
return safeDeserializeMarkdown(editor, escapeMdxExpressions(markdown)) as Value;
|
||||
}
|
||||
const { content: rewritten, urlMap } = preprocessCitationMarkdown(markdown);
|
||||
const value = safeDeserializeMarkdown(
|
||||
editor,
|
||||
escapeMdxExpressions(rewritten)
|
||||
);
|
||||
const value = safeDeserializeMarkdown(editor, escapeMdxExpressions(rewritten));
|
||||
return injectCitationNodes(value, urlMap) as Value;
|
||||
}
|
||||
: undefined,
|
||||
|
|
@ -203,10 +197,7 @@ export function PlateEditor({
|
|||
let newValue: Descendant[];
|
||||
if (enableCitations) {
|
||||
const { content: rewritten, urlMap } = preprocessCitationMarkdown(markdown);
|
||||
const deserialized = safeDeserializeMarkdown(
|
||||
editor,
|
||||
escapeMdxExpressions(rewritten)
|
||||
);
|
||||
const deserialized = safeDeserializeMarkdown(editor, escapeMdxExpressions(rewritten));
|
||||
newValue = injectCitationNodes(deserialized, urlMap);
|
||||
} else {
|
||||
newValue = safeDeserializeMarkdown(editor, escapeMdxExpressions(markdown));
|
||||
|
|
|
|||
|
|
@ -49,10 +49,7 @@ export function safeDeserializeMarkdown(
|
|||
return api.deserialize(markdown, { remarkPlugins: STRICT_PLUGINS }) as Descendant[];
|
||||
} catch (mdxError) {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
console.warn(
|
||||
"[plate-editor] MDX parse failed, retrying without remark-mdx:",
|
||||
mdxError
|
||||
);
|
||||
console.warn("[plate-editor] MDX parse failed, retrying without remark-mdx:", mdxError);
|
||||
}
|
||||
try {
|
||||
return api.deserialize(markdown, { remarkPlugins: LENIENT_PLUGINS }) as Descendant[];
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@ import type React from "react";
|
|||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { agentFlagsAtom } from "@/atoms/agent/agent-flags-query.atom";
|
||||
import {
|
||||
makeFolderMention,
|
||||
mentionedDocumentsAtom,
|
||||
} from "@/atoms/chat/mentioned-documents.atom";
|
||||
import { makeFolderMention, mentionedDocumentsAtom } from "@/atoms/chat/mentioned-documents.atom";
|
||||
import { connectorDialogOpenAtom } from "@/atoms/connector-dialog/connector-dialog.atoms";
|
||||
import { connectorsAtom } from "@/atoms/connectors/connector-query.atoms";
|
||||
import { deleteDocumentMutationAtom } from "@/atoms/documents/document-mutation.atoms";
|
||||
|
|
|
|||
|
|
@ -301,8 +301,7 @@ export const DocumentMentionPicker = forwardRef<
|
|||
// folder entries lift the existing kind-aware key so the same
|
||||
// matchers used by the chip atom apply unchanged.
|
||||
const selectedKeys = useMemo(
|
||||
() =>
|
||||
new Set(initialSelectedDocuments.map((d) => getMentionDocKey(d))),
|
||||
() => new Set(initialSelectedDocuments.map((d) => getMentionDocKey(d))),
|
||||
[initialSelectedDocuments]
|
||||
);
|
||||
|
||||
|
|
@ -583,9 +582,7 @@ export const DocumentMentionPicker = forwardRef<
|
|||
{(surfsenseDocsList.length > 0 || userDocsList.length > 0) && (
|
||||
<div className="mx-2 my-4 border-t border-border dark:border-white/5" />
|
||||
)}
|
||||
<div className="px-3 py-2 text-xs font-bold text-muted-foreground/55">
|
||||
Folders
|
||||
</div>
|
||||
<div className="px-3 py-2 text-xs font-bold text-muted-foreground/55">Folders</div>
|
||||
{folderMentions.map((folder) => {
|
||||
const folderKey = getMentionDocKey(folder);
|
||||
const isAlreadySelected = selectedKeys.has(folderKey);
|
||||
|
|
|
|||
|
|
@ -59,19 +59,15 @@ export default defineConfig({
|
|||
? undefined
|
||||
: {
|
||||
// Local stays on webpack dev (Turbopack caused stale-lock panics in E2E).
|
||||
command: process.env.CI
|
||||
? "pnpm build && pnpm start"
|
||||
: "pnpm exec next dev",
|
||||
command: process.env.CI ? "pnpm build && pnpm start" : "pnpm exec next dev",
|
||||
url: `http://localhost:${PORT}`,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: process.env.CI ? 300_000 : 180_000,
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
stderr: "pipe",
|
||||
env: {
|
||||
NEXT_PUBLIC_FASTAPI_BACKEND_URL:
|
||||
process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL,
|
||||
NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE:
|
||||
process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE,
|
||||
NEXT_PUBLIC_FASTAPI_BACKEND_URL: process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL,
|
||||
NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE: process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ export const BACKEND_URL = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http:
|
|||
|
||||
const TEST_USER_EMAIL = process.env.PLAYWRIGHT_TEST_EMAIL || "e2e-test@surfsense.net";
|
||||
const TEST_USER_PASSWORD = process.env.PLAYWRIGHT_TEST_PASSWORD || "E2eTestPassword123!";
|
||||
const E2E_MINT_SECRET =
|
||||
process.env.E2E_MINT_SECRET || "local-e2e-mint-secret-not-for-production";
|
||||
const E2E_MINT_SECRET = process.env.E2E_MINT_SECRET || "local-e2e-mint-secret-not-for-production";
|
||||
|
||||
/**
|
||||
* Mints a JWT for the seeded e2e user via the test-only endpoint mounted
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue