Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions examples/remote-dom-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ function App() {
<UIResourceRenderer
key={`basic-${scriptContent}`}
resource={mockResourceReact}
library={basicComponentLibrary}
remoteElements={remoteElements}
remoteDomProps={{
library: basicComponentLibrary,
remoteElements: remoteElements,
}}
/>
</div>

Expand All @@ -163,8 +165,10 @@ function App() {
<UIResourceRenderer
key={`radix-${scriptContent}`}
resource={mockResourceReact}
library={radixComponentLibrary}
remoteElements={remoteElements}
remoteDomProps={{
library: radixComponentLibrary,
remoteElements: remoteElements,
}}
/>
</div>

Expand All @@ -180,8 +184,10 @@ function App() {
<UIResourceRenderer
key={`webcomponents-${scriptContent}`}
resource={mockResourceWebComponents}
library={basicComponentLibrary}
remoteElements={remoteElements}
remoteDomProps={{
library: basicComponentLibrary,
remoteElements: remoteElements,
}}
/>
</div>
</div>
Expand Down
23 changes: 10 additions & 13 deletions packages/client/src/components/UIResourceRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import type { Resource } from '@modelcontextprotocol/sdk/types.js';
import { ResourceContentType } from '../types';
import { ResourceContentType, UIActionResult } from '../types';
import { HTMLResourceRenderer, HTMLResourceRendererProps } from './HTMLResourceRenderer';
import { RemoteDOMResourceProps, RemoteDOMResourceRenderer } from './RemoteDOMResourceRenderer';
import { basicComponentLibrary } from '../remote-dom/component-libraries/basic';

type UIResourceRendererProps = Omit<
HTMLResourceRendererProps & RemoteDOMResourceProps,
'resource'
> & {
type UIResourceRendererProps = {
resource: Partial<Resource>;
onUIAction?: (result: UIActionResult) => Promise<unknown>;
supportedContentTypes?: ResourceContentType[];
htmlProps?: Omit<HTMLResourceRendererProps, 'resource' | 'onUIAction'>;
Comment thread
idosal marked this conversation as resolved.
remoteDomProps?: Omit<RemoteDOMResourceProps, 'resource' | 'onUIAction'>;
};

function getContentType(
Expand All @@ -35,11 +35,9 @@ export const UIResourceRenderer: React.FC<UIResourceRendererProps> = (props) =>
const {
resource,
onUIAction,
style,
iframeProps,
supportedContentTypes,
Comment thread
idosal marked this conversation as resolved.
library,
remoteElements,
htmlProps,
remoteDomProps,
} = props;
const contentType = getContentType(resource);

Expand All @@ -60,17 +58,16 @@ export const UIResourceRenderer: React.FC<UIResourceRendererProps> = (props) =>
<HTMLResourceRenderer
resource={resource}
onUIAction={onUIAction}
style={style}
iframeProps={iframeProps}
{...htmlProps}
/>
);
case 'remoteDom':
return (
<RemoteDOMResourceRenderer
resource={resource}
onUIAction={onUIAction}

Copilot AI Jul 5, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By only mapping library and remoteElements, any future props on RemoteDOMResourceProps will be ignored. Consider spreading ...remoteDomProps and then overriding library and remoteElements to preserve extensibility.

Suggested change
onUIAction={onUIAction}
onUIAction={onUIAction}
{...remoteDomProps}

Copilot uses AI. Check for mistakes.
library={library || basicComponentLibrary}
remoteElements={remoteElements}
library={remoteDomProps?.library || basicComponentLibrary}
{...remoteDomProps}
/>
);
default:
Expand Down