diff --git a/web/src/components/search/search-results-panel.tsx b/web/src/components/search/search-results-panel.tsx index 8337626..d4c1b48 100644 --- a/web/src/components/search/search-results-panel.tsx +++ b/web/src/components/search/search-results-panel.tsx @@ -1,29 +1,9 @@ import { useEffect, useRef, useState } from "preact/hooks"; import { Search } from "lucide-preact"; -import type { SearchDetail, SearchResultItem } from "@/lib/api"; +import type { SearchDetail } from "@/lib/api"; import { MarkdownContent } from "@/components/markdown/markdown-content"; import { cn } from "@/lib/utils"; -function cleanResultText(input: string) { - return input - .replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "$1") - .replace(/\[\s*\]/g, " ") - .replace(/(^|\s)#{1,6}\s*/g, "$1") - .replace(/^\s*[-*+]\s+/gm, "") - .replace(/(\*\*|__|\*|_|`{1,3}|~~)/g, "") - .replace(/\r?\n+/g, " ") - .replace(/\s{2,}/g, " ") - .trim(); -} - -function summarizeResult(result: SearchResultItem) { - const highlights = Array.isArray(result.highlights) ? result.highlights.filter(Boolean) : []; - const raw = highlights.length ? highlights.join(" ") : result.text ?? ""; - const cleaned = cleanResultText(raw); - if (cleaned.length <= 680) return cleaned; - return `${cleaned.slice(0, 679).trimEnd()}…`; -} - function formatHost(url: string) { try { return new URL(url).hostname.replace(/^www\./, ""); @@ -193,7 +173,6 @@ export function SearchResultsPanel({ search, isLoading, isRunning, showPrompt =
{search?.results.map((result) => { - const summary = summarizeResult(result); return (

{formatHost(result.url)}

@@ -203,7 +182,7 @@ export function SearchResultsPanel({ search, isLoading, isRunning, showPrompt = {(result.publishedDate || result.author) && (

{[result.publishedDate, result.author].filter(Boolean).join(" • ")}

)} - {summary ?

{summary}

: null} + {result.url ?

{result.url}

: null}
); })}