diff --git a/client/src/components/MCPUIResource/MCPUIResource.tsx b/client/src/components/MCPUIResource/MCPUIResource.tsx index 785bfac234..d3385b3f0a 100644 --- a/client/src/components/MCPUIResource/MCPUIResource.tsx +++ b/client/src/components/MCPUIResource/MCPUIResource.tsx @@ -56,7 +56,7 @@ export function MCPUIResource(props: MCPUIResourceProps) { console.error('Error rendering UI resource:', error); return ( - {localize('com_ui_ui_resource_error', { 0: uiResource.name })} + {localize('com_ui_ui_resource_error', { 0: uiResource.name || resourceId })} ); } diff --git a/client/src/components/Share/ShareMessagesProvider.tsx b/client/src/components/Share/ShareMessagesProvider.tsx index 8fec3573c1..25848849b8 100644 --- a/client/src/components/Share/ShareMessagesProvider.tsx +++ b/client/src/components/Share/ShareMessagesProvider.tsx @@ -19,7 +19,7 @@ interface ShareMessagesProviderProps { export function ShareMessagesProvider({ messages, children }: ShareMessagesProviderProps) { const contextValue = useMemo( () => ({ - conversation: { conversationId: 'shared-conversation' }, + conversation: null, conversationId: undefined, // These are required by the context but not used in share view ask: () => Promise.resolve(), diff --git a/client/src/store/misc.ts b/client/src/store/misc.ts index 5b649cbe02..7bd571eaca 100644 --- a/client/src/store/misc.ts +++ b/client/src/store/misc.ts @@ -30,7 +30,7 @@ const conversationAttachmentsSelector = selectorFamily< // Filter to only include attachments for this conversation Object.entries(attachmentsMap).forEach(([messageId, attachments]) => { - if (!attachments) { + if (!attachments || attachments.length === 0) { return; } diff --git a/client/src/utils/index.ts b/client/src/utils/index.ts index 41ed7f9c37..4af034fedd 100644 --- a/client/src/utils/index.ts +++ b/client/src/utils/index.ts @@ -1,4 +1,7 @@ import React from 'react'; +import type { UIActionResult } from '@mcp-ui/client'; +import { TAskFunction } from '~/common'; +import logger from './logger'; export * from './map'; export * from './json'; @@ -125,7 +128,7 @@ export const normalizeLayout = (layout: number[]) => { return normalizedLayout; }; -export const handleUIAction = async (result: any, ask: any) => { +export const handleUIAction = async (result: UIActionResult, ask: TAskFunction) => { const supportedTypes = ['intent', 'tool', 'prompt']; const { type, payload } = result; @@ -171,12 +174,7 @@ Execute the intention of the prompt that is mentioned in the message using the t `; } - console.log('About to submit message:', messageText); - - try { - await ask({ text: messageText }); - console.log('Message submitted successfully'); - } catch (error) { - console.error('Error submitting message:', error); - } + logger.debug('MCP-UI', 'About to submit message:', messageText); + ask({ text: messageText }); + logger.debug('MCP-UI', 'Message submitted successfully'); }; diff --git a/packages/api/src/mcp/parsers.ts b/packages/api/src/mcp/parsers.ts index edd0f3ed10..1087fd6e9a 100644 --- a/packages/api/src/mcp/parsers.ts +++ b/packages/api/src/mcp/parsers.ts @@ -141,7 +141,10 @@ export function formatToolContent( const resourceText: string[] = []; if (isUiResource) { - const contentToHash = item.resource.text || item.resource.uri || ''; + const contentToHash = + item.resource.text && typeof item.resource.text === 'string' + ? item.resource.text + : item.resource.uri; const resourceId = generateResourceId(contentToHash); const uiResource: UIResource = { ...item.resource,