]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
66eb3a2ad6226902cd4de17fed84de318917ded3
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
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';
8
9 interface Props {
10 section: AgenticSection;
11 open: boolean;
12 isStreaming: boolean;
13 onToggle?: () => void;
14 }
15
16 let { isStreaming, onToggle, open, section }: Props = $props();
17
18 const fileGlobMeta = $derived(parseFileGlobSearchMeta(section));
19 const home = $derived(toolsStore.serverHome);
20 </script>
21
22 <ToolCallBlock {section} {open} {isStreaming} meta={fileGlobMeta} {onToggle}>
23 {#snippet titleSnippet()}
24 {#if fileGlobMeta}
25 <span class="text-muted-foreground"
26 >{fileGlobMeta.include === '**' ? 'List files' : 'Search files'}&nbsp;</span
27 >
28 {#if fileGlobMeta.include !== '**'}
29 <span class="font-mono">{fileGlobMeta.include}</span>
30 {/if}
31 <span class="text-muted-foreground">&nbsp;in&nbsp;</span>
32 <span class="font-mono" title={fileGlobMeta.path}
33 >{abbreviateHome(fileGlobMeta.path, home)}</span
34 >
35 {/if}
36 {/snippet}
37
38 {#snippet children(meta, ctx)}
39 {#if ctx.isPending}
40 <div class="rounded bg-muted/20 p-2 text-xs text-muted-foreground/70 italic">
41 Searching...
42 </div>
43 {:else if meta?.errorMessage}
44 <div
45 class="flex items-start gap-2 rounded bg-red-500/10 p-2 text-xs text-red-600 italic dark:text-red-400"
46 >
47 <XCircle class="mt-0.5 h-3 w-3 shrink-0" />
48 <span>{meta.errorMessage}</span>
49 </div>
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>
54 {/each}
55 </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>
58 </div>
59 {:else}
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>
63 </div>
64 {/if}
65 {/snippet}
66 </ToolCallBlock>