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:
parent
f9a1aa4e3c
commit
2d4fca4fa6
1 changed files with 905 additions and 648 deletions
|
|
@ -16,16 +16,13 @@ export interface ResourcePreviewPanelProps {
|
|||
onUnsubscribe: () => void;
|
||||
}
|
||||
|
||||
function priorityLabel(priority: number): string {
|
||||
if (priority >= 0.7) return "priority: high";
|
||||
if (priority >= 0.4) return "priority: medium";
|
||||
return "priority: low";
|
||||
}
|
||||
import type { ContentBlock } from "@modelcontextprotocol/sdk/types.js";
|
||||
|
||||
function resolveContentType(mimeType: string): "json" | "image" | "text" {
|
||||
if (mimeType === "application/json") return "json";
|
||||
if (mimeType.startsWith("image/")) return "image";
|
||||
return "text";
|
||||
function toContentBlock(content: string, mimeType: string): ContentBlock {
|
||||
if (mimeType.startsWith("image/")) {
|
||||
return { type: "image", data: content, mimeType };
|
||||
}
|
||||
return { type: "text", text: content };
|
||||
}
|
||||
|
||||
function formatLastUpdated(lastUpdated: string): string {
|
||||
|
|
@ -97,12 +94,7 @@ export function ResourcePreviewPanel({
|
|||
<CopyButton value={uri} />
|
||||
</UriGroup>
|
||||
</HeaderRow>
|
||||
<ContentViewer
|
||||
type={resolveContentType(mimeType)}
|
||||
content={content}
|
||||
mimeType={mimeType}
|
||||
copyable
|
||||
/>
|
||||
<ContentViewer block={toContentBlock(content, mimeType)} copyable />
|
||||
<MetaRow>
|
||||
{lastUpdated ? (
|
||||
<TimestampText>{formatLastUpdated(lastUpdated)}</TimestampText>
|
||||
|
|
@ -114,13 +106,15 @@ export function ResourcePreviewPanel({
|
|||
<FooterRow>
|
||||
<AnnotationGroup>
|
||||
{annotations?.audience && (
|
||||
<AnnotationBadge label={annotations.audience} variant="audience" />
|
||||
<AnnotationBadge
|
||||
facet="audience"
|
||||
value={
|
||||
annotations.audience.split(", ") as ("user" | "assistant")[]
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{annotations?.priority !== undefined && (
|
||||
<AnnotationBadge
|
||||
label={priorityLabel(annotations.priority)}
|
||||
variant="priority"
|
||||
/>
|
||||
<AnnotationBadge facet="priority" value={annotations.priority} />
|
||||
)}
|
||||
</AnnotationGroup>
|
||||
<ActionGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue