Skip to content

Commit a0a94c7

Browse files
committed
Show selected MCP server icons in ChatInput
1 parent acc0805 commit a0a94c7

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/lib/components/chat/ChatInput.svelte

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@
203203
// Show file upload when any mime is allowed (text always; images if multimodal)
204204
let showFileUpload = $derived(mimeTypes.length > 0);
205205
let showNoTools = $derived(!showFileUpload);
206+
let selectedServers = $derived(
207+
$allMcpServers.filter((server) => $selectedServerIds.has(server.id))
208+
);
206209
</script>
207210

208211
<div class="flex min-h-full flex-1 flex-col" onpaste={onPaste}>
@@ -382,7 +385,7 @@
382385

383386
{#if $enabledServersCount > 0}
384387
<div
385-
class="ml-2 inline-flex h-7 items-center gap-1.5 rounded-full border border-blue-500/10 bg-blue-600/10 pl-3 pr-1 text-xs font-semibold text-blue-700 dark:bg-blue-600/20 dark:text-blue-400"
388+
class="ml-2 inline-flex h-7 items-center gap-1.5 rounded-full border border-blue-500/10 bg-blue-600/10 pl-2 pr-1 text-xs font-semibold text-blue-700 dark:bg-blue-600/20 dark:text-blue-400"
386389
class:grayscale={!modelSupportsTools}
387390
class:opacity-60={!modelSupportsTools}
388391
class:cursor-help={!modelSupportsTools}
@@ -391,12 +394,28 @@
391394
: "Current model doesn’t support tools"}
392395
>
393396
<button
394-
class="cursor-pointer select-none bg-transparent p-0 leading-none text-current focus:outline-none"
397+
class="inline-flex cursor-pointer select-none items-center gap-1 bg-transparent p-0 leading-none text-current focus:outline-none"
395398
type="button"
396399
title="Manage MCP Servers"
397400
onclick={() => (isMcpManagerOpen = true)}
398401
class:line-through={!modelSupportsTools}
399402
>
403+
{#if selectedServers.length}
404+
<span class="flex items-center -space-x-1">
405+
{#each selectedServers.slice(0, 3) as server (server.id)}
406+
<img
407+
src={getMcpServerFaviconUrl(server.url)}
408+
alt=""
409+
class="size-4 rounded bg-white p-px shadow-sm ring-1 ring-black/5 dark:bg-gray-900 dark:ring-white/10"
410+
/>
411+
{/each}
412+
{#if selectedServers.length > 3}
413+
<span class="ml-1 text-[10px] font-semibold text-blue-800 dark:text-blue-200">
414+
+{selectedServers.length - 3}
415+
</span>
416+
{/if}
417+
</span>
418+
{/if}
400419
MCP ({$enabledServersCount})
401420
</button>
402421
<button

src/routes/conversation/[id]/+page.svelte

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,7 @@
287287
// final text once tools complete, while preserving any
288288
// pre‑tool streamed content when appropriate.
289289
const hadTools =
290-
messageToWriteTo.updates?.some(
291-
(u) => u.type === MessageUpdateType.Tool
292-
) ?? false;
290+
messageToWriteTo.updates?.some((u) => u.type === MessageUpdateType.Tool) ?? false;
293291
294292
if (hadTools) {
295293
const existing = messageToWriteTo.content;
@@ -316,10 +314,8 @@
316314
messageToWriteTo.content = finalText;
317315
} else {
318316
// C. Merge with a paragraph break for readability.
319-
const needsGap =
320-
!/\n\n$/.test(existing) && !/^\n/.test(finalText ?? "");
321-
messageToWriteTo.content =
322-
existing + (needsGap ? "\n\n" : "") + finalText;
317+
const needsGap = !/\n\n$/.test(existing) && !/^\n/.test(finalText ?? "");
318+
messageToWriteTo.content = existing + (needsGap ? "\n\n" : "") + finalText;
323319
}
324320
} else {
325321
messageToWriteTo.content = finalText;

0 commit comments

Comments
 (0)