Address PR #1218 code review feedback

- Extract duplicated extractMethod into shared historyUtils.ts
- Include response content in search (was accidentally dropped)
- Show Parameters instead of raw Request in expanded view; gate on
  params existing so parameterless requests don't show empty block

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-20 17:23:49 -04:00
commit 986659ae8f
3 changed files with 24 additions and 25 deletions

View file

@ -11,6 +11,7 @@ import {
} from "@mantine/core";
import type { MessageEntry } from "../../../../../../core/mcp/types.js";
import { ContentViewer } from "../../elements/ContentViewer/ContentViewer";
import { extractMethod } from "../historyUtils.js";
export interface HistoryEntryProps {
entry: MessageEntry;
@ -63,13 +64,6 @@ function formatPinLabel(isPinned: boolean): string {
return isPinned ? "Unpin" : "Pin";
}
function extractMethod(entry: MessageEntry): string {
if ("method" in entry.message) {
return entry.message.method;
}
return "response";
}
function extractTarget(entry: MessageEntry): string | undefined {
const msg = entry.message;
if (!("params" in msg) || !msg.params) return undefined;
@ -147,16 +141,18 @@ export function HistoryEntry({
<Collapse in={isExpanded}>
<Stack gap="sm">
<Divider />
<Stack gap="xs">
<Text size="sm">Request:</Text>
<ContentViewer
block={{
type: "text",
text: serializeMessage(entry.message),
}}
copyable
/>
</Stack>
{"params" in entry.message && entry.message.params && (
<Stack gap="xs">
<Text size="sm">Parameters:</Text>
<ContentViewer
block={{
type: "text",
text: serializeMessage(entry.message.params),
}}
copyable
/>
</Stack>
)}
{entry.response && (
<Stack gap="xs">
<Text size="sm">Response:</Text>

View file

@ -11,6 +11,7 @@ import {
import type { MessageEntry } from "../../../../../../core/mcp/types.js";
import { HistoryEntry } from "../HistoryEntry/HistoryEntry";
import { ListToggle } from "../../elements/ListToggle/ListToggle";
import { extractMethod } from "../historyUtils.js";
export interface HistoryListPanelProps {
entries: MessageEntry[];
@ -49,13 +50,6 @@ function formatHistoryTitle(count: number): string {
return `History (${count})`;
}
function extractMethod(entry: MessageEntry): string {
if ("method" in entry.message) {
return entry.message.method;
}
return "response";
}
function matchesFilters(
entry: MessageEntry,
searchText: string,
@ -65,8 +59,9 @@ function matchesFilters(
if (methodFilter && method !== methodFilter) return false;
if (searchText) {
const term = searchText.toLowerCase();
const responseText = entry.response ? JSON.stringify(entry.response) : "";
const searchable =
`${method} ${entry.id} ${JSON.stringify(entry.message)}`.toLowerCase();
`${method} ${entry.id} ${JSON.stringify(entry.message)} ${responseText}`.toLowerCase();
if (!searchable.includes(term)) return false;
}
return true;

View file

@ -0,0 +1,8 @@
import type { MessageEntry } from "../../../../../core/mcp/types.js";
export function extractMethod(entry: MessageEntry): string {
if ("method" in entry.message) {
return entry.message.method;
}
return "response";
}