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);
return (
<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>
);
}

View file

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

View file

@ -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;
}

View file

@ -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');
};

View file

@ -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,