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

@ -6,7 +6,8 @@ const meta: Meta<typeof ConnectionToggle> = {
title: "Elements/ConnectionToggle",
component: ConnectionToggle,
args: {
onChange: fn(),
onConnect: fn(),
onDisconnect: fn(),
},
};
@ -15,32 +16,31 @@ type Story = StoryObj<typeof ConnectionToggle>;
export const Connected: Story = {
args: {
checked: true,
loading: false,
disabled: false,
status: "connected",
},
};
export const Disconnected: Story = {
args: {
checked: false,
loading: false,
disabled: false,
status: "disconnected",
},
};
export const Loading: Story = {
export const Connecting: Story = {
args: {
checked: false,
loading: true,
disabled: false,
status: "connecting",
},
};
export const Disabled: Story = {
args: {
checked: false,
loading: false,
status: "disconnected",
disabled: true,
},
};
export const Error: Story = {
args: {
status: "error",
},
};

View file

@ -1,24 +1,34 @@
import { Switch } from "@mantine/core";
import type { ConnectionStatus } from "@inspector/core/mcp/types.js";
export interface ConnectionToggleProps {
checked: boolean;
loading: boolean;
disabled: boolean;
onChange: (checked: boolean) => void;
status: ConnectionStatus;
disabled?: boolean;
onConnect: () => void;
onDisconnect: () => void;
}
export function ConnectionToggle({
checked,
loading,
disabled,
onChange,
status,
disabled = false,
onConnect,
onDisconnect,
}: ConnectionToggleProps) {
const isConnected = status === "connected";
const isConnecting = status === "connecting";
return (
<Switch
size="lg"
checked={checked || loading}
disabled={disabled || loading}
onChange={(event) => onChange(event.currentTarget.checked)}
checked={isConnected || isConnecting}
disabled={disabled || isConnecting}
onChange={(event) => {
if (event.currentTarget.checked) {
onConnect();
} else {
onDisconnect();
}
}}
/>
);
}