mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-20 01:31:31 +02:00
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
This commit is contained in:
@@ -628,7 +628,6 @@
|
|||||||
isReasoning={chatStore.isReasoning}
|
isReasoning={chatStore.isReasoning}
|
||||||
{isRecording}
|
{isRecording}
|
||||||
onFileUpload={handleFileUpload}
|
onFileUpload={handleFileUpload}
|
||||||
onMcpResourcesClick={() => (isResourceDialogOpen = true)}
|
|
||||||
onMcpSettingsClick={() => (isMcpServersDialogOpen = true)}
|
onMcpSettingsClick={() => (isMcpServersDialogOpen = true)}
|
||||||
onMicClick={handleMicClick}
|
onMicClick={handleMicClick}
|
||||||
{onStop}
|
{onStop}
|
||||||
|
|||||||
-2
@@ -30,13 +30,11 @@
|
|||||||
const attachmentMenu = useAttachmentMenu(
|
const attachmentMenu = useAttachmentMenu(
|
||||||
() => ({
|
() => ({
|
||||||
hasAudioModality: chatFormActions.hasAudioModality,
|
hasAudioModality: chatFormActions.hasAudioModality,
|
||||||
hasMcpResourcesSupport: chatFormActions.hasMcpResourcesSupport,
|
|
||||||
hasVideoModality: chatFormActions.hasVideoModality,
|
hasVideoModality: chatFormActions.hasVideoModality,
|
||||||
hasVisionModality: chatFormActions.hasVisionModality
|
hasVisionModality: chatFormActions.hasVisionModality
|
||||||
}),
|
}),
|
||||||
() => ({
|
() => ({
|
||||||
onFileUpload: chatFormActions.onFileUpload,
|
onFileUpload: chatFormActions.onFileUpload,
|
||||||
onMcpResourcesClick: chatFormActions.onMcpResourcesClick,
|
|
||||||
onSystemPromptClick: chatFormActions.onSystemPromptClick
|
onSystemPromptClick: chatFormActions.onSystemPromptClick
|
||||||
}),
|
}),
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
-2
@@ -44,13 +44,11 @@
|
|||||||
const attachmentMenu = useAttachmentMenu(
|
const attachmentMenu = useAttachmentMenu(
|
||||||
() => ({
|
() => ({
|
||||||
hasAudioModality: chatFormActions.hasAudioModality,
|
hasAudioModality: chatFormActions.hasAudioModality,
|
||||||
hasMcpResourcesSupport: chatFormActions.hasMcpResourcesSupport,
|
|
||||||
hasVideoModality: chatFormActions.hasVideoModality,
|
hasVideoModality: chatFormActions.hasVideoModality,
|
||||||
hasVisionModality: chatFormActions.hasVisionModality
|
hasVisionModality: chatFormActions.hasVisionModality
|
||||||
}),
|
}),
|
||||||
() => ({
|
() => ({
|
||||||
onFileUpload: chatFormActions.onFileUpload,
|
onFileUpload: chatFormActions.onFileUpload,
|
||||||
onMcpResourcesClick: chatFormActions.onMcpResourcesClick,
|
|
||||||
onSystemPromptClick: chatFormActions.onSystemPromptClick
|
onSystemPromptClick: chatFormActions.onSystemPromptClick
|
||||||
}),
|
}),
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
+2
-27
@@ -11,9 +11,9 @@
|
|||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { ICON_CLASS_DEFAULT } from '$lib/constants';
|
import { ICON_CLASS_DEFAULT } from '$lib/constants';
|
||||||
import { setChatFormActionsContext } from '$lib/contexts';
|
import { setChatFormActionsContext } from '$lib/contexts';
|
||||||
import { FileTypeCategory, MessageRole, ToolSource } from '$lib/enums';
|
import { FileTypeCategory, MessageRole } from '$lib/enums';
|
||||||
import { ChatService } from '$lib/services';
|
import { ChatService } from '$lib/services';
|
||||||
import { chatStore, conversationsStore, mcpStore, settingsStore } from '$lib/stores';
|
import { chatStore, conversationsStore, settingsStore } from '$lib/stores';
|
||||||
import { getFileTypeCategory } from '$lib/utils';
|
import { getFileTypeCategory } from '$lib/utils';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
onMicClick?: () => void;
|
onMicClick?: () => void;
|
||||||
onStop?: () => void;
|
onStop?: () => void;
|
||||||
onSystemPromptClick?: () => void;
|
onSystemPromptClick?: () => void;
|
||||||
onMcpResourcesClick?: () => void;
|
|
||||||
onMcpSettingsClick?: () => void;
|
onMcpSettingsClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@
|
|||||||
isReasoning = false,
|
isReasoning = false,
|
||||||
isRecording = false,
|
isRecording = false,
|
||||||
onFileUpload,
|
onFileUpload,
|
||||||
onMcpResourcesClick,
|
|
||||||
onMcpSettingsClick,
|
onMcpSettingsClick,
|
||||||
onMicClick,
|
onMicClick,
|
||||||
onStop,
|
onStop,
|
||||||
@@ -56,23 +54,6 @@
|
|||||||
|
|
||||||
let currentConfig = $derived(settingsStore.config);
|
let currentConfig = $derived(settingsStore.config);
|
||||||
|
|
||||||
// usable MCP servers for this conversation: globally enabled and not
|
|
||||||
// disabled by the effective tool policy (category or server-scoped key)
|
|
||||||
let policyEnabledMcpServerIds = $derived.by(() => {
|
|
||||||
const prefs = conversationsStore.preferences;
|
|
||||||
|
|
||||||
if (!prefs.isCategoryEnabled(ToolSource.MCP)) return new Set<string>();
|
|
||||||
|
|
||||||
return new Set(
|
|
||||||
mcpStore
|
|
||||||
.getServers()
|
|
||||||
.filter((s) => s.enabled && prefs.isServerToolsEnabled(s.id))
|
|
||||||
.map((s) => s.id)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
let hasMcpResourcesSupport = $derived(mcpStore.hasResourcesCapability(policyEnabledMcpServerIds));
|
|
||||||
|
|
||||||
let hasAudioModality = $state(false);
|
let hasAudioModality = $state(false);
|
||||||
let hasVideoModality = $state(false);
|
let hasVideoModality = $state(false);
|
||||||
let hasVisionModality = $state(false);
|
let hasVisionModality = $state(false);
|
||||||
@@ -145,9 +126,6 @@
|
|||||||
get hasAudioModality() {
|
get hasAudioModality() {
|
||||||
return hasAudioModality;
|
return hasAudioModality;
|
||||||
},
|
},
|
||||||
get hasMcpResourcesSupport() {
|
|
||||||
return hasMcpResourcesSupport;
|
|
||||||
},
|
|
||||||
get hasVideoModality() {
|
get hasVideoModality() {
|
||||||
return hasVideoModality;
|
return hasVideoModality;
|
||||||
},
|
},
|
||||||
@@ -157,9 +135,6 @@
|
|||||||
get onFileUpload() {
|
get onFileUpload() {
|
||||||
return onFileUpload;
|
return onFileUpload;
|
||||||
},
|
},
|
||||||
get onMcpResourcesClick() {
|
|
||||||
return onMcpResourcesClick;
|
|
||||||
},
|
|
||||||
get onMcpSettingsClick() {
|
get onMcpSettingsClick() {
|
||||||
return onMcpSettingsClick;
|
return onMcpSettingsClick;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export enum AttachmentType {
|
|||||||
export enum AttachmentMenuItemId {
|
export enum AttachmentMenuItemId {
|
||||||
AUDIO = 'audio',
|
AUDIO = 'audio',
|
||||||
IMAGES = 'images',
|
IMAGES = 'images',
|
||||||
MCP_RESOURCES = 'mcp-resources',
|
|
||||||
PDF = 'pdf',
|
PDF = 'pdf',
|
||||||
SYSTEM_MESSAGE = 'system-message',
|
SYSTEM_MESSAGE = 'system-message',
|
||||||
TEXT = 'text',
|
TEXT = 'text',
|
||||||
@@ -41,7 +40,6 @@ export enum AttachmentItemEnabledWhen {
|
|||||||
*/
|
*/
|
||||||
export enum AttachmentAction {
|
export enum AttachmentAction {
|
||||||
FILE_UPLOAD = 'onFileUpload',
|
FILE_UPLOAD = 'onFileUpload',
|
||||||
MCP_RESOURCES_CLICK = 'onMcpResourcesClick',
|
|
||||||
SYSTEM_PROMPT_CLICK = 'onSystemPromptClick'
|
SYSTEM_PROMPT_CLICK = 'onSystemPromptClick'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,10 +52,3 @@ export enum AttachmentLabel {
|
|||||||
MCP_RESOURCE = 'MCP Resource',
|
MCP_RESOURCE = 'MCP Resource',
|
||||||
PDF_FILE = 'PDF File'
|
PDF_FILE = 'PDF File'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Visibility conditions for attachment menu items.
|
|
||||||
*/
|
|
||||||
export enum AttachmentItemVisibleWhen {
|
|
||||||
HAS_MCP_RESOURCES_SUPPORT = 'hasMcpResourcesSupport'
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ export {
|
|||||||
AttachmentType,
|
AttachmentType,
|
||||||
AttachmentMenuItemId,
|
AttachmentMenuItemId,
|
||||||
AttachmentItemEnabledWhen,
|
AttachmentItemEnabledWhen,
|
||||||
AttachmentAction,
|
AttachmentAction
|
||||||
AttachmentItemVisibleWhen
|
|
||||||
} from './attachment.enums';
|
} from './attachment.enums';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
@@ -5,19 +5,16 @@ export interface AttachmentModalityFlags {
|
|||||||
hasVisionModality: boolean;
|
hasVisionModality: boolean;
|
||||||
hasAudioModality: boolean;
|
hasAudioModality: boolean;
|
||||||
hasVideoModality: boolean;
|
hasVideoModality: boolean;
|
||||||
hasMcpResourcesSupport: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AttachmentActionCallbacks {
|
export interface AttachmentActionCallbacks {
|
||||||
onFileUpload?: () => void;
|
onFileUpload?: () => void;
|
||||||
onSystemPromptClick?: () => void;
|
onSystemPromptClick?: () => void;
|
||||||
onMcpResourcesClick?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UseAttachmentMenuReturn {
|
export interface UseAttachmentMenuReturn {
|
||||||
readonly callbacks: Record<string, () => void>;
|
readonly callbacks: Record<string, () => void>;
|
||||||
isItemEnabled(enabledWhen: string | undefined): boolean;
|
isItemEnabled(enabledWhen: string | undefined): boolean;
|
||||||
isItemVisible(visibleWhen: string | undefined): boolean;
|
|
||||||
getSystemMessageTooltip(): string;
|
getSystemMessageTooltip(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +44,6 @@ export function useAttachmentMenu(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
[AttachmentAction.FILE_UPLOAD]: wrap(cbs.onFileUpload),
|
[AttachmentAction.FILE_UPLOAD]: wrap(cbs.onFileUpload),
|
||||||
[AttachmentAction.MCP_RESOURCES_CLICK]: wrap(cbs.onMcpResourcesClick),
|
|
||||||
[AttachmentAction.SYSTEM_PROMPT_CLICK]: wrap(cbs.onSystemPromptClick)
|
[AttachmentAction.SYSTEM_PROMPT_CLICK]: wrap(cbs.onSystemPromptClick)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -58,12 +54,6 @@ export function useAttachmentMenu(
|
|||||||
return !!modalityFlags[enabledWhen as keyof AttachmentModalityFlags];
|
return !!modalityFlags[enabledWhen as keyof AttachmentModalityFlags];
|
||||||
}
|
}
|
||||||
|
|
||||||
function isItemVisible(visibleWhen: string | undefined): boolean {
|
|
||||||
if (!visibleWhen) return true;
|
|
||||||
|
|
||||||
return !!modalityFlags[visibleWhen as keyof AttachmentModalityFlags];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSystemMessageTooltip(): string {
|
function getSystemMessageTooltip(): string {
|
||||||
return !page.params.id
|
return !page.params.id
|
||||||
? 'Add custom system message for a new conversation'
|
? 'Add custom system message for a new conversation'
|
||||||
@@ -75,7 +65,6 @@ export function useAttachmentMenu(
|
|||||||
return callbacks;
|
return callbacks;
|
||||||
},
|
},
|
||||||
getSystemMessageTooltip,
|
getSystemMessageTooltip,
|
||||||
isItemEnabled,
|
isItemEnabled
|
||||||
isItemVisible
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -811,40 +811,6 @@ class MCPStore implements McpHealthHost {
|
|||||||
return Boolean(this.buildMcpClientConfig(settingsStore.config));
|
return Boolean(this.buildMcpClientConfig(settingsStore.config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if any enabled server with successful health check supports resources.
|
|
||||||
* Uses health check state since servers may not have active connections until
|
|
||||||
* the user actually sends a message or uses prompts.
|
|
||||||
*/
|
|
||||||
hasResourcesCapability(enabledServerIds?: ReadonlySet<string>): boolean {
|
|
||||||
const ids = enabledServerIds ?? this.globalEnabledServerIds();
|
|
||||||
|
|
||||||
if (ids.size === 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const [serverId, state] of Object.entries(this.health.checks)) {
|
|
||||||
if (!ids.has(serverId)) continue;
|
|
||||||
|
|
||||||
if (
|
|
||||||
state.status === HealthCheckStatus.SUCCESS &&
|
|
||||||
state.capabilities?.server?.resources !== undefined
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const [serverName, connection] of this.connections) {
|
|
||||||
if (!ids.has(serverName)) continue;
|
|
||||||
|
|
||||||
if (MCPService.supportsResources(connection)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any connected server has instructions.
|
* Check if any connected server has instructions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
-5
@@ -3,7 +3,6 @@ import type { DatabaseMessage, DatabaseMessageExtra } from './database';
|
|||||||
import type {
|
import type {
|
||||||
AttachmentAction,
|
AttachmentAction,
|
||||||
AttachmentItemEnabledWhen,
|
AttachmentItemEnabledWhen,
|
||||||
AttachmentItemVisibleWhen,
|
|
||||||
AttachmentMenuItemId,
|
AttachmentMenuItemId,
|
||||||
ChatFormCommandAction,
|
ChatFormCommandAction,
|
||||||
ErrorDialogType,
|
ErrorDialogType,
|
||||||
@@ -30,8 +29,6 @@ export interface AttachmentMenuItem {
|
|||||||
disabledTooltip?: string;
|
disabledTooltip?: string;
|
||||||
/** Callback key on the Props interface to invoke when clicked */
|
/** Callback key on the Props interface to invoke when clicked */
|
||||||
action: AttachmentAction;
|
action: AttachmentAction;
|
||||||
/** Whether the item is only shown when a specific capability is present */
|
|
||||||
visibleWhen?: AttachmentItemVisibleWhen;
|
|
||||||
/** Whether this item has a tooltip even when enabled (uses dynamic text) */
|
/** Whether this item has a tooltip even when enabled (uses dynamic text) */
|
||||||
hasEnabledTooltip?: boolean;
|
hasEnabledTooltip?: boolean;
|
||||||
}
|
}
|
||||||
@@ -336,9 +333,7 @@ export interface ChatFormActionsContext {
|
|||||||
readonly hasAudioModality: boolean;
|
readonly hasAudioModality: boolean;
|
||||||
readonly hasVideoModality: boolean;
|
readonly hasVideoModality: boolean;
|
||||||
readonly hasVisionModality: boolean;
|
readonly hasVisionModality: boolean;
|
||||||
readonly hasMcpResourcesSupport: boolean;
|
|
||||||
onFileUpload?: () => void;
|
onFileUpload?: () => void;
|
||||||
onSystemPromptClick?: () => void;
|
onSystemPromptClick?: () => void;
|
||||||
onMcpResourcesClick?: () => void;
|
|
||||||
onMcpSettingsClick?: () => void;
|
onMcpSettingsClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user