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

@ -0,0 +1,150 @@
import { useCallback, useMemo } from "react";
import { Card, Flex, Stack } from "@mantine/core";
import type {
MessageEntry,
MessageMethod,
MessageOrigin,
} from "@inspector/core/mcp/types.js";
import { ProtocolControls } from "../../groups/ProtocolControls/ProtocolControls";
import { ProtocolListPanel } from "../../groups/ProtocolListPanel/ProtocolListPanel.js";
import { extractMethod } from "../../groups/protocolUtils.js";
import type { SortDirection } from "../../elements/SortToggle/SortToggle";
export interface ProtocolScreenProps {
entries: MessageEntry[];
pinnedIds: Set<string>;
ui: ProtocolUiState;
onUiChange: (next: ProtocolUiState) => void;
onClearAll: () => void;
onExport: () => void;
onClearSection: (section: "pinned" | "history") => void;
onExportSection: (section: "pinned" | "history") => void;
onReplay: (id: string) => void;
onTogglePin: (id: string) => void;
sortDirection: SortDirection;
onSortChange: (next: SortDirection) => void;
compact: boolean;
onToggleCompact: () => void;
/** See LoggingScreen: shows a "pin as column" button when set (#1616). */
onPin?: () => void;
/** See LoggingScreen: fills the parent height and drops the filter sidebar. */
embedded?: boolean;
}
// Search text, method filter, and per-direction visibility — controlled by the
// parent (App) as one object so they persist across tab navigation within a
// live session (#1417).
export interface ProtocolUiState {
search: string;
methodFilter?: MessageMethod;
/** Which message directions are shown, keyed by entry origin. */
visibleDirections: Record<MessageOrigin, boolean>;
}
const ScreenLayout = Flex.withProps({
variant: "screen",
h: "calc(100dvh - var(--app-shell-header-height, 0px))",
gap: "md",
p: "xl",
});
const Sidebar = Stack.withProps({
w: 340,
flex: "0 0 auto",
});
const SidebarCard = Card.withProps({
withBorder: true,
padding: "lg",
});
export function ProtocolScreen({
entries,
pinnedIds,
ui,
onUiChange,
onClearAll,
onExport,
onClearSection,
onExportSection,
onReplay,
onTogglePin,
sortDirection,
onSortChange,
compact,
onToggleCompact,
onPin,
embedded = false,
}: ProtocolScreenProps) {
const { search, methodFilter, visibleDirections } = ui;
const availableMethods = useMemo(
() => Array.from(new Set(entries.map(extractMethod))).sort(),
[entries],
);
const handleClearAll = useCallback(() => {
onUiChange({ ...ui, methodFilter: undefined });
onClearAll();
}, [ui, onUiChange, onClearAll]);
const handleToggleDirection = useCallback(
(direction: MessageOrigin, visible: boolean) => {
onUiChange({
...ui,
visibleDirections: { ...visibleDirections, [direction]: visible },
});
},
[ui, visibleDirections, onUiChange],
);
const handleToggleAllDirections = useCallback(() => {
const next = !Object.values(visibleDirections).every(Boolean);
onUiChange({
...ui,
visibleDirections: { client: next, server: next },
});
}, [ui, visibleDirections, onUiChange]);
return (
<ScreenLayout h={embedded ? "100%" : undefined}>
{embedded ? null : (
<Sidebar>
<SidebarCard>
<ProtocolControls
searchText={search}
methodFilter={methodFilter}
availableMethods={availableMethods}
visibleDirections={visibleDirections}
onSearchChange={(value) => onUiChange({ ...ui, search: value })}
onMethodFilterChange={(value) =>
onUiChange({ ...ui, methodFilter: value })
}
onToggleDirection={handleToggleDirection}
onToggleAllDirections={handleToggleAllDirections}
/>
</SidebarCard>
</Sidebar>
)}
<ProtocolListPanel
entries={entries}
pinnedIds={pinnedIds}
searchText={search}
methodFilter={methodFilter}
visibleDirections={visibleDirections}
onClearAll={handleClearAll}
onExport={onExport}
onClearSection={onClearSection}
onExportSection={onExportSection}
onReplay={onReplay}
onTogglePin={onTogglePin}
sortDirection={sortDirection}
onSortChange={onSortChange}
compact={compact}
onToggleCompact={onToggleCompact}
onPin={onPin}
embedded={embedded}
/>
</ScreenLayout>
);
}