Remove ConnectedView and UnconnectedView, superseded by InspectorView
The two prior shell views took `children` and routed connection state by having two distinct mounts. `InspectorView` collapses both into a single state-machine view that switches `ViewHeader` modes internally, so the old shells have no remaining call sites. Spec section 4 (Views) rewritten to describe `InspectorView` instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4e99e6393f
commit
0babbfa6a9
5 changed files with 35 additions and 1043 deletions
|
|
@ -1,714 +0,0 @@
|
|||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { fn } from "storybook/test";
|
||||
import { Text } from "@mantine/core";
|
||||
import { ConnectedView } from "./ConnectedView.js";
|
||||
import { ToolsScreen } from "../../screens/ToolsScreen/ToolsScreen";
|
||||
import { ResourcesScreen } from "../../screens/ResourcesScreen/ResourcesScreen";
|
||||
import { PromptsScreen } from "../../screens/PromptsScreen/PromptsScreen";
|
||||
import { LoggingScreen } from "../../screens/LoggingScreen/LoggingScreen";
|
||||
import { TasksScreen } from "../../screens/TasksScreen/TasksScreen";
|
||||
import { HistoryScreen } from "../../screens/HistoryScreen/HistoryScreen";
|
||||
|
||||
import type { LoggingLevel } from "@modelcontextprotocol/sdk/types.js";
|
||||
import type { LogEntryData } from "../../elements/LogEntry/LogEntry";
|
||||
|
||||
const allTabs = ["Tools", "Resources", "Prompts", "Logs", "Tasks", "History"];
|
||||
|
||||
const logMessages: { level: LoggingLevel; data: string; logger?: string }[] = [
|
||||
{ level: "info", data: "Server started on port 3000" },
|
||||
{
|
||||
level: "debug",
|
||||
data: "Loading configuration from /etc/mcp/config.json",
|
||||
logger: "config",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
data: "Deprecated API endpoint called: /v1/tools",
|
||||
logger: "http",
|
||||
},
|
||||
{ level: "info", data: "Client connected: inspector-web-ui" },
|
||||
{
|
||||
level: "error",
|
||||
data: "Failed to read resource: file not found at /data/missing.txt",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Tool execution completed: search_files (245ms)",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
data: "Parsing JSON-RPC request body",
|
||||
logger: "transport",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Listing available tools for client session",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
data: "Slow query detected: 1200ms for resource lookup",
|
||||
logger: "db",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Resource subscription added: file:///config.json",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
data: "Heartbeat ping received from client",
|
||||
logger: "session",
|
||||
},
|
||||
{
|
||||
level: "error",
|
||||
data: "Permission denied reading /etc/secrets.env",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Prompt 'summarize' resolved with 2 messages",
|
||||
logger: "prompts",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
data: "Cache hit for resource: db://users/42",
|
||||
logger: "cache",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Tool 'create_record' executed successfully in 89ms",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
data: "Client reconnection attempt #3",
|
||||
logger: "session",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "New resource detected: file:///data/output.csv",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
data: "Serializing response payload (2.4KB)",
|
||||
logger: "transport",
|
||||
},
|
||||
{
|
||||
level: "error",
|
||||
data: "Timeout waiting for tool response after 30s",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Session initialized with capabilities: tools, resources, prompts",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
data: "Validating input schema for tool 'batch_process'",
|
||||
logger: "tools",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Resource template resolved: db://tables/users/rows/15",
|
||||
logger: "resources",
|
||||
},
|
||||
{
|
||||
level: "warning",
|
||||
data: "Memory usage at 78% — consider increasing limits",
|
||||
logger: "system",
|
||||
},
|
||||
{
|
||||
level: "info",
|
||||
data: "Client disconnected gracefully",
|
||||
logger: "session",
|
||||
},
|
||||
{
|
||||
level: "debug",
|
||||
data: "Flushing log buffer to disk (128 entries)",
|
||||
logger: "logging",
|
||||
},
|
||||
];
|
||||
|
||||
function pad(n: number): string {
|
||||
return n.toString().padStart(2, "0");
|
||||
}
|
||||
|
||||
const sampleLogEntries: LogEntryData[] = Array.from({ length: 50 }, (_, i) => {
|
||||
const src = logMessages[i % logMessages.length];
|
||||
return {
|
||||
receivedAt: new Date(`2026-03-17T10:00:${pad(i + 1)}Z`),
|
||||
params: { level: src.level, data: src.data, logger: src.logger },
|
||||
};
|
||||
});
|
||||
|
||||
const meta: Meta<typeof ConnectedView> = {
|
||||
title: "Views/ConnectedView",
|
||||
component: ConnectedView,
|
||||
parameters: { layout: "fullscreen" },
|
||||
args: {
|
||||
serverInfo: { name: "my-mcp-server", version: "1.0.0" },
|
||||
status: "connected",
|
||||
latencyMs: 23,
|
||||
availableTabs: allTabs,
|
||||
activeTab: "Tools",
|
||||
onTabChange: fn(),
|
||||
onDisconnect: fn(),
|
||||
onToggleTheme: fn(),
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof ConnectedView>;
|
||||
|
||||
export const ToolsActive: Story = {
|
||||
args: {
|
||||
activeTab: "Tools",
|
||||
children: (
|
||||
<ToolsScreen
|
||||
tools={[
|
||||
{
|
||||
name: "send_message",
|
||||
title: "Send Message",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "create_record",
|
||||
title: "Create Record",
|
||||
description: "Creates a new record with the given parameters",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
title: { type: "string", description: "Record title" },
|
||||
count: { type: "number", description: "Number of items" },
|
||||
enabled: {
|
||||
type: "boolean",
|
||||
description: "Whether the record is active",
|
||||
},
|
||||
},
|
||||
required: ["title"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "delete_records",
|
||||
title: "Delete Records",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "list_users",
|
||||
title: "List Users",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "batch_process",
|
||||
title: "Batch Process",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "search_files",
|
||||
title: "Search Files",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "read_file",
|
||||
title: "Read File",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "write_file",
|
||||
title: "Write File",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "get_schema",
|
||||
title: "Get Schema",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "run_query",
|
||||
title: "Run Query",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "create_migration",
|
||||
title: "Create Migration",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "validate_config",
|
||||
title: "Validate Config",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "deploy_service",
|
||||
title: "Deploy Service",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "rollback_deploy",
|
||||
title: "Rollback Deploy",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "check_health",
|
||||
title: "Check Health",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "generate_report",
|
||||
title: "Generate Report",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "export_csv",
|
||||
title: "Export CSV",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "import_data",
|
||||
title: "Import Data",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "send_notification",
|
||||
title: "Send Notification",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "schedule_task",
|
||||
title: "Schedule Task",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "cancel_task",
|
||||
title: "Cancel Task",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "list_connections",
|
||||
title: "List Connections",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "refresh_cache",
|
||||
title: "Refresh Cache",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "purge_logs",
|
||||
title: "Purge Logs",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "encrypt_secret",
|
||||
title: "Encrypt Secret",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "rotate_keys",
|
||||
title: "Rotate Keys",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "sync_resources",
|
||||
title: "Sync Resources",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "compile_template",
|
||||
title: "Compile Template",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "analyze_performance",
|
||||
title: "Analyze Performance",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
{
|
||||
name: "resize_image",
|
||||
title: "Resize Image",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
]}
|
||||
selectedToolName="create_record"
|
||||
callState={{
|
||||
status: "ok",
|
||||
result: {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(
|
||||
{
|
||||
id: 42,
|
||||
title: "New Record",
|
||||
count: 5,
|
||||
enabled: true,
|
||||
createdAt: "2026-03-17T12:00:00Z",
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
}}
|
||||
listChanged={true}
|
||||
onRefreshList={fn()}
|
||||
onSelectTool={fn()}
|
||||
onCallTool={fn()}
|
||||
onCancelCall={fn()}
|
||||
onClearResult={fn()}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const ResourcesActive: Story = {
|
||||
args: {
|
||||
activeTab: "Resources",
|
||||
children: (
|
||||
<ResourcesScreen
|
||||
resources={[
|
||||
{
|
||||
name: "config.json",
|
||||
uri: "file:///config.json",
|
||||
annotations: { audience: ["user"], priority: 0.8 },
|
||||
},
|
||||
{ name: "README.md", uri: "file:///README.md" },
|
||||
{
|
||||
name: "schema.sql",
|
||||
uri: "file:///schema.sql",
|
||||
annotations: { priority: 0.5 },
|
||||
},
|
||||
{ name: "package.json", uri: "file:///package.json" },
|
||||
{ name: ".env.example", uri: "file:///.env.example" },
|
||||
{
|
||||
name: "docker-compose.yml",
|
||||
uri: "file:///docker-compose.yml",
|
||||
annotations: { priority: 0.6 },
|
||||
},
|
||||
{
|
||||
name: "migrations/001_init.sql",
|
||||
uri: "file:///migrations/001_init.sql",
|
||||
},
|
||||
{
|
||||
name: "logs/error.log",
|
||||
uri: "file:///logs/error.log",
|
||||
annotations: { priority: 0.7 },
|
||||
},
|
||||
{ name: "api-spec.yaml", uri: "file:///api-spec.yaml" },
|
||||
{ name: "Makefile", uri: "file:///Makefile" },
|
||||
]}
|
||||
templates={[
|
||||
{
|
||||
name: "User Profile",
|
||||
uriTemplate: "file:///users/{userId}/profile",
|
||||
description: "Fetch a user profile by their unique identifier.",
|
||||
},
|
||||
{
|
||||
name: "Table Row",
|
||||
title: "Database Table Row",
|
||||
uriTemplate: "db://tables/{tableName}/rows/{rowId}",
|
||||
},
|
||||
{
|
||||
name: "Log File",
|
||||
title: "Application Log",
|
||||
uriTemplate: "file:///logs/{service}/{date}.log",
|
||||
},
|
||||
]}
|
||||
subscriptions={[
|
||||
{
|
||||
resource: { name: "config.json", uri: "file:///config.json" },
|
||||
lastUpdated: new Date("2026-03-17T10:30:00Z"),
|
||||
},
|
||||
{
|
||||
resource: { name: "schema.sql", uri: "file:///schema.sql" },
|
||||
lastUpdated: new Date("2026-03-17T10:28:00Z"),
|
||||
},
|
||||
]}
|
||||
selectedTemplateUri="file:///users/{userId}/profile"
|
||||
selectedResourceUri="file:///users/42/profile"
|
||||
readState={{
|
||||
status: "ok",
|
||||
uri: "file:///users/42/profile",
|
||||
result: {
|
||||
contents: [
|
||||
{
|
||||
uri: "file:///users/42/profile",
|
||||
mimeType: "application/json",
|
||||
text: JSON.stringify(
|
||||
{ id: 42, name: "Alice", email: "alice@example.com" },
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
lastUpdated: new Date("2026-03-17T11:15:00Z"),
|
||||
isSubscribed: false,
|
||||
}}
|
||||
listChanged={true}
|
||||
onRefreshList={fn()}
|
||||
onSelectUri={fn()}
|
||||
onSelectTemplate={fn()}
|
||||
onReadResource={fn()}
|
||||
onSubscribeResource={fn()}
|
||||
onUnsubscribeResource={fn()}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const PromptsActive: Story = {
|
||||
args: {
|
||||
activeTab: "Prompts",
|
||||
children: (
|
||||
<PromptsScreen
|
||||
prompts={[
|
||||
{
|
||||
name: "summarize",
|
||||
description: "Summarize a document",
|
||||
},
|
||||
{
|
||||
name: "translate",
|
||||
description: "Translate text to another language",
|
||||
arguments: [
|
||||
{
|
||||
name: "text",
|
||||
required: true,
|
||||
description: "The text to translate",
|
||||
},
|
||||
{
|
||||
name: "targetLanguage",
|
||||
required: true,
|
||||
description: "Target language code",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "code-review",
|
||||
description: "Review code for issues",
|
||||
},
|
||||
]}
|
||||
selectedPromptName="translate"
|
||||
getPromptState={{
|
||||
status: "ok",
|
||||
result: {
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: {
|
||||
type: "text",
|
||||
text: 'Translate the following text to Spanish: "Hello, how are you?"',
|
||||
},
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: { type: "text", text: "Hola, como estas?" },
|
||||
},
|
||||
],
|
||||
},
|
||||
}}
|
||||
listChanged={true}
|
||||
onRefreshList={fn()}
|
||||
onSelectPrompt={fn()}
|
||||
onGetPrompt={fn()}
|
||||
onCopyMessages={fn()}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const LoggingActive: Story = {
|
||||
args: {
|
||||
activeTab: "Logs",
|
||||
children: (
|
||||
<LoggingScreen
|
||||
currentLevel="info"
|
||||
onSetLevel={fn()}
|
||||
onClear={fn()}
|
||||
onExport={fn()}
|
||||
entries={sampleLogEntries}
|
||||
autoScroll={true}
|
||||
onToggleAutoScroll={fn()}
|
||||
onCopyAll={fn()}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const TasksActive: Story = {
|
||||
args: {
|
||||
activeTab: "Tasks",
|
||||
children: (
|
||||
<TasksScreen
|
||||
tasks={[
|
||||
{
|
||||
taskId: "d0b22eba71fa36229ce5c4dfadeaa7de",
|
||||
status: "working",
|
||||
ttl: 300000,
|
||||
createdAt: "2026-03-29T20:18:20Z",
|
||||
lastUpdatedAt: "2026-03-29T20:18:22Z",
|
||||
statusMessage: "Processing records 650 of 1000...",
|
||||
},
|
||||
{
|
||||
taskId: "4100b5e0b0ed9cd0023330342d1bf647",
|
||||
status: "input_required",
|
||||
ttl: 300000,
|
||||
createdAt: "2026-03-29T20:17:55Z",
|
||||
lastUpdatedAt: "2026-03-29T20:17:55Z",
|
||||
},
|
||||
{
|
||||
taskId: "d487b49aa39023d907b5a2a5b506cb3",
|
||||
status: "completed",
|
||||
ttl: 300000,
|
||||
createdAt: "2026-03-29T20:16:47Z",
|
||||
lastUpdatedAt: "2026-03-29T20:16:49Z",
|
||||
},
|
||||
{
|
||||
taskId: "e6ebffd9cca84ddd1646d3c579a4d453",
|
||||
status: "failed",
|
||||
ttl: 300000,
|
||||
createdAt: "2026-03-29T20:17:27Z",
|
||||
lastUpdatedAt: "2026-03-29T20:17:57Z",
|
||||
statusMessage: "Timeout waiting for tool response after 30s",
|
||||
},
|
||||
]}
|
||||
progressByTaskId={{
|
||||
d0b22eba71fa36229ce5c4dfadeaa7de: {
|
||||
progress: 650,
|
||||
total: 1000,
|
||||
message: "Processing records 650 of 1000...",
|
||||
},
|
||||
}}
|
||||
onRefresh={fn()}
|
||||
onClearCompleted={fn()}
|
||||
onCancel={fn()}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const HistoryActive: Story = {
|
||||
args: {
|
||||
activeTab: "History",
|
||||
children: (
|
||||
<HistoryScreen
|
||||
entries={[
|
||||
{
|
||||
id: "req-1",
|
||||
timestamp: new Date("2026-03-17T10:00:00Z"),
|
||||
direction: "request" as const,
|
||||
message: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 1,
|
||||
method: "tools/call",
|
||||
params: {
|
||||
name: "send_message",
|
||||
arguments: { message: "Hello, world!" },
|
||||
},
|
||||
},
|
||||
response: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 1,
|
||||
result: {
|
||||
content: [{ type: "text", text: "Message sent successfully" }],
|
||||
},
|
||||
},
|
||||
duration: 120,
|
||||
},
|
||||
{
|
||||
id: "req-2",
|
||||
timestamp: new Date("2026-03-17T10:01:00Z"),
|
||||
direction: "request" as const,
|
||||
message: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 2,
|
||||
method: "resources/read",
|
||||
params: { uri: "file:///config.json" },
|
||||
},
|
||||
response: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 2,
|
||||
result: {
|
||||
contents: [{ uri: "file:///config.json", text: "{}" }],
|
||||
},
|
||||
},
|
||||
duration: 45,
|
||||
},
|
||||
{
|
||||
id: "req-3",
|
||||
timestamp: new Date("2026-03-17T10:02:00Z"),
|
||||
direction: "request" as const,
|
||||
message: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 3,
|
||||
method: "tools/call",
|
||||
params: { name: "delete_records", arguments: { ids: [1, 2, 3] } },
|
||||
},
|
||||
response: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 3,
|
||||
error: { code: -32000, message: "Permission denied" },
|
||||
},
|
||||
duration: 350,
|
||||
},
|
||||
{
|
||||
id: "req-4",
|
||||
timestamp: new Date("2026-03-17T09:30:00Z"),
|
||||
direction: "request" as const,
|
||||
message: { jsonrpc: "2.0" as const, id: 4, method: "tools/list" },
|
||||
response: { jsonrpc: "2.0" as const, id: 4, result: { tools: [] } },
|
||||
duration: 80,
|
||||
},
|
||||
{
|
||||
id: "req-5",
|
||||
timestamp: new Date("2026-03-17T09:35:00Z"),
|
||||
direction: "request" as const,
|
||||
message: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 5,
|
||||
method: "prompts/get",
|
||||
params: { name: "greeting" },
|
||||
},
|
||||
response: {
|
||||
jsonrpc: "2.0" as const,
|
||||
id: 5,
|
||||
result: {
|
||||
messages: [
|
||||
{ role: "user", content: { type: "text", text: "Hello!" } },
|
||||
],
|
||||
},
|
||||
},
|
||||
duration: 60,
|
||||
},
|
||||
]}
|
||||
pinnedIds={new Set(["req-4", "req-5"])}
|
||||
onClearAll={fn()}
|
||||
onExport={fn()}
|
||||
onReplay={fn()}
|
||||
onTogglePin={fn()}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
export const LimitedTabs: Story = {
|
||||
args: {
|
||||
availableTabs: ["Tools", "Resources", "Prompts"],
|
||||
children: <Text>Tools screen content</Text>,
|
||||
},
|
||||
};
|
||||
|
||||
export const LongServerName: Story = {
|
||||
args: {
|
||||
serverInfo: {
|
||||
name: "my-very-long-server-name-that-might-overflow-is",
|
||||
version: "1.0.0",
|
||||
},
|
||||
children: <Text>Tools screen content</Text>,
|
||||
},
|
||||
};
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
import type { ReactNode } from "react";
|
||||
import { AppShell } from "@mantine/core";
|
||||
import type { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
||||
import type { ConnectionStatus } from "@inspector/core/mcp/types.js";
|
||||
import { ViewHeader } from "../../groups/ViewHeader/ViewHeader";
|
||||
|
||||
export interface ConnectedLayoutProps {
|
||||
serverInfo: Implementation;
|
||||
status: ConnectionStatus;
|
||||
latencyMs?: number;
|
||||
activeTab: string;
|
||||
availableTabs: string[];
|
||||
onTabChange: (tab: string) => void;
|
||||
onDisconnect: () => void;
|
||||
onToggleTheme: () => void;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function ConnectedView({
|
||||
serverInfo,
|
||||
status,
|
||||
latencyMs,
|
||||
activeTab,
|
||||
availableTabs,
|
||||
onTabChange,
|
||||
onDisconnect,
|
||||
onToggleTheme,
|
||||
children,
|
||||
}: ConnectedLayoutProps) {
|
||||
return (
|
||||
<AppShell header={{ height: 60 }} padding="md">
|
||||
<AppShell.Header>
|
||||
<ViewHeader
|
||||
connected
|
||||
serverInfo={serverInfo}
|
||||
status={status}
|
||||
latencyMs={latencyMs}
|
||||
activeTab={activeTab}
|
||||
availableTabs={availableTabs}
|
||||
onTabChange={onTabChange}
|
||||
onDisconnect={onDisconnect}
|
||||
onToggleTheme={onToggleTheme}
|
||||
/>
|
||||
</AppShell.Header>
|
||||
<AppShell.Main>{children}</AppShell.Main>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
import { useState } from "react";
|
||||
import type { InspectorServerSettings } from "@inspector/core/mcp/types.js";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { fn } from "storybook/test";
|
||||
import { UnconnectedView } from "./UnconnectedView.js";
|
||||
import {
|
||||
ServerListScreen,
|
||||
type ServerEntry,
|
||||
} from "../../screens/ServerListScreen/ServerListScreen";
|
||||
import { ServerSettingsModal } from "../../groups/ServerSettingsModal/ServerSettingsModal";
|
||||
|
||||
const meta: Meta<typeof UnconnectedView> = {
|
||||
title: "Views/UnconnectedView",
|
||||
component: UnconnectedView,
|
||||
parameters: { layout: "fullscreen" },
|
||||
args: {
|
||||
onToggleTheme: fn(),
|
||||
},
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof UnconnectedView>;
|
||||
|
||||
const sharedScreenCallbacks = {
|
||||
onAddManually: fn(),
|
||||
onImportConfig: fn(),
|
||||
onImportServerJson: fn(),
|
||||
onToggleConnection: fn(),
|
||||
onServerInfo: fn(),
|
||||
onSettings: fn(),
|
||||
onEdit: fn(),
|
||||
onClone: fn(),
|
||||
onRemove: fn(),
|
||||
};
|
||||
|
||||
function makeStdioServer(
|
||||
name: string,
|
||||
version: string,
|
||||
command: string,
|
||||
): ServerEntry {
|
||||
return {
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
config: { command },
|
||||
info: { name, version },
|
||||
connection: { status: "disconnected" },
|
||||
};
|
||||
}
|
||||
|
||||
function makeHttpServer(
|
||||
name: string,
|
||||
version: string,
|
||||
url: string,
|
||||
): ServerEntry {
|
||||
return {
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
config: { type: "streamable-http", url },
|
||||
info: { name, version },
|
||||
connection: { status: "disconnected" },
|
||||
};
|
||||
}
|
||||
|
||||
export const Empty: Story = {
|
||||
args: {
|
||||
children: <ServerListScreen servers={[]} {...sharedScreenCallbacks} />,
|
||||
},
|
||||
};
|
||||
|
||||
export const WithServers: Story = {
|
||||
args: {
|
||||
children: (
|
||||
<ServerListScreen
|
||||
servers={[
|
||||
makeStdioServer(
|
||||
"everything-server",
|
||||
"1.0.0",
|
||||
"npx -y @modelcontextprotocol/server-everything",
|
||||
),
|
||||
makeStdioServer(
|
||||
"filesystem-server",
|
||||
"0.6.2",
|
||||
"npx -y @modelcontextprotocol/server-filesystem /home/user",
|
||||
),
|
||||
makeHttpServer(
|
||||
"remote-server",
|
||||
"2.1.0",
|
||||
"https://api.example.com/mcp",
|
||||
),
|
||||
]}
|
||||
{...sharedScreenCallbacks}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
function SettingsModalStory() {
|
||||
const [settings, setSettings] = useState<InspectorServerSettings>({
|
||||
headers: [
|
||||
{ key: "Authorization", value: "Bearer token-abc-123" },
|
||||
{ key: "X-Request-Id", value: "req-456" },
|
||||
],
|
||||
metadata: [{ key: "userId", value: "user-789" }],
|
||||
connectionTimeout: 30000,
|
||||
requestTimeout: 60000,
|
||||
oauthClientId: "my-client-id",
|
||||
oauthClientSecret: "super-secret-value",
|
||||
oauthScopes: "read write",
|
||||
});
|
||||
|
||||
return (
|
||||
<UnconnectedView onToggleTheme={fn()}>
|
||||
<ServerListScreen
|
||||
servers={[
|
||||
makeStdioServer(
|
||||
"everything-server",
|
||||
"1.0.0",
|
||||
"npx -y @modelcontextprotocol/server-everything",
|
||||
),
|
||||
]}
|
||||
{...sharedScreenCallbacks}
|
||||
/>
|
||||
<ServerSettingsModal
|
||||
opened
|
||||
settings={settings}
|
||||
onClose={fn()}
|
||||
onSettingsChange={setSettings}
|
||||
/>
|
||||
</UnconnectedView>
|
||||
);
|
||||
}
|
||||
|
||||
export const WithSettingsModal: Story = {
|
||||
render: () => <SettingsModalStory />,
|
||||
};
|
||||
|
||||
export const ManyServers: Story = {
|
||||
args: {
|
||||
children: (
|
||||
<ServerListScreen
|
||||
servers={[
|
||||
makeStdioServer(
|
||||
"everything-server",
|
||||
"1.0.0",
|
||||
"npx -y @modelcontextprotocol/server-everything",
|
||||
),
|
||||
makeStdioServer(
|
||||
"filesystem-server",
|
||||
"0.6.2",
|
||||
"npx -y @modelcontextprotocol/server-filesystem /home/user",
|
||||
),
|
||||
makeHttpServer(
|
||||
"remote-api-server",
|
||||
"2.1.0",
|
||||
"https://api.example.com/mcp",
|
||||
),
|
||||
makeStdioServer(
|
||||
"postgres-server",
|
||||
"1.3.0",
|
||||
"npx -y @modelcontextprotocol/server-postgres",
|
||||
),
|
||||
makeStdioServer(
|
||||
"github-server",
|
||||
"0.9.1",
|
||||
"npx -y @modelcontextprotocol/server-github",
|
||||
),
|
||||
makeHttpServer(
|
||||
"slack-server",
|
||||
"1.1.0",
|
||||
"https://slack-mcp.example.com/mcp",
|
||||
),
|
||||
makeStdioServer(
|
||||
"memory-server",
|
||||
"0.2.0",
|
||||
"npx -y @modelcontextprotocol/server-memory",
|
||||
),
|
||||
makeStdioServer(
|
||||
"puppeteer-server",
|
||||
"1.0.3",
|
||||
"npx -y @modelcontextprotocol/server-puppeteer",
|
||||
),
|
||||
makeStdioServer(
|
||||
"sqlite-server",
|
||||
"0.5.1",
|
||||
"npx -y @modelcontextprotocol/server-sqlite ./data.db",
|
||||
),
|
||||
makeStdioServer(
|
||||
"brave-search-server",
|
||||
"1.2.0",
|
||||
"npx -y @modelcontextprotocol/server-brave-search",
|
||||
),
|
||||
makeHttpServer(
|
||||
"google-maps-server",
|
||||
"0.8.0",
|
||||
"https://maps-mcp.example.com/mcp",
|
||||
),
|
||||
makeStdioServer(
|
||||
"sequential-thinking-server",
|
||||
"1.4.2",
|
||||
"npx -y @modelcontextprotocol/server-sequential-thinking",
|
||||
),
|
||||
]}
|
||||
{...sharedScreenCallbacks}
|
||||
/>
|
||||
),
|
||||
},
|
||||
};
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import type { ReactNode } from "react";
|
||||
import { AppShell } from "@mantine/core";
|
||||
import { ViewHeader } from "../../groups/ViewHeader/ViewHeader";
|
||||
|
||||
export interface HomeLayoutProps {
|
||||
children: ReactNode;
|
||||
onToggleTheme: () => void;
|
||||
}
|
||||
|
||||
export function UnconnectedView({ children, onToggleTheme }: HomeLayoutProps) {
|
||||
return (
|
||||
<AppShell header={{ height: 60 }} padding="md">
|
||||
<AppShell.Header>
|
||||
<ViewHeader connected={false} onToggleTheme={onToggleTheme} />
|
||||
</AppShell.Header>
|
||||
<AppShell.Main>{children}</AppShell.Main>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
|
|
@ -775,69 +775,49 @@ themselves — every callback passed down must originate in a core hook.
|
|||
|
||||
## Section 4 — Views (`clients/web/src/components/views/`)
|
||||
|
||||
> Outer shell components that decide which screen to render based on
|
||||
> connection state (`ConnectedView`, `UnconnectedView`). They receive the full
|
||||
> Inspector core context and route to the appropriate screen.
|
||||
> Outer shell component that holds inspector-level state (active server,
|
||||
> connection status, current tab) and renders the appropriate screen.
|
||||
> Receives all screen data via props so a single view can drive the whole
|
||||
> application.
|
||||
|
||||
<!-- AGENT:VIEWS -->
|
||||
### ConnectedView
|
||||
### InspectorView
|
||||
|
||||
- **Location**: `views/ConnectedView/ConnectedView.tsx`
|
||||
- **Purpose**: Outer `AppShell` wrapper shown once a server session is live; renders `ViewHeader` in connected mode and slots the active screen into the main region via `children`.
|
||||
- **Current props**:
|
||||
- `serverName: string`
|
||||
- `status: "connected" | "connecting" | "failed"`
|
||||
- `latencyMs?: number`
|
||||
- `activeTab: string`
|
||||
- **Location**: `views/InspectorView/InspectorView.tsx`
|
||||
- **Purpose**: Single state-machine view that owns inspector-level state, switches `ViewHeader` between connected and unconnected modes, and renders the active screen based on the current tab. Replaces the prior `ConnectedView` / `UnconnectedView` pair (which awkwardly took `children`).
|
||||
- **Internal state**:
|
||||
- `activeServer: string | undefined`
|
||||
- `connectionStatus: ConnectionStatus`
|
||||
- `initializeResult: InitializeResult | undefined`
|
||||
- `latencyMs: number | undefined`
|
||||
- `activeTab: string` (defaults to `"Servers"`; expands to all tabs once a server is connected)
|
||||
- `availableTabs: string[]`
|
||||
- `onTabChange: (tab: string) => void`
|
||||
- `onDisconnect: () => void`
|
||||
- `onToggleTheme: () => void`
|
||||
- `children: ReactNode`
|
||||
- **MCP schema touch points**:
|
||||
- `Implementation` (server identity → `serverName`) from `InitializeResult.serverInfo`.
|
||||
- `ServerCapabilities` from `InitializeResult.capabilities` — drives which tabs are available (tools/prompts/resources/logging/completions).
|
||||
- `InitializeResult` as a whole is the natural handshake object to accept instead of loose strings.
|
||||
- **Target props**:
|
||||
- `serverInfo: Implementation`
|
||||
- `capabilities: ServerCapabilities`
|
||||
- `connectionStatus: "connected" | "connecting" | "failed"` (app state, owned by core)
|
||||
- `latencyMs?: number` (app state)
|
||||
- `activeTab: InspectorTab` (app state; enum derived from capabilities)
|
||||
- `availableTabs: InspectorTab[]` (app state; derived from `capabilities`)
|
||||
- `onTabChange: (tab: InspectorTab) => void`
|
||||
- `onDisconnect: () => void`
|
||||
- `onToggleTheme: () => void`
|
||||
- `children: ReactNode`
|
||||
- **Callbacks → core hook**:
|
||||
- `onDisconnect` → `useConnection` (disconnect action).
|
||||
- `onTabChange` → local UI state in the wiring layer (not an MCP call); wiring-layer `useState` (no dedicated hook yet) or screen-level state.
|
||||
- `onToggleTheme` → app-level theme store, not a core hook.
|
||||
- `connectionStatus`, `latencyMs`, `serverInfo`, `capabilities` → `useConnection` / `useInspectorClient` / `useServerCapabilities`.
|
||||
- **Internal refactors**:
|
||||
- Replace flat `serverName` with `serverInfo.name` lookup; forward full `serverInfo` to `ViewHeader` once that group is updated.
|
||||
- Compute/validate `availableTabs` against `capabilities` rather than accepting an arbitrary string list; narrow `activeTab`/`availableTabs` to an `InspectorTab` union.
|
||||
- No transport or fetching logic; remains a pure shell routing children.
|
||||
|
||||
### UnconnectedView
|
||||
|
||||
- **Location**: `views/UnconnectedView/UnconnectedView.tsx`
|
||||
- **Purpose**: Outer `AppShell` wrapper shown when no MCP session is active; renders `ViewHeader` in disconnected mode and slots the server-list / connect screen into the main region via `children`.
|
||||
- `logLevel: LoggingLevel`
|
||||
- `autoScroll: boolean`
|
||||
- **Current props**:
|
||||
- `children: ReactNode`
|
||||
- `servers: ServerEntry[]`
|
||||
- `tools: Tool[]`
|
||||
- `prompts: Prompt[]`
|
||||
- `resources: Resource[]`
|
||||
- `resourceTemplates: ResourceTemplate[]`
|
||||
- `subscriptions: InspectorResourceSubscription[]`
|
||||
- `logs: LogEntryData[]`
|
||||
- `tasks: Task[]`
|
||||
- `progressByTaskId?: Record<string, TaskProgress>`
|
||||
- `history: MessageEntry[]`
|
||||
- `onToggleTheme: () => void`
|
||||
- **MCP schema touch points**:
|
||||
- None directly — no handshake has occurred. The view is intentionally MCP-schema-free and only hosts the connect flow.
|
||||
- **Target props**:
|
||||
- `children: ReactNode`
|
||||
- `onToggleTheme: () => void`
|
||||
- (Optional future) `connectionStatus: "disconnected" | "connecting" | "failed"` if the header needs to surface retry state in this shell.
|
||||
- `Implementation` / `InitializeResult` — produced internally on connect and forwarded to `ViewHeader`.
|
||||
- `ServerCapabilities` — will eventually drive `availableTabs` (currently the view exposes all tabs once connected; capability-gating is a follow-up).
|
||||
- All screen-data types (`Tool`, `Prompt`, `Resource`, `ResourceTemplate`, `Task`, `LoggingLevel`) flow straight through to the relevant screen.
|
||||
- **Callbacks → core hook**:
|
||||
- Connection toggle (per-card) → `useConnection` (connect / disconnect actions).
|
||||
- `onToggleTheme` → app-level theme store, not a core hook.
|
||||
- Any connect action rendered inside `children` (e.g. from `ServerListScreen`) → `useConnection` (connect action), not owned by this view.
|
||||
- **Internal refactors**:
|
||||
- None required today; keep the shell minimal and let the embedded `ServerListScreen` own all connect/form state.
|
||||
- Rename internal `HomeLayoutProps` to `UnconnectedViewProps` for consistency with the component name when the refactor lands.
|
||||
- Per-screen handlers (`onCallTool`, `onGetPrompt`, `onReadResource`, `onSetLevel`, `onCancel` …) currently stubbed as `noop`; the wiring layer will replace these with hook calls (`useManagedTools`, `useManagedPrompts`, `useManagedResources`, `useLogging`, `useTasks`, `useHistory`).
|
||||
- **Internal refactors / follow-ups**:
|
||||
- Compute `availableTabs` from `initializeResult.capabilities` instead of always exposing all tabs.
|
||||
- Narrow `activeTab` / `availableTabs` to an `InspectorTab` union.
|
||||
- Once core hooks land, the view should accept the hook outputs directly rather than receive bare arrays via props (stories will continue to pass fixtures).
|
||||
<!-- /AGENT:VIEWS -->
|
||||
|
||||
---
|
||||
|
|
|
|||
Loading…
Reference in a new issue