refactor(web): rename "History" tab/feature to "Protocol" (#1623)

Rename the web client's History tab and its supporting code to Protocol
so the feature reads as the MCP "Protocol" view.

- Tab renders as "Protocol"; INSPECTOR_TAB_IDS, InspectorView tab
  constants/MonitorTab, TAB_UI_REGISTRY key, and navigation.ts tab id all
  updated to Protocol.
- Rename components + folders: HistoryScreen -> ProtocolScreen,
  HistoryListPanel -> ProtocolListPanel, HistoryEntry -> ProtocolEntry,
  HistoryControls -> ProtocolControls, historyUtils -> protocolUtils
  (plus their tests and stories, and exported types).
- Rename App/InspectorView plumbing: historyUi, pinnedHistoryIds,
  on*History* handlers/props, replayHistoryRequest,
  isReplayableHistoryMethod, sort/compact scopes, etc. -> Protocol names.
- Export filenames use the "protocol" slug (buildExportFilename +
  ExportKind).

Preserved (per issue #1623 decisions):
- The in-panel section discriminator keeps its "pinned" | "history"
  values, and the sub-sections stay labeled Pinned / History.
- window.history and core message-log/replay concepts are untouched.

npm run ci passes (format, lint, build, unit tests, >=90 per-file
coverage gate, smoke, Storybook).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
This commit is contained in:
cliffhall 2026-07-09 19:04:54 -04:00
commit ace4250d31

View file

@ -1,167 +0,0 @@
import { useState } from "react";
import type { ComponentProps } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import type { MessageEntry } from "../../../../../../core/mcp/types.js";
import { expect, fn, screen, userEvent, within } from "storybook/test";
import { HistoryScreen } from "./HistoryScreen";
import { EMPTY_HISTORY_UI } from "../screenUiState";
// HistoryScreen is controlled (search text + method filter live in the parent
// as one `ui` object — see #1417). This wrapper holds that state so the
// play-driven filter selection and clear-all reset are observable, mirroring
// how App owns the state.
function StatefulHistoryScreen(args: ComponentProps<typeof HistoryScreen>) {
const [ui, setUi] = useState({ ...EMPTY_HISTORY_UI, ...args.ui });
return <HistoryScreen {...args} ui={ui} onUiChange={setUi} />;
}
const meta: Meta<typeof HistoryScreen> = {
title: "Screens/HistoryScreen",
component: HistoryScreen,
parameters: { layout: "fullscreen" },
args: {
pinnedIds: new Set<string>(),
onClearAll: fn(),
onExport: fn(),
onReplay: fn(),
onTogglePin: fn(),
ui: EMPTY_HISTORY_UI,
onUiChange: fn(),
sortDirection: "newest-first",
onSortChange: fn(),
compact: true,
onToggleCompact: fn(),
},
render: (args) => <StatefulHistoryScreen {...args} />,
};
export default meta;
type Story = StoryObj<typeof HistoryScreen>;
const sampleEntries: MessageEntry[] = [
{
id: "req-1",
timestamp: new Date("2026-03-17T10:00:00Z"),
direction: "request",
message: {
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: { name: "send_message", arguments: { message: "Hello, world!" } },
},
response: {
jsonrpc: "2.0",
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",
message: {
jsonrpc: "2.0",
id: 2,
method: "resources/read",
params: { uri: "file:///config.json" },
},
response: {
jsonrpc: "2.0",
id: 2,
result: {
contents: [{ uri: "file:///config.json", text: "{}" }],
},
},
duration: 45,
},
{
id: "req-3",
timestamp: new Date("2026-03-17T10:02:00Z"),
direction: "request",
message: {
jsonrpc: "2.0",
id: 3,
method: "tools/call",
params: { name: "delete_records", arguments: { ids: [1, 2, 3] } },
},
response: {
jsonrpc: "2.0",
id: 3,
error: { code: -32000, message: "Permission denied" },
},
duration: 350,
},
{
id: "req-4",
timestamp: new Date("2026-03-17T09:30:00Z"),
direction: "request",
message: {
jsonrpc: "2.0",
id: 4,
method: "tools/list",
},
response: {
jsonrpc: "2.0",
id: 4,
result: { tools: [] },
},
duration: 80,
},
{
id: "req-5",
timestamp: new Date("2026-03-17T09:35:00Z"),
direction: "request",
message: {
jsonrpc: "2.0",
id: 5,
method: "prompts/get",
params: { name: "greeting" },
},
response: {
jsonrpc: "2.0",
id: 5,
result: {
messages: [{ role: "user", content: { type: "text", text: "Hello!" } }],
},
},
duration: 60,
},
];
export const WithEntries: Story = {
args: {
entries: sampleEntries,
pinnedIds: new Set(["req-4", "req-5"]),
},
};
export const Empty: Story = {
args: {
entries: [],
},
};
export const MethodFilterClearedOnClearAll: Story = {
args: {
entries: sampleEntries,
pinnedIds: new Set<string>(),
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const filter = canvas.getByPlaceholderText(
"All methods",
) as HTMLInputElement;
await userEvent.click(filter);
await userEvent.click(
await screen.findByRole("option", { name: "tools/call" }),
);
await expect(filter).toHaveValue("tools/call");
await userEvent.click(canvas.getByRole("button", { name: /^clear$/i }));
await expect(filter).toHaveValue("");
},
};