chore: address copilot comments

This commit is contained in:
Dustin Healy 2025-12-04 14:39:16 -08:00
parent 649036903f
commit 62395f8dc1
5 changed files with 14 additions and 13 deletions

View file

@ -56,7 +56,7 @@ export function MCPUIResource(props: MCPUIResourceProps) {
console.error('Error rendering UI resource:', error); console.error('Error rendering UI resource:', error);
return ( return (
<span className="inline-flex items-center rounded bg-red-50 px-2 py-1 text-xs font-medium text-red-600"> <span className="inline-flex items-center rounded bg-red-50 px-2 py-1 text-xs font-medium text-red-600">
{localize('com_ui_ui_resource_error', { 0: uiResource.name })} {localize('com_ui_ui_resource_error', { 0: uiResource.name || resourceId })}
</span> </span>
); );
} }

View file

@ -19,7 +19,7 @@ interface ShareMessagesProviderProps {
export function ShareMessagesProvider({ messages, children }: ShareMessagesProviderProps) { export function ShareMessagesProvider({ messages, children }: ShareMessagesProviderProps) {
const contextValue = useMemo<MessagesViewContextValue>( const contextValue = useMemo<MessagesViewContextValue>(
() => ({ () => ({
conversation: { conversationId: 'shared-conversation' }, conversation: null,
conversationId: undefined, conversationId: undefined,
// These are required by the context but not used in share view // These are required by the context but not used in share view
ask: () => Promise.resolve(), ask: () => Promise.resolve(),

View file

@ -30,7 +30,7 @@ const conversationAttachmentsSelector = selectorFamily<
// Filter to only include attachments for this conversation // Filter to only include attachments for this conversation
Object.entries(attachmentsMap).forEach(([messageId, attachments]) => { Object.entries(attachmentsMap).forEach(([messageId, attachments]) => {
if (!attachments) { if (!attachments || attachments.length === 0) {
return; return;
} }

View file

@ -1,4 +1,7 @@
import React from 'react'; import React from 'react';
import type { UIActionResult } from '@mcp-ui/client';
import { TAskFunction } from '~/common';
import logger from './logger';
export * from './map'; export * from './map';
export * from './json'; export * from './json';
@ -125,7 +128,7 @@ export const normalizeLayout = (layout: number[]) => {
return normalizedLayout; return normalizedLayout;
}; };
export const handleUIAction = async (result: any, ask: any) => { export const handleUIAction = async (result: UIActionResult, ask: TAskFunction) => {
const supportedTypes = ['intent', 'tool', 'prompt']; const supportedTypes = ['intent', 'tool', 'prompt'];
const { type, payload } = result; 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); logger.debug('MCP-UI', 'About to submit message:', messageText);
ask({ text: messageText });
try { logger.debug('MCP-UI', 'Message submitted successfully');
await ask({ text: messageText });
console.log('Message submitted successfully');
} catch (error) {
console.error('Error submitting message:', error);
}
}; };

View file

@ -141,7 +141,10 @@ export function formatToolContent(
const resourceText: string[] = []; const resourceText: string[] = [];
if (isUiResource) { 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 resourceId = generateResourceId(contentToHash);
const uiResource: UIResource = { const uiResource: UIResource = {
...item.resource, ...item.resource,