fix(web): seed Edit-and-replay from what replay sends, name each JSON editor
Copilot's fourth pass, one inline plus two suppressed. All three were right. - The modal presented the whole captured frame as editable, but replay does not re-send a frame: it dispatches through the typed InspectorClient methods, whose signatures have no room for `_meta` (a captured `tools/call` carries `_meta.progressToken`) or for any list-request key but `cursor`. So editing `_meta` and pressing Send transmitted something other than what was on screen. `replayableParams` now projects the frame down to what the dispatcher actually reads, the modal seeds from that, and it names what was left out rather than leaving the difference to be discovered. The projection lives beside the dispatch switch because the two are halves of one contract. - `ContentViewer` gains `jsonLabel`, so a read-only JSON editor can say what it holds. Every one of them announced "JSON content", and an expanded Protocol entry has two while the list has many pairs — leaving a screen reader with indistinguishable textboxes and only the visible headings to tell them apart. Protocol entries now name theirs per method and direction, Network entries per request/response body. - `isJsonDocument` became `formatJsonDocument`, returning the formatted text instead of a boolean. The heuristic path parsed the payload to decide and then parsed it again to render; Protocol and Network hand over serialized bodies as untyped text and are not virtualized, so a long history paid twice per payload per render. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UL9retfvAXRgvi6EWk4SY4 Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
12c00d8c63
commit
5abe289caa
1 changed files with 413 additions and 31 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { useState } from "react";
|
||||
import { Button, Group, Modal, Stack, Text } from "@mantine/core";
|
||||
import { Alert, Button, Group, Modal, Stack, Text } from "@mantine/core";
|
||||
import { JsonEditor } from "../../elements/JsonEditor/JsonEditor";
|
||||
import { isJsonObject } from "../../../utils/jsonObjectDraft";
|
||||
import { isSerializableJson } from "@inspector/core/json/jsonUtils.js";
|
||||
|
|
@ -8,8 +8,22 @@ export interface EditReplayModalProps {
|
|||
opened: boolean;
|
||||
/** The method being replayed, shown so the editor is unambiguous. */
|
||||
method: string;
|
||||
/** The originating entry's params, seeded into the editor. */
|
||||
/**
|
||||
* The originating entry's params, seeded into the editor — already reduced to
|
||||
* the ones replay will actually read. See {@link droppedParamKeys}.
|
||||
*/
|
||||
params?: Record<string, unknown>;
|
||||
/**
|
||||
* Param names the entry carried that replay cannot re-send, so the modal can
|
||||
* say so rather than leave the difference to be discovered.
|
||||
*
|
||||
* Replay dispatches through the typed `InspectorClient` methods rather than
|
||||
* re-sending the captured frame, and those signatures have no room for
|
||||
* `_meta` (or for anything but `cursor` on a list request). Seeding the
|
||||
* editor with them would invite an edit that Send silently discards, which is
|
||||
* the one thing an inspector must not do.
|
||||
*/
|
||||
droppedParamKeys?: string[];
|
||||
/**
|
||||
* Re-issue the request with these params. `null` means "send no params",
|
||||
* which is a request an empty editor can legitimately express — see
|
||||
|
|
@ -27,6 +41,17 @@ const MethodText = Text.withProps({
|
|||
|
||||
const Footer = Group.withProps({ justify: "flex-end", gap: "sm" });
|
||||
|
||||
// Names the params replay cannot carry. `light` and gray rather than a warning
|
||||
// colour: nothing is wrong and there is nothing for the user to fix — it is a
|
||||
// property of how replay dispatches.
|
||||
const DroppedNote = Alert.withProps({ variant: "light", color: "gray" });
|
||||
|
||||
/** "`a`, `b` are" / "`a` is" — the list, agreeing with its verb. */
|
||||
function formatDroppedKeys(keys: string[]): string {
|
||||
const names = keys.map((key) => `\`${key}\``).join(", ");
|
||||
return `${names} ${keys.length === 1 ? "is" : "are"}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* What the editor's text currently means: the params to send, or why they
|
||||
* cannot be sent.
|
||||
|
|
@ -75,6 +100,7 @@ function parseParamsDraft(
|
|||
function EditReplayForm({
|
||||
method,
|
||||
params,
|
||||
droppedParamKeys,
|
||||
onSend,
|
||||
onClose,
|
||||
}: Omit<EditReplayModalProps, "opened">) {
|
||||
|
|
@ -86,6 +112,15 @@ function EditReplayForm({
|
|||
return (
|
||||
<Stack gap="sm">
|
||||
<MethodText>{method}</MethodText>
|
||||
{droppedParamKeys && droppedParamKeys.length > 0 && (
|
||||
<DroppedNote>
|
||||
<Text size="xs">
|
||||
{`Replay re-issues this request through the client's own ${method}
|
||||
method, which carries only the fields below, so
|
||||
${formatDroppedKeys(droppedParamKeys)} not re-sent.`}
|
||||
</Text>
|
||||
</DroppedNote>
|
||||
)}
|
||||
<JsonEditor
|
||||
ariaLabel="Request params"
|
||||
label="Params"
|
||||
|
|
@ -130,6 +165,7 @@ export function EditReplayModal({
|
|||
opened,
|
||||
method,
|
||||
params,
|
||||
droppedParamKeys,
|
||||
onSend,
|
||||
onClose,
|
||||
}: EditReplayModalProps) {
|
||||
|
|
@ -138,6 +174,7 @@ export function EditReplayModal({
|
|||
<EditReplayForm
|
||||
method={method}
|
||||
params={params}
|
||||
droppedParamKeys={droppedParamKeys}
|
||||
onSend={onSend}
|
||||
onClose={onClose}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue