fix(web): reject a reshaped replay param, and forward a declared JSON body

Copilot's sixth pass generated no new inline comments; both suppressed ones
were right.

- `arguments` surviving the key check is not the same as being sent as
  written. `replayProtocolRequest` applies `arguments ?? {}`, so a `null` shown
  in the editor reaches the wire as `{}`; an array or scalar is not nullish and
  rides the cast into a call whose type says it is a named-argument record.
  `reshapedReplayParam` rejects both before Send. `name` and `uri` are
  deliberately not checked there — the dispatch already refuses those with a
  reason the caller shows as a toast, so they fail visibly rather than
  silently.

- `NetworkEntry` never forwarded the body's content type, so the Network tab
  could not reach the declared-JSON branch at all and a malformed
  `application/json` response read as plain text with no sign it was meant to
  be JSON. Forwarded — but only when the declared type *is* JSON: passing it
  wholesale would also route an HTML body into the sandboxed frame and a CSV
  one into a table, which is a change to what the Network tab is and not one
  this makes.

The `NetworkEntry > Auth Success` play function moved off `textContent` for
body assertions. Ace repaints its rows on an animation frame and virtualizes
them, so reading the DOM straight after Reveal returned the previous rows
under load — it passed in isolation and failed in the full run. It now reads
the editors' documents alongside the DOM text, and waits.

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:
cliffhall 2026-08-27 04:17:19 -04:00
commit 0e9069a78d

View file

@ -178,6 +178,25 @@ describe("EditReplayModal", () => {
).toBeInTheDocument();
});
// Surviving the key check is not the same as being sent as written:
// `replayProtocolRequest` applies `arguments ?? {}`, so a null shown in the
// editor reaches the wire as `{}`.
it("disables Send for a null arguments, which would be sent as {}", async () => {
renderWithMantine(<EditReplayModal {...baseProps} method="tools/call" />);
await setAceText('{"name":"echo","arguments":null}');
expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();
expect(screen.getByText(/sent as `\{\}` when null/)).toBeInTheDocument();
});
it("disables Send for a non-object arguments", async () => {
renderWithMantine(<EditReplayModal {...baseProps} method="tools/call" />);
await setAceText('{"name":"echo","arguments":[1,2]}');
expect(screen.getByRole("button", { name: "Send" })).toBeDisabled();
expect(
screen.getByText(/`arguments` must be a JSON object/),
).toBeInTheDocument();
});
it("closes without sending when cancelled", async () => {
const user = userEvent.setup();
const onSend = vi.fn();