From 95e3a2dca7ac33bba2f8fdc4f6c1261ee232f7df Mon Sep 17 00:00:00 2001 From: cliffhall Date: Sat, 18 Apr 2026 19:39:19 -0400 Subject: [PATCH] Phase 2: Refactor Logs cluster to MCP SDK types Replace string-typed log levels with SDK LoggingLevel across the Logs group components and LoggingScreen. - LogControls: type currentLevel, visibleLevels, and all handlers with LoggingLevel instead of string; type LOG_LEVELS array and LEVEL_COLORS record with LoggingLevel - LogStreamPanel: type visibleLevels as Record instead of Record - LoggingScreen: type currentLevel, onSetLevel, visibleLevels state, and toggle handlers with LoggingLevel; extract NO_LEVELS_VISIBLE as a module-level constant - Stories already used LoggingLevel literals; updated type annotations to use Record - No ConnectedView story changes needed (already passes valid LoggingLevel values) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../LogControls/LogControls.stories.tsx | 3 ++- .../groups/LogControls/LogControls.tsx | 17 ++++++------ .../groups/LogStreamPanel/LogStreamPanel.tsx | 5 ++-- .../screens/LoggingScreen/LoggingScreen.tsx | 26 ++++++++++++------- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/clients/web/src/components/groups/LogControls/LogControls.stories.tsx b/clients/web/src/components/groups/LogControls/LogControls.stories.tsx index 2b21e5d1..b516b6b6 100644 --- a/clients/web/src/components/groups/LogControls/LogControls.stories.tsx +++ b/clients/web/src/components/groups/LogControls/LogControls.stories.tsx @@ -1,8 +1,9 @@ import type { Meta, StoryObj } from "@storybook/react-vite"; +import type { LoggingLevel } from "@modelcontextprotocol/sdk/types.js"; import { fn } from "storybook/test"; import { LogControls } from "./LogControls"; -const allLevelsVisible: Record = { +const allLevelsVisible: Record = { debug: true, info: true, notice: true, diff --git a/clients/web/src/components/groups/LogControls/LogControls.tsx b/clients/web/src/components/groups/LogControls/LogControls.tsx index 780faad1..7e25f3bb 100644 --- a/clients/web/src/components/groups/LogControls/LogControls.tsx +++ b/clients/web/src/components/groups/LogControls/LogControls.tsx @@ -8,8 +8,9 @@ import { Title, UnstyledButton, } from "@mantine/core"; +import type { LoggingLevel } from "@modelcontextprotocol/sdk/types.js"; -const LOG_LEVELS = [ +const LOG_LEVELS: LoggingLevel[] = [ "debug", "info", "notice", @@ -18,9 +19,9 @@ const LOG_LEVELS = [ "critical", "alert", "emergency", -] as const; +]; -const LEVEL_COLORS: Record = { +const LEVEL_COLORS: Record = { debug: { c: "dimmed" }, info: { c: "blue" }, notice: { c: "teal" }, @@ -37,12 +38,12 @@ const SubtleButton = Button.withProps({ }); export interface LogControlsProps { - currentLevel: string; + currentLevel: LoggingLevel; filterText: string; - visibleLevels: Record; - onSetLevel: (level: string) => void; + visibleLevels: Record; + onSetLevel: (level: LoggingLevel) => void; onFilterChange: (text: string) => void; - onToggleLevel: (level: string, visible: boolean) => void; + onToggleLevel: (level: LoggingLevel, visible: boolean) => void; onToggleAllLevels: () => void; } @@ -72,7 +73,7 @@ export function LogControls({ data={LOG_LEVELS.map((level) => ({ value: level, label: level }))} value={currentLevel} onChange={(value) => { - if (value) onSetLevel(value); + if (value) onSetLevel(value as LoggingLevel); }} />