Phase 1: Refactor all 16 element component interfaces to use MCP SDK types

Replace ad-hoc local type definitions in element components with real
MCP SDK types and Inspector wrapper types from core/mcp/types.ts:

Schema-typed primitives:
- LogLevelBadge: LogLevel → LoggingLevel (SDK)
- TransportBadge: "stdio"|"http" → ServerType (core), add sse/streamable-http
- TaskStatusBadge: local TaskStatus → SDK TaskStatus (working/input_required/...)
- ServerStatusIndicator: inline union → ConnectionStatus (core), "failed"→"error"

MCP wrapper consumers:
- AnnotationBadge: label+variant → facet+value with SDK Role type
- CapabilityItem: name:string → capability:keyof ServerCapabilities|ClientCapabilities
- LogEntry: flat props → entry:{receivedAt:Date, params:LoggingMessageNotification["params"]}
- MessageBubble: flat props → message:SamplingMessage|PromptMessage
- ProgressDisplay: flat props → params:ProgressNotification["params"]

Composite-input elements:
- ContentViewer: type+content+mimeType → block:ContentBlock (SDK discriminated union)
- InlineError: message+details → error:{message,data?}
- ConnectionToggle: checked+loading+onChange → status:ConnectionStatus+onConnect/onDisconnect

Also updates all group/screen/view consumers to keep the build green,
and renames CSS variable --inspector-status-failed → --inspector-status-error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-16 22:25:23 -04:00
commit 2d4fca4fa6
2 changed files with 905 additions and 648 deletions

View file

@ -16,7 +16,10 @@ export const SingleMessage: Story = {
messages: [
{
role: "user",
content: "What is the capital of France?",
content: {
type: "text",
text: "What is the capital of France?",
},
},
],
},
@ -28,12 +31,17 @@ export const Conversation: Story = {
messages: [
{
role: "user",
content: "What is the capital of France?",
content: {
type: "text",
text: "What is the capital of France?",
},
},
{
role: "assistant",
content:
"The capital of France is Paris. It is the largest city in France and serves as the country's political, economic, and cultural center.",
content: {
type: "text",
text: "The capital of France is Paris. It is the largest city in France and serves as the country's political, economic, and cultural center.",
},
},
],
},
@ -44,11 +52,17 @@ export const WithImage: Story = {
messages: [
{
role: "user",
content: "Here is a photo for you to analyze.",
imageContent: {
data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
mimeType: "image/png",
},
content: [
{
type: "text",
text: "Here is a photo for you to analyze.",
},
{
type: "image",
data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
mimeType: "image/png",
},
],
},
],
},
@ -60,25 +74,38 @@ export const LongConversation: Story = {
messages: [
{
role: "user",
content: "Can you help me write a haiku about programming?",
content: {
type: "text",
text: "Can you help me write a haiku about programming?",
},
},
{
role: "assistant",
content:
"Sure! Here is a haiku about programming:\n\nSilent keys tap fast\nLogic flows through glowing screens\nBugs hide in the code",
content: {
type: "text",
text: "Sure! Here is a haiku about programming:\n\nSilent keys tap fast\nLogic flows through glowing screens\nBugs hide in the code",
},
},
{
role: "user",
content: "That is great! Can you write another one about debugging?",
content: {
type: "text",
text: "That is great! Can you write another one about debugging?",
},
},
{
role: "assistant",
content:
"Here is a debugging haiku:\n\nStack trace lines scroll down\nOne missing semicolon\nHours lost to a typo",
content: {
type: "text",
text: "Here is a debugging haiku:\n\nStack trace lines scroll down\nOne missing semicolon\nHours lost to a typo",
},
},
{
role: "user",
content: "I love it! One more about open source?",
content: {
type: "text",
text: "I love it! One more about open source?",
},
},
],
},

View file

@ -1,20 +1,17 @@
import { Button, Group, Stack, Text, Title } from "@mantine/core";
import type {
PromptMessage,
SamplingMessage,
} from "@modelcontextprotocol/sdk/types.js";
import { MessageBubble } from "../../elements/MessageBubble/MessageBubble";
export interface PromptMessage {
role: string;
content: string;
imageContent?: { data: string; mimeType: string };
audioContent?: { data: string; mimeType: string };
}
const CopyAllButton = Button.withProps({
variant: "light",
size: "sm",
});
export interface PromptMessagesDisplayProps {
messages: PromptMessage[];
messages: (PromptMessage | SamplingMessage)[];
onCopyAll?: () => void;
}
@ -34,14 +31,7 @@ export function PromptMessagesDisplay({
<Text c="dimmed">No messages to display</Text>
) : (
messages.map((message, index) => (
<MessageBubble
key={index}
index={index}
role={message.role as "user" | "assistant"}
content={message.content}
imageContent={message.imageContent}
audioContent={message.audioContent}
/>
<MessageBubble key={index} index={index} message={message} />
))
)}
</Stack>