mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-06 16:04:37 +00:00
* ui: replace per-conversation MCP overrides with per-conversation tool policy MCP server enabled state is now global (server.enabled); per-conversation control moves to disabled tool keys and categories seeded into each new conversation. Aligns the add sheet with the dropdown options and flattens MCP tool groups in the tools submenu. Assisted-by: pi * ui: keep tool policy migration running when defaults parse fails A corrupt disabledToolKeys localStorage entry no longer aborts the migration; it falls through with empty defaults so legacy MCP server overrides still get converted. Assisted-by: pi * ui: fall back to global defaults when agentic flow has no tool policy Passing empty disabled sets bypassed the global defaults and could enable tools for callers that do not pass a policy yet. Assisted-by: pi * ui: align preferences section headers with their methods The Reasoning Effort and Working Directory headers sat above tool policy methods; move them above setCwd and setReasoningEffort. Also clarify the disabled tools JSDoc: existing rows with an unset field have an empty policy, defaults apply only when there is no active conversation. Assisted-by: pi * ui: gate MCP server avatars on conversation tool policy Servers whose tools are disabled for the current conversation (MCP category or server-scoped key) no longer show as enabled for the chat. Assisted-by: pi * ui: drop unused MCP category toggle from tools panel hook Per-conversation MCP control is server-granular; no component renders a whole-category toggle, so remove the dead API. Assisted-by: pi * ui: skip MCP init when flow policy disables the MCP category Resolve the effective tool policy before deciding whether to initialize MCP so flows that will not send any MCP tools skip the init work. Callers without a policy keep falling back to global defaults. Assisted-by: pi * chore: format * ui: restore reasoning section in mobile add sheet The sheet rewrite dropped it; the desktop dropdown still has it. MCP Prompts and Resources stay out of the sheet on purpose. Assisted-by: pi * ui: clear MCP server group key in enableAllToolsForServer The group key disables every tool of the server regardless of per-tool keys, so re-enabling a server from Settings did nothing while it was set. Assisted-by: pi * ui: skip MCP init when no policy-enabled server remains Extends the category-level check: the flow also skips MCP init when every globally-enabled server has its server-scoped group key disabled in the tool policy. Assisted-by: pi * ui: make Settings tools tab edit defaults with category toggles Adds per-category checkboxes and a caption stating the tab applies to new conversations; tool picks inside a chat only affect that chat. Assisted-by: pi * ui: gate cwd picker and mention picker on effective tool policy Both checked the global disabled set directly, so a conversation that disabled file_search still showed search as available. Assisted-by: pi * ui: clean up tool key helpers and store docs Documents getEnabledToolsForLLM properly, unstacks the JSDoc at isEntryEnabled, makes setToolEnabled persist like setCategoryEnabled (toggleTool now delegates to it), and routes the serverId-less MCP branch of toolKey through getMcpServerToolsKey so both key formats come from one place. Preferences banner comments become plain comments so they no longer read as class member docs. Assisted-by: pi * ui: indeterminate group checkboxes and inert grayed rows A category that is on with nothing enabled under it now shows the mixed checkbox state instead of a checked box next to 0/N. Rows grayed out by a disabled parent no longer stay clickable behind opacity. Assisted-by: pi * ui: gate MCP prompt and resource capabilities on tool policy hasPromptsCapability and hasResourcesCapability accept an optional set of usable server ids; ChatFormActions resolves it from global enablement minus the active conversation's policy. Restores the per-chat gating the old mcpServerOverrides provided; callers without arguments keep global behavior. Assisted-by: pi * ui: remove unmounted MCP submenu component Never rendered anywhere; its entries are duplicates (prompts and resources live in the attachment menu, servers in the add menu and sheet) that would need capability wiring maintained for nothing. Assisted-by: pi * ui: fix model information dialog width on all screen sizes The dialog sets container-type: inline-size, so auto width ignores its contents and collapses to padding. Give it an explicit viewport width on mobile and cap at 60rem on desktop. Assisted-by: pi * ui: scroll wide chat template in model information dialog Long unbreakable Jinja tokens blew out the table and dialog width; the block now scrolls horizontally instead of stretching. Assisted-by: pi * ui: use fixed table layout in model information dialog Auto table layout sizes columns to content min-content, so the chat template's long lines kept inflating the dialog despite the scroll wrapper. Fixed layout pins the first column and gives the value column a definite width the wrapper can scroll within. min-w-0 on the grid item guards the same path on the grid side. Assisted-by: pi * ui: make model information dialog full-screen on mobile Matches the settings dialog pattern: full viewport below md, calc-sized and capped at 60rem on desktop. Assisted-by: pi * ui: stack chat template row in model information dialog Label above the block in a single full-width cell, so the template gets the whole table width and its horizontal scroll is usable on narrow screens. Assisted-by: pi * ui: scroll model information header with the content The base dialog header is sticky; this dialog overrides it to relative so the title and description scroll away with the body. relative keeps the header as the close button's containing block. Assisted-by: pi * ui: replace literal comment text in sheet group snippet A // line inside the Svelte snippet rendered as visible text; use an HTML comment. Assisted-by: pi * ui: let indeterminate state win over checked in group checkboxes The checkbox indicator snippet renders the check icon whenever checked, so the mixed state never showed. Pass the checked prop as false while indeterminate. Assisted-by: pi * ui: initialize only policy-enabled MCP servers for a flow ensureInitialized accepts an optional server id set; the agentic flow passes the servers its tool policy leaves usable, so servers disabled for the conversation no longer get connected. Callers without arguments keep the global behavior. Assisted-by: pi * ui: derive group checkbox state in useToolsPanel Moves the mixed-state derivation out of the submenu and sheet snippets into one getGroupCheckState accessor; the snippets just consume checked and indeterminate. Assisted-by: pi * ui: gate /prompt command on the conversation tool policy The slash command's availability now follows the same rule as the agentic flow instead of the global capability check, so it disables itself when the conversation's policy leaves no usable MCP server. Assisted-by: pi * ui: remove dead MCP prompt menu trigger chain The /prompt slash command is the surviving trigger; the menu-button path (onMcpPromptClick, hasMcpPromptsSupport, showMcpPromptButton, the MCP_PROMPT attachment item and its unrendered item arrays) has no consumer left. Message display for inserted prompts is untouched. Assisted-by: pi * ui: render dash for mixed-state group checkboxes The accessor refactor dropped the checked-and-not-indeterminate guard, so the category-on flag won and the dash never showed. The tooltip keeps using the raw parent flag since clicking a mixed group still disables it. Assisted-by: pi * ui: fix group checkbox sticking checked after disable Clicking a mixed-state group box let bits-ui optimistically flip its internal checked flag; the derived checked prop did not change across the transition (both mixed and off map to checked=false), so Svelte never applied the settled value and the check icon stuck while the count already read 0/7. Pass the parent flag as checked and the mix as indeterminate, so every group toggle changes checked; render the dash on top of a checked box for the mixed state. Assisted-by: pi * fix: UI for Model Information dialog * ui: keep MCP connections stable across policy switches ensureInitialized folds the policy into its config signature, so alternating two conversations with different policies tore down and reconnected every server with health checks included. Tool collection already filters by the flow policy, so initialize every settings-enabled server instead and never pass a policy into the MCP config. The duplicated policy-server check becomes one accessor on ConversationPreferences. Assisted-by: pi * ui: remove dead MCP resources menu trigger chain Same shape as the earlier prompt trigger cleanup: nothing renders the MCP resources menu button, and the only live entry into resource browsing is Settings > MCP Servers plus the attachment resource picker. Drop onMcpResourcesClick, hasMcpResourcesSupport, MCP_RESOURCES_CLICK, the AttachmentItemVisibleWhen enum and hasResourcesCapability; the resources display, browser and picker components are untouched. Assisted-by: pi
369 lines
11 KiB
Svelte
369 lines
11 KiB
Svelte
<script lang="ts">
|
|
import { ActionIconCopyToClipboard, BadgesModality } from '$lib/components/app';
|
|
import * as Dialog from '$lib/components/ui/dialog';
|
|
import * as Table from '$lib/components/ui/table';
|
|
import { modelsStore, serverStore } from '$lib/stores';
|
|
import type { ApiLlamaCppServerProps } from '$lib/types';
|
|
import { formatFileSize, formatNumber, formatParameters } from '$lib/utils';
|
|
|
|
interface Props {
|
|
open?: boolean;
|
|
onOpenChange?: (open: boolean) => void;
|
|
// when set, fetch props from the child process (router mode)
|
|
modelId?: string | null;
|
|
}
|
|
|
|
let { modelId = null, onOpenChange, open = $bindable() }: Props = $props();
|
|
|
|
let isRouter = $derived(serverStore.isRouterMode);
|
|
|
|
// per-model props fetched from the child process
|
|
let routerModelProps = $state<ApiLlamaCppServerProps | null>(null);
|
|
let isLoadingRouterProps = $state(false);
|
|
|
|
// in router mode use per-model props, otherwise use global props
|
|
let serverProps = $derived(isRouter && modelId ? routerModelProps : serverStore.props);
|
|
|
|
let modelName = $derived(isRouter && modelId ? modelId : modelsStore.singleModelName);
|
|
let models = $derived(modelsStore.models);
|
|
let isLoadingModels = $derived(modelsStore.loading);
|
|
|
|
// in router mode, find the model option matching modelId
|
|
// in single mode, use the first model as before
|
|
let firstModel = $derived.by(() => {
|
|
if (isRouter && modelId) {
|
|
return models.find((m) => m.model === modelId) ?? null;
|
|
}
|
|
|
|
return models[0] ?? null;
|
|
});
|
|
|
|
// Get modalities from modelStore using the model ID from the first model
|
|
let modalities = $derived.by(() => {
|
|
if (!firstModel?.id) return [];
|
|
|
|
return modelsStore.props.getModelModalitiesArray(firstModel.id);
|
|
});
|
|
|
|
// Ensure models are fetched when dialog opens
|
|
$effect(() => {
|
|
if (open && models.length === 0) {
|
|
modelsStore.fetch();
|
|
}
|
|
});
|
|
|
|
// fetch per-model props from child process when dialog opens in router mode
|
|
$effect(() => {
|
|
if (open && isRouter && modelId) {
|
|
isLoadingRouterProps = true;
|
|
modelsStore.props
|
|
.fetchModelProps(modelId)
|
|
.then((props) => {
|
|
routerModelProps = props;
|
|
})
|
|
.catch(() => {
|
|
routerModelProps = null;
|
|
})
|
|
.finally(() => {
|
|
isLoadingRouterProps = false;
|
|
});
|
|
}
|
|
|
|
if (!open) {
|
|
routerModelProps = null;
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<Dialog.Root bind:open {onOpenChange}>
|
|
<Dialog.Content
|
|
class="z-9999 max-md:h-[100dvh]! max-md:w-screen! max-md:max-w-none! md:w-[calc(100vw-4rem)]! md:max-w-[60rem]! md:max-h-[80dvh]!"
|
|
>
|
|
<!-- sticky header holds only the close button; the title scrolls with the body -->
|
|
<Dialog.Header />
|
|
|
|
<div class="min-w-0 space-y-6 md:py-4 -mt-4! md:mt-0 pb-4">
|
|
<div class="min-w-0 space-y-2">
|
|
<Dialog.Title>Model Information</Dialog.Title>
|
|
|
|
<Dialog.Description>Current model details and capabilities</Dialog.Description>
|
|
</div>
|
|
|
|
{#if isLoadingModels || isLoadingRouterProps}
|
|
<div class="flex items-center justify-center py-8">
|
|
<div class="text-sm text-muted-foreground">Loading model information...</div>
|
|
</div>
|
|
{:else if firstModel}
|
|
{@const modelMeta = firstModel.meta}
|
|
|
|
{#if serverProps}
|
|
<!-- Desktop: fixed-layout table, long values scroll inside their cell -->
|
|
<Table.Root class="hidden table-fixed md:table">
|
|
<Table.Header>
|
|
<Table.Row>
|
|
<Table.Head class="w-[10rem]">Model</Table.Head>
|
|
|
|
<Table.Head>
|
|
<div class="flex min-w-0 items-center gap-2">
|
|
<span class="min-w-0 flex-1 overflow-x-auto whitespace-nowrap">
|
|
{modelName}
|
|
</span>
|
|
|
|
<ActionIconCopyToClipboard
|
|
ariaLabel="Copy model name to clipboard"
|
|
canCopy={!!modelName}
|
|
text={modelName || ''}
|
|
/>
|
|
</div>
|
|
</Table.Head>
|
|
</Table.Row>
|
|
</Table.Header>
|
|
|
|
<Table.Body>
|
|
<!-- Model Path -->
|
|
<Table.Row>
|
|
<Table.Cell class="h-10 align-middle font-medium">File Path</Table.Cell>
|
|
|
|
<Table.Cell class="h-10 align-middle font-mono text-xs">
|
|
<div class="flex min-w-0 items-center gap-2">
|
|
<span class="min-w-0 flex-1 overflow-x-auto whitespace-nowrap">
|
|
{serverProps.model_path}
|
|
</span>
|
|
|
|
<ActionIconCopyToClipboard
|
|
ariaLabel="Copy model path to clipboard"
|
|
text={serverProps.model_path}
|
|
/>
|
|
</div>
|
|
</Table.Cell>
|
|
</Table.Row>
|
|
|
|
<!-- Context Size -->
|
|
{#if serverProps?.default_generation_settings?.n_ctx}
|
|
<Table.Row>
|
|
<Table.Cell class="h-10 align-middle font-medium">Context Size</Table.Cell>
|
|
|
|
<Table.Cell
|
|
>{formatNumber(serverProps.default_generation_settings.n_ctx)} tokens</Table.Cell
|
|
>
|
|
</Table.Row>
|
|
{:else}
|
|
<Table.Row>
|
|
<Table.Cell class="h-10 align-middle font-medium text-red-500"
|
|
>Context Size</Table.Cell
|
|
>
|
|
|
|
<Table.Cell class="text-red-500">Not available</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Training Context -->
|
|
{#if modelMeta?.n_ctx_train}
|
|
<Table.Row>
|
|
<Table.Cell class="h-10 align-middle font-medium">Training Context</Table.Cell>
|
|
|
|
<Table.Cell>{formatNumber(modelMeta.n_ctx_train)} tokens</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Model Size -->
|
|
{#if modelMeta?.size}
|
|
<Table.Row>
|
|
<Table.Cell class="h-10 align-middle font-medium">Model Size</Table.Cell>
|
|
|
|
<Table.Cell>{formatFileSize(modelMeta.size)}</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Parameters -->
|
|
{#if modelMeta?.n_params}
|
|
<Table.Row>
|
|
<Table.Cell class="h-10 align-middle font-medium">Parameters</Table.Cell>
|
|
|
|
<Table.Cell>{formatParameters(modelMeta.n_params)}</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Embedding Size -->
|
|
{#if modelMeta?.n_embd}
|
|
<Table.Row>
|
|
<Table.Cell class="align-middle font-medium">Embedding Size</Table.Cell>
|
|
|
|
<Table.Cell>{formatNumber(modelMeta.n_embd)}</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Vocabulary Size -->
|
|
{#if modelMeta?.n_vocab}
|
|
<Table.Row>
|
|
<Table.Cell class="align-middle font-medium">Vocabulary Size</Table.Cell>
|
|
|
|
<Table.Cell>{formatNumber(modelMeta.n_vocab)} tokens</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Vocabulary Type -->
|
|
{#if modelMeta?.vocab_type}
|
|
<Table.Row>
|
|
<Table.Cell class="align-middle font-medium">Vocabulary Type</Table.Cell>
|
|
|
|
<Table.Cell class="align-middle capitalize">{modelMeta.vocab_type}</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Total Slots -->
|
|
<Table.Row>
|
|
<Table.Cell class="align-middle font-medium">Parallel Slots</Table.Cell>
|
|
|
|
<Table.Cell>{serverProps.total_slots}</Table.Cell>
|
|
</Table.Row>
|
|
|
|
<!-- Modalities -->
|
|
{#if modalities.length > 0}
|
|
<Table.Row>
|
|
<Table.Cell class="align-middle font-medium">Modalities</Table.Cell>
|
|
|
|
<Table.Cell>
|
|
<div class="flex flex-wrap gap-1">
|
|
<BadgesModality {modalities} />
|
|
</div>
|
|
</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
|
|
<!-- Build Info -->
|
|
<Table.Row>
|
|
<Table.Cell class="align-middle font-medium">Build Info</Table.Cell>
|
|
|
|
<Table.Cell class="align-middle font-mono text-xs"
|
|
>{serverProps.build_info}</Table.Cell
|
|
>
|
|
</Table.Row>
|
|
|
|
<!-- Chat Template -->
|
|
{#if serverProps.chat_template}
|
|
<Table.Row>
|
|
<Table.Cell class="py-4" colspan={2}>
|
|
<div class="flex flex-col gap-2">
|
|
<span class="font-medium">Chat Template</span>
|
|
|
|
<div class="overflow-x-auto rounded-md bg-muted p-4">
|
|
<pre
|
|
class="font-mono text-xs whitespace-pre">{serverProps.chat_template}</pre>
|
|
</div>
|
|
</div>
|
|
</Table.Cell>
|
|
</Table.Row>
|
|
{/if}
|
|
</Table.Body>
|
|
</Table.Root>
|
|
|
|
<!-- Mobile: stacked layout; long values wrap instead of scrolling the page -->
|
|
<div class="flex min-w-0 flex-col gap-4 md:hidden">
|
|
<div class="min-w-0 space-y-1">
|
|
<div class="text-xs font-medium text-muted-foreground">Model</div>
|
|
|
|
<div class="flex min-w-0 items-start gap-2">
|
|
<span class="min-w-0 flex-1 break-all font-mono text-xs">{modelName}</span>
|
|
|
|
<ActionIconCopyToClipboard
|
|
ariaLabel="Copy model name to clipboard"
|
|
canCopy={!!modelName}
|
|
text={modelName || ''}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="min-w-0 space-y-1">
|
|
<div class="text-xs font-medium text-muted-foreground">File Path</div>
|
|
|
|
<div class="flex min-w-0 items-start gap-2">
|
|
<span class="min-w-0 flex-1 break-all font-mono text-xs"
|
|
>{serverProps.model_path}</span
|
|
>
|
|
|
|
<ActionIconCopyToClipboard
|
|
ariaLabel="Copy model path to clipboard"
|
|
text={serverProps.model_path}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
{#if serverProps?.default_generation_settings?.n_ctx}
|
|
{@render infoRow(
|
|
'Context Size',
|
|
`${formatNumber(serverProps.default_generation_settings.n_ctx)} tokens`
|
|
)}
|
|
{:else}
|
|
{@render infoRow('Context Size', 'Not available', 'text-red-500')}
|
|
{/if}
|
|
|
|
{#if modelMeta?.n_ctx_train}
|
|
{@render infoRow('Training Context', `${formatNumber(modelMeta.n_ctx_train)} tokens`)}
|
|
{/if}
|
|
|
|
{#if modelMeta?.size}
|
|
{@render infoRow('Model Size', formatFileSize(modelMeta.size))}
|
|
{/if}
|
|
|
|
{#if modelMeta?.n_params}
|
|
{@render infoRow('Parameters', formatParameters(modelMeta.n_params))}
|
|
{/if}
|
|
|
|
{#if modelMeta?.n_embd}
|
|
{@render infoRow('Embedding Size', formatNumber(modelMeta.n_embd))}
|
|
{/if}
|
|
|
|
{#if modelMeta?.n_vocab}
|
|
{@render infoRow('Vocabulary Size', `${formatNumber(modelMeta.n_vocab)} tokens`)}
|
|
{/if}
|
|
|
|
{#if modelMeta?.vocab_type}
|
|
{@render infoRow('Vocabulary Type', modelMeta.vocab_type, 'capitalize')}
|
|
{/if}
|
|
|
|
{@render infoRow('Parallel Slots', `${serverProps.total_slots}`)}
|
|
|
|
{#if modalities.length > 0}
|
|
<div class="min-w-0 space-y-1">
|
|
<div class="text-xs font-medium text-muted-foreground">Modalities</div>
|
|
|
|
<div class="flex flex-wrap gap-1">
|
|
<BadgesModality {modalities} />
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
<div class="min-w-0 space-y-1">
|
|
<div class="text-xs font-medium text-muted-foreground">Build Info</div>
|
|
|
|
<span class="block break-all font-mono text-xs">{serverProps.build_info}</span>
|
|
</div>
|
|
|
|
{#if serverProps.chat_template}
|
|
<div class="min-w-0 space-y-2">
|
|
<div class="text-xs font-medium text-muted-foreground">Chat Template</div>
|
|
|
|
<div class="overflow-x-auto rounded-md bg-muted p-4">
|
|
<pre class="font-mono text-xs whitespace-pre">{serverProps.chat_template}</pre>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
{:else if !isLoadingModels}
|
|
<div class="flex items-center justify-center py-8">
|
|
<div class="text-sm text-muted-foreground">No model information available</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</Dialog.Content>
|
|
</Dialog.Root>
|
|
|
|
{#snippet infoRow(label: string, value: string, valueClass: string = '')}
|
|
<div class="flex items-center justify-between gap-3">
|
|
<span class="shrink-0 text-xs font-medium text-muted-foreground {valueClass}">{label}</span>
|
|
|
|
<span class="text-sm {valueClass}">{value}</span>
|
|
</div>
|
|
{/snippet}
|