2 import { parseFileGlobSearchMeta } from './parsers/file-glob-search';
3 import ToolCallBlock from './ToolCallBlock.svelte';
4 import { XCircle } from '@lucide/svelte';
5 import { toolsStore } from '$lib/stores/tools.svelte';
6 import type { AgenticSection } from '$lib/types';
7 import { abbreviateHome } from '$lib/utils';
10 section: AgenticSection;
13 onToggle?: () => void;
16 let { isStreaming, onToggle, open, section }: Props = $props();
18 const fileGlobMeta = $derived(parseFileGlobSearchMeta(section));
19 const home = $derived(toolsStore.serverHome);
22 <ToolCallBlock {section} {open} {isStreaming} meta={fileGlobMeta} {onToggle}>
23 {#snippet titleSnippet()}
25 <span class="text-muted-foreground"
26 >{fileGlobMeta.include === '**' ? 'List files' : 'Search files'} </span
28 {#if fileGlobMeta.include !== '**'}
29 <span class="font-mono">{fileGlobMeta.include}</span>
31 <span class="text-muted-foreground"> in </span>
32 <span class="font-mono" title={fileGlobMeta.path}
33 >{abbreviateHome(fileGlobMeta.path, home)}</span
38 {#snippet children(meta, ctx)}
40 <div class="rounded bg-muted/20 p-2 text-xs text-muted-foreground/70 italic">
43 {:else if meta?.errorMessage}
45 class="flex items-start gap-2 rounded bg-red-500/10 p-2 text-xs text-red-600 italic dark:text-red-400"
47 <XCircle class="mt-0.5 h-3 w-3 shrink-0" />
48 <span>{meta.errorMessage}</span>
50 {:else if meta && meta.matches.length > 0}
51 <div class="max-h-96 overflow-auto">
52 {#each meta.matches as match, i (i)}
53 <div class="font-mono text-[11px] leading-relaxed whitespace-pre-wrap">{match}</div>
56 <div class="mt-1.5 text-xs text-muted-foreground/70 italic">
57 Total matches: <span class="font-mono">{meta.totalMatches ?? meta.matches.length}</span>
60 <div class="text-xs text-muted-foreground/70 italic">No matches</div>
61 <div class="mt-1.5 text-xs text-muted-foreground/70 italic">
62 Total matches: <span class="font-mono">{meta?.totalMatches ?? 0}</span>