mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 05:42:39 +02:00
chore; linting
This commit is contained in:
parent
70686a1eb2
commit
d198c8b89d
16 changed files with 228 additions and 167 deletions
|
|
@ -1,7 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { Slottable } from "@radix-ui/react-slot";
|
||||
import { type ComponentPropsWithRef, type ReactNode, forwardRef } from "react";
|
||||
import { type ComponentPropsWithRef, forwardRef, type ReactNode } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
Edit2,
|
||||
FileText,
|
||||
Globe,
|
||||
Logs,
|
||||
type LucideIcon,
|
||||
MessageCircle,
|
||||
MessageSquare,
|
||||
|
|
@ -14,7 +15,6 @@ import {
|
|||
MoreHorizontal,
|
||||
Plug,
|
||||
Plus,
|
||||
Logs,
|
||||
Settings,
|
||||
Shield,
|
||||
Trash2,
|
||||
|
|
@ -23,13 +23,13 @@ import {
|
|||
import { motion } from "motion/react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { myAccessAtom } from "@/atoms/members/members-query.atoms";
|
||||
import { permissionsAtom } from "@/atoms/permissions/permissions-query.atoms";
|
||||
import {
|
||||
createRoleMutationAtom,
|
||||
deleteRoleMutationAtom,
|
||||
updateRoleMutationAtom,
|
||||
} from "@/atoms/roles/roles-mutation.atoms";
|
||||
import { permissionsAtom } from "@/atoms/permissions/permissions-query.atoms";
|
||||
import { myAccessAtom } from "@/atoms/members/members-query.atoms";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
|
|
|
|||
|
|
@ -253,29 +253,31 @@ function ApprovalCard({
|
|||
</div>
|
||||
)}
|
||||
|
||||
{/* Display mode */}
|
||||
{!isEditing && (
|
||||
<div className="space-y-2 px-4 py-3 bg-card">
|
||||
<div>
|
||||
<p className="text-xs font-medium text-muted-foreground">Name</p>
|
||||
<p className="text-sm text-foreground">{committedArgs?.name ?? args.name}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs font-medium text-muted-foreground">Type</p>
|
||||
<p className="text-sm text-foreground">
|
||||
{FILE_TYPE_LABELS[committedArgs?.file_type ?? args.file_type] ?? committedArgs?.file_type ?? args.file_type}
|
||||
</p>
|
||||
</div>
|
||||
{(committedArgs?.content ?? args.content) && (
|
||||
{/* Display mode */}
|
||||
{!isEditing && (
|
||||
<div className="space-y-2 px-4 py-3 bg-card">
|
||||
<div>
|
||||
<p className="text-xs font-medium text-muted-foreground">Content</p>
|
||||
<p className="line-clamp-4 text-sm whitespace-pre-wrap text-foreground">
|
||||
{committedArgs?.content ?? args.content}
|
||||
<p className="text-xs font-medium text-muted-foreground">Name</p>
|
||||
<p className="text-sm text-foreground">{committedArgs?.name ?? args.name}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs font-medium text-muted-foreground">Type</p>
|
||||
<p className="text-sm text-foreground">
|
||||
{FILE_TYPE_LABELS[committedArgs?.file_type ?? args.file_type] ??
|
||||
committedArgs?.file_type ??
|
||||
args.file_type}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(committedArgs?.content ?? args.content) && (
|
||||
<div>
|
||||
<p className="text-xs font-medium text-muted-foreground">Content</p>
|
||||
<p className="line-clamp-4 text-sm whitespace-pre-wrap text-foreground">
|
||||
{committedArgs?.content ?? args.content}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Edit mode */}
|
||||
{isEditing && !decided && (
|
||||
|
|
@ -341,26 +343,26 @@ function ApprovalCard({
|
|||
</p>
|
||||
) : isEditing ? (
|
||||
<>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const finalArgs = buildFinalArgs();
|
||||
setCommittedArgs(finalArgs);
|
||||
setDecided("edit");
|
||||
setIsEditing(false);
|
||||
onDecision({
|
||||
type: "edit",
|
||||
edited_action: {
|
||||
name: interruptData.action_requests[0].name,
|
||||
args: finalArgs,
|
||||
},
|
||||
});
|
||||
}}
|
||||
disabled={!canApprove}
|
||||
>
|
||||
<CheckIcon />
|
||||
Approve with Changes
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const finalArgs = buildFinalArgs();
|
||||
setCommittedArgs(finalArgs);
|
||||
setDecided("edit");
|
||||
setIsEditing(false);
|
||||
onDecision({
|
||||
type: "edit",
|
||||
edited_action: {
|
||||
name: interruptData.action_requests[0].name,
|
||||
args: finalArgs,
|
||||
},
|
||||
});
|
||||
}}
|
||||
disabled={!canApprove}
|
||||
>
|
||||
<CheckIcon />
|
||||
Approve with Changes
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
|
|
@ -376,25 +378,25 @@ function ApprovalCard({
|
|||
) : (
|
||||
<>
|
||||
{allowedDecisions.includes("approve") && (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const finalArgs = buildFinalArgs();
|
||||
setCommittedArgs(finalArgs);
|
||||
setDecided("approve");
|
||||
onDecision({
|
||||
type: "approve",
|
||||
edited_action: {
|
||||
name: interruptData.action_requests[0].name,
|
||||
args: finalArgs,
|
||||
},
|
||||
});
|
||||
}}
|
||||
disabled={!canApprove}
|
||||
>
|
||||
<CheckIcon />
|
||||
Approve
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const finalArgs = buildFinalArgs();
|
||||
setCommittedArgs(finalArgs);
|
||||
setDecided("approve");
|
||||
onDecision({
|
||||
type: "approve",
|
||||
edited_action: {
|
||||
name: interruptData.action_requests[0].name,
|
||||
args: finalArgs,
|
||||
},
|
||||
});
|
||||
}}
|
||||
disabled={!canApprove}
|
||||
>
|
||||
<CheckIcon />
|
||||
Approve
|
||||
</Button>
|
||||
)}
|
||||
{canEdit && (
|
||||
<Button size="sm" variant="outline" onClick={() => setIsEditing(true)}>
|
||||
|
|
|
|||
|
|
@ -390,9 +390,7 @@ function WarningCard({ result }: { result: WarningResult }) {
|
|||
</div>
|
||||
</div>
|
||||
<div className="space-y-2 px-4 py-3">
|
||||
{result.message && (
|
||||
<p className="text-sm text-muted-foreground">{result.message}</p>
|
||||
)}
|
||||
{result.message && <p className="text-sm text-muted-foreground">{result.message}</p>}
|
||||
<p className="text-xs text-amber-600 dark:text-amber-500">{result.warning}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ export {
|
|||
type SerializablePlan,
|
||||
type TodoStatus,
|
||||
} from "./plan";
|
||||
export {
|
||||
type ExecuteArgs,
|
||||
ExecuteArgsSchema,
|
||||
type ExecuteResult,
|
||||
ExecuteResultSchema,
|
||||
SandboxExecuteToolUI,
|
||||
} from "./sandbox-execute";
|
||||
export {
|
||||
type ScrapeWebpageArgs,
|
||||
ScrapeWebpageArgsSchema,
|
||||
|
|
@ -98,11 +105,4 @@ export {
|
|||
SaveMemoryResultSchema,
|
||||
SaveMemoryToolUI,
|
||||
} from "./user-memory";
|
||||
export {
|
||||
type ExecuteArgs,
|
||||
ExecuteArgsSchema,
|
||||
type ExecuteResult,
|
||||
ExecuteResultSchema,
|
||||
SandboxExecuteToolUI,
|
||||
} from "./sandbox-execute";
|
||||
export { type WriteTodosData, WriteTodosSchema, WriteTodosToolUI } from "./write-todos";
|
||||
|
|
|
|||
|
|
@ -15,14 +15,10 @@ import { useCallback, useMemo, useState } from "react";
|
|||
import { z } from "zod";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleContent,
|
||||
CollapsibleTrigger,
|
||||
} from "@/components/ui/collapsible";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { getBearerToken } from "@/lib/auth-utils";
|
||||
import { BACKEND_URL } from "@/lib/env-config";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
// ============================================================================
|
||||
// Zod Schemas
|
||||
|
|
@ -75,9 +71,7 @@ function extractSandboxFiles(text: string): SandboxFile[] {
|
|||
while ((match = SANDBOX_FILE_RE.exec(text)) !== null) {
|
||||
const filePath = match[1].trim();
|
||||
if (filePath) {
|
||||
const name = filePath.includes("/")
|
||||
? filePath.split("/").pop() || filePath
|
||||
: filePath;
|
||||
const name = filePath.includes("/") ? filePath.split("/").pop() || filePath : filePath;
|
||||
files.push({ path: filePath, name });
|
||||
}
|
||||
}
|
||||
|
|
@ -86,14 +80,24 @@ function extractSandboxFiles(text: string): SandboxFile[] {
|
|||
}
|
||||
|
||||
function stripSandboxFileLines(text: string): string {
|
||||
return text.replace(/^SANDBOX_FILE:\s*.+$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
|
||||
return text
|
||||
.replace(/^SANDBOX_FILE:\s*.+$/gm, "")
|
||||
.replace(/\n{3,}/g, "\n\n")
|
||||
.trim();
|
||||
}
|
||||
|
||||
function parseExecuteResult(result: ExecuteResult): ParsedOutput {
|
||||
const raw = result.result || result.output || "";
|
||||
|
||||
if (result.error) {
|
||||
return { exitCode: null, output: result.error, displayOutput: result.error, truncated: false, isError: true, files: [] };
|
||||
return {
|
||||
exitCode: null,
|
||||
output: result.error,
|
||||
displayOutput: result.error,
|
||||
truncated: false,
|
||||
isError: true,
|
||||
files: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (result.exit_code !== undefined && result.exit_code !== null) {
|
||||
|
|
@ -127,7 +131,14 @@ function parseExecuteResult(result: ExecuteResult): ParsedOutput {
|
|||
}
|
||||
|
||||
if (raw.startsWith("Error:")) {
|
||||
return { exitCode: null, output: raw, displayOutput: raw, truncated: false, isError: true, files: [] };
|
||||
return {
|
||||
exitCode: null,
|
||||
output: raw,
|
||||
displayOutput: raw,
|
||||
truncated: false,
|
||||
isError: true,
|
||||
files: [],
|
||||
};
|
||||
}
|
||||
|
||||
const files = extractSandboxFiles(raw);
|
||||
|
|
@ -240,9 +251,7 @@ function SandboxFileDownload({ file, threadId }: { file: SandboxFile; threadId:
|
|||
)}
|
||||
<FileIcon className="size-3 text-zinc-400" />
|
||||
<span className="truncate max-w-[200px]">{file.name}</span>
|
||||
{error && (
|
||||
<span className="text-destructive text-[10px] ml-1">{error}</span>
|
||||
)}
|
||||
{error && <span className="text-destructive text-[10px] ml-1">{error}</span>}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
|
@ -270,14 +279,11 @@ function ExecuteCompleted({
|
|||
variant={success ? "secondary" : "destructive"}
|
||||
className={cn(
|
||||
"ml-auto gap-1 text-[10px] px-1.5 py-0",
|
||||
success && "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20"
|
||||
success &&
|
||||
"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20"
|
||||
)}
|
||||
>
|
||||
{success ? (
|
||||
<CheckCircle2Icon className="size-3" />
|
||||
) : (
|
||||
<XCircleIcon className="size-3" />
|
||||
)}
|
||||
{success ? <CheckCircle2Icon className="size-3" /> : <XCircleIcon className="size-3" />}
|
||||
{parsed.exitCode}
|
||||
</Badge>
|
||||
);
|
||||
|
|
@ -306,7 +312,10 @@ function ExecuteCompleted({
|
|||
{truncateCommand(command)}
|
||||
</code>
|
||||
{hasFiles && !open && (
|
||||
<Badge variant="outline" className="gap-1 text-[10px] px-1.5 py-0 border-blue-500/30 text-blue-500">
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="gap-1 text-[10px] px-1.5 py-0 border-blue-500/30 text-blue-500"
|
||||
>
|
||||
<FileIcon className="size-2.5" />
|
||||
{parsed.files.length}
|
||||
</Badge>
|
||||
|
|
@ -355,11 +364,7 @@ function ExecuteCompleted({
|
|||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{parsed.files.map((file) => (
|
||||
<SandboxFileDownload
|
||||
key={file.path}
|
||||
file={file}
|
||||
threadId={threadId}
|
||||
/>
|
||||
<SandboxFileDownload key={file.path} file={file} threadId={threadId} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -412,9 +417,4 @@ export const SandboxExecuteToolUI = makeAssistantToolUI<ExecuteArgs, ExecuteResu
|
|||
},
|
||||
});
|
||||
|
||||
export {
|
||||
ExecuteArgsSchema,
|
||||
ExecuteResultSchema,
|
||||
type ExecuteArgs,
|
||||
type ExecuteResult,
|
||||
};
|
||||
export { ExecuteArgsSchema, ExecuteResultSchema, type ExecuteArgs, type ExecuteResult };
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ function ExpandedGifOverlay({
|
|||
className="max-h-[90vh] max-w-[90vw] cursor-pointer rounded-2xl shadow-2xl"
|
||||
/>
|
||||
</motion.div>,
|
||||
document.body,
|
||||
document.body
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ const carouselItems = [
|
|||
},
|
||||
{
|
||||
title: "Search & Citation",
|
||||
description:
|
||||
"Ask questions and get cited responses from your knowledge base.",
|
||||
description: "Ask questions and get cited responses from your knowledge base.",
|
||||
src: "/homepage/hero_tutorial/BSNCGif.gif",
|
||||
},
|
||||
{
|
||||
|
|
@ -121,9 +120,7 @@ function HeroCarouselCard({
|
|||
<h3 className="truncate text-base font-semibold text-neutral-900 sm:text-xl dark:text-white">
|
||||
{title}
|
||||
</h3>
|
||||
<p className="text-sm text-neutral-500 dark:text-neutral-400">
|
||||
{description}
|
||||
</p>
|
||||
<p className="text-sm text-neutral-500 dark:text-neutral-400">{description}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
|
@ -141,11 +138,7 @@ function HeroCarouselCard({
|
|||
className="w-full rounded-lg sm:rounded-xl"
|
||||
/>
|
||||
) : frozenFrame ? (
|
||||
<img
|
||||
src={frozenFrame}
|
||||
alt={title}
|
||||
className="w-full rounded-lg sm:rounded-xl"
|
||||
/>
|
||||
<img src={frozenFrame} alt={title} className="w-full rounded-lg sm:rounded-xl" />
|
||||
) : (
|
||||
<div className="aspect-video w-full rounded-lg bg-neutral-100 sm:rounded-xl dark:bg-neutral-800" />
|
||||
)}
|
||||
|
|
@ -174,7 +167,7 @@ function HeroCarousel() {
|
|||
directionRef.current = newIndex >= activeIndex ? "forward" : "backward";
|
||||
setActiveIndex(newIndex);
|
||||
},
|
||||
[activeIndex],
|
||||
[activeIndex]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -246,7 +239,7 @@ function HeroCarousel() {
|
|||
blur: t * 6,
|
||||
};
|
||||
},
|
||||
[activeIndex, cardWidth, baseOffset, stackGap],
|
||||
[activeIndex, cardWidth, baseOffset, stackGap]
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -287,18 +280,18 @@ function HeroCarousel() {
|
|||
transition={{ duration: 0.7, ease: [0.32, 0.72, 0, 1] }}
|
||||
>
|
||||
<motion.div
|
||||
animate={{ filter: `blur(${style.blur}px)` }}
|
||||
transition={{ duration: 0.7, ease: [0.32, 0.72, 0, 1] }}
|
||||
>
|
||||
<HeroCarouselCard
|
||||
index={i}
|
||||
title={item.title}
|
||||
description={item.description}
|
||||
src={item.src}
|
||||
isActive={i === activeIndex}
|
||||
onExpandedChange={setIsGifExpanded}
|
||||
/>
|
||||
</motion.div>
|
||||
animate={{ filter: `blur(${style.blur}px)` }}
|
||||
transition={{ duration: 0.7, ease: [0.32, 0.72, 0, 1] }}
|
||||
>
|
||||
<HeroCarouselCard
|
||||
index={i}
|
||||
title={item.title}
|
||||
description={item.description}
|
||||
src={item.src}
|
||||
isActive={i === activeIndex}
|
||||
onExpandedChange={setIsGifExpanded}
|
||||
/>
|
||||
</motion.div>
|
||||
<motion.div
|
||||
className="pointer-events-none absolute inset-0 rounded-2xl bg-black sm:rounded-3xl"
|
||||
animate={{ opacity: style.overlayOpacity }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue