]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
7b674e8184d5e4788cd7497c0c37ef97e8f520f5
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { XCircle } from '@lucide/svelte';
3 import { abbreviateHome, type AgenticSection } from '$lib/utils';
4 import { toolsStore } from '$lib/stores/tools.svelte';
5 import { parseFileGlobSearchMeta } from './parsers/file-glob-search';
6 import ToolCallBlock from './ToolCallBlock.svelte';
7
8 interface Props {
9 section: AgenticSection;
10 open: boolean;
11 isStreaming: boolean;
12 onToggle?: () => void;
13 }
14
15 let { section, open, isStreaming, onToggle }: Props = $props();
16
17 const fileGlobMeta = $derived(parseFileGlobSearchMeta(section));
18 const home = $derived(toolsStore.serverHome);
19 </script>
20
21 <ToolCallBlock {section} {open} {isStreaming} meta={fileGlobMeta} {onToggle}>
22 {#snippet titleSnippet()}
23 {#if fileGlobMeta}
24 <span class="text-muted-foreground"
25 >{fileGlobMeta.include === '**' ? 'List files' : 'Search files'}&nbsp;</span
26 >
27 {#if fileGlobMeta.include !== '**'}
28 <span class="font-mono">{fileGlobMeta.include}</span>
29 {/if}
30 <span class="text-muted-foreground">&nbsp;in&nbsp;</span>
31 <span class="font-mono" title={fileGlobMeta.path}
32 >{abbreviateHome(fileGlobMeta.path, home)}</span
33 >
34 {/if}
35 {/snippet}
36
37 {#snippet children(meta, ctx)}
38 {#if ctx.isPending}
39 <div class="rounded bg-muted/20 p-2 text-xs text-muted-foreground/70 italic">
40 Searching...
41 </div>
42 {:else if meta?.errorMessage}
43 <div
44 class="flex items-start gap-2 rounded bg-red-500/10 p-2 text-xs text-red-600 italic dark:text-red-400"
45 >
46 <XCircle class="mt-0.5 h-3 w-3 shrink-0" />
47 <span>{meta.errorMessage}</span>
48 </div>
49 {:else if meta && meta.matches.length > 0}
50 <div class="max-h-96 overflow-auto">
51 {#each meta.matches as match, i (i)}
52 <div class="font-mono text-[11px] leading-relaxed whitespace-pre-wrap">{match}</div>
53 {/each}
54 </div>
55 <div class="mt-1.5 text-xs text-muted-foreground/70 italic">
56 Total matches: <span class="font-mono">{meta.totalMatches ?? meta.matches.length}</span>
57 </div>
58 {:else}
59 <div class="text-xs text-muted-foreground/70 italic">No matches</div>
60 <div class="mt-1.5 text-xs text-muted-foreground/70 italic">
61 Total matches: <span class="font-mono">{meta?.totalMatches ?? 0}</span>
62 </div>
63 {/if}
64 {/snippet}
65 </ToolCallBlock>