mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 19:06:24 +02:00
Backend: - Remove dead imports (display_image, link_preview, knowledge_base) from tools registry and __init__ - Delete orphaned elif chain (lines 784-1046) in knowledge_base.py left after asyncio.gather refactor - Add missing NotionAPIError class to notion_history.py Frontend: - Add display-image.tsx, link-preview.tsx, scrape-webpage.tsx tool UI components - Fix GeneratePodcastToolUI: add null guard for no-props render + optional chaining on status/args - Fix SaveMemoryToolUI/RecallMemoryToolUI: add null guard when rendered without props in provider - Update launch.json to use pnpm on port 3999 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { makeAssistantToolUI } from "@assistant-ui/react";
|
|
import { z } from "zod";
|
|
import { ImageIcon } from "lucide-react";
|
|
|
|
const DisplayImageArgsSchema = z.object({
|
|
url: z.string().optional(),
|
|
alt: z.string().optional(),
|
|
caption: z.string().optional(),
|
|
});
|
|
|
|
const DisplayImageResultSchema = z.object({
|
|
url: z.string().optional(),
|
|
alt: z.string().optional(),
|
|
caption: z.string().optional(),
|
|
}).passthrough();
|
|
|
|
type DisplayImageArgs = z.infer<typeof DisplayImageArgsSchema>;
|
|
type DisplayImageResult = z.infer<typeof DisplayImageResultSchema>;
|
|
|
|
export const DisplayImageToolUI = makeAssistantToolUI<DisplayImageArgs, DisplayImageResult>({
|
|
toolName: "display_image",
|
|
render: ({ args, result, status }) => {
|
|
const isLoading = status.type === "running";
|
|
const imageUrl = result?.url ?? args?.url;
|
|
const altText = result?.alt ?? args?.alt ?? "Image";
|
|
const caption = result?.caption ?? args?.caption;
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="my-3 flex items-center gap-2 rounded-lg border bg-card/60 px-4 py-3">
|
|
<ImageIcon className="size-4 animate-pulse text-muted-foreground" />
|
|
<span className="text-sm text-muted-foreground">Loading image...</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!imageUrl) return null;
|
|
|
|
return (
|
|
<div className="my-3 rounded-lg border bg-card/60 overflow-hidden">
|
|
<img
|
|
src={imageUrl}
|
|
alt={altText}
|
|
className="w-full max-h-96 object-contain"
|
|
/>
|
|
{caption && (
|
|
<p className="px-4 py-2 text-sm text-muted-foreground">{caption}</p>
|
|
)}
|
|
</div>
|
|
);
|
|
},
|
|
});
|