fix: address Copilot review round 10 — structural const match, deep-link constants

- selectBranchIndex compares a discriminator structurally: a `const` may be
  an object or array, and deep-link arguments arrive as freshly parsed
  instances that could never be reference-equal to the schema's own.
- New applySchemaConstants, applied by InspectorView AFTER the deep link's
  `appArgs` are spread over the seeded defaults. The form renders a pinned
  field read-only, so a link disagreeing with one would otherwise auto-open an
  App with a hidden value contradicting the shape on screen.

Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-26 04:23:14 -04:00
commit 775fec0f6a

View file

@ -103,7 +103,11 @@ import {
correlatedFetchStatusById,
revealableMessageIds,
} from "../../../utils/correlateTransportErrors";
import { collectSchemaDefaults, toFormSchema } from "../../../utils/jsonUtils";
import {
applySchemaConstants,
collectSchemaDefaults,
toFormSchema,
} from "../../../utils/jsonUtils";
import { MONITOR_COLUMN_ANIM_MS } from "./monitorColumnAnimation";
const SORT_DEFAULT: SortDirection = "newest-first";
@ -1040,13 +1044,15 @@ export function InspectorView({
// than the first, and defaults seeded from the wrong branch would sit in
// the submitted arguments where the form — showing the branch the args
// identify — never displays them (#2123).
const formValues = {
...collectSchemaDefaults(
toFormSchema(target.inputSchema) ?? {},
deepLink.appArgs ?? {},
),
// …and the schema's constants are re-applied *after* the overlay: a field
// the form renders read-only cannot be corrected by the user, so a deep
// link disagreeing with one would otherwise auto-open with a hidden value
// contradicting the shape on screen.
const appFormSchema = toFormSchema(target.inputSchema) ?? {};
const formValues = applySchemaConstants(appFormSchema, {
...collectSchemaDefaults(appFormSchema, deepLink.appArgs ?? {}),
...deepLink.appArgs,
};
});
// Seed the selection directly rather than routing through
// AppsScreen.handleSelect. This deliberately bypasses handleSelect's
// no-input-app auto-launch: a deep link must never invoke a tool against