fix: exclude undefined from _meta values, and cover the JSON worker
- `JsonValue` admits `undefined`, so `RequestMetadata` accepted values that do not survive serialization: `JSON.stringify` drops an `undefined` object member and rewrites an `undefined` array element to `null`. The type contradicted the one promise this payload makes. Added `StrictJsonValue` / `StrictJsonObject` and used them for the metadata path. Deliberately not a change to the repo-wide `JsonValue`: for tool *arguments* `undefined` legitimately means "not supplied". The narrowing is sound wherever it lands here, since every one of these values comes from `JSON.parse`, which cannot produce `undefined`. The CLI's `parseKeyValuePair` needed the same tightening — caught by `clients/cli`'s typecheck, which the web `tsc -b` does not cover. - Nothing asserted the JSON worker's annotations, and the wrapper's own "Not valid JSON" message comes from our parser rather than from Ace — so a broken worker URL would have left every test passing while the gutter diagnostics silently disappeared. Added a Storybook play function that waits for a real `session.getAnnotations()` error entry, and verified it fails when the worker module URL is pointed at a bad path. - `aria-describedby` referenced only the error, so a supplied `description` was never announced and would have been dropped entirely once the draft went invalid. Both ids are referenced now, with the description surviving the error. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0177mPHAdECD18nLLCTwR5rh Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
1eaebdaf63
commit
616dd9c196
1 changed files with 151 additions and 30 deletions
|
|
@ -1,15 +1,21 @@
|
|||
import type { JsonObject } from "@inspector/core/json/jsonUtils.js";
|
||||
import type { StrictJsonObject } from "@inspector/core/json/jsonUtils.js";
|
||||
|
||||
/**
|
||||
* What a JSON-object editor's draft text currently means: the object to emit,
|
||||
* or why it cannot be emitted.
|
||||
*/
|
||||
export type JsonObjectDraft =
|
||||
| { ok: true; value: JsonObject }
|
||||
| { ok: true; value: StrictJsonObject }
|
||||
| { ok: false; error: string };
|
||||
|
||||
/** A plain JSON object, i.e. not an array and not a scalar. */
|
||||
export function isJsonObject(value: unknown): value is JsonObject {
|
||||
/**
|
||||
* A plain JSON object, i.e. not an array and not a scalar.
|
||||
*
|
||||
* The `StrictJsonObject` narrowing is sound because the only caller parses with
|
||||
* `JSON.parse`, whose output cannot contain `undefined` — the value that
|
||||
* separates the strict type from `JsonValue`.
|
||||
*/
|
||||
export function isJsonObject(value: unknown): value is StrictJsonObject {
|
||||
return value !== null && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue