diff --git a/client/src/lib/hooks/__tests__/useConnection.test.tsx b/client/src/lib/hooks/__tests__/useConnection.test.tsx index 5c47767f..4f382740 100644 --- a/client/src/lib/hooks/__tests__/useConnection.test.tsx +++ b/client/src/lib/hooks/__tests__/useConnection.test.tsx @@ -510,12 +510,13 @@ describe("useConnection", () => { requestedSchema: { type: "object", properties: { - name: { - $ref: "#/properties/nameDef", - }, - nameDef: { + source: { type: "string", - title: "Name", + minLength: 1, + title: "A Connectable Node", + }, + target: { + $ref: "#/properties/source", }, }, }, @@ -529,9 +530,10 @@ describe("useConnection", () => { expect(mockProtocolOnMessage).toHaveBeenCalledTimes(1); const message = mockProtocolOnMessage.mock.calls[0][0]; - expect(message.params.requestedSchema.properties.name).toEqual({ + expect(message.params.requestedSchema.properties.target).toEqual({ type: "string", - title: "Name", + minLength: 1, + title: "A Connectable Node", }); }); }); diff --git a/client/src/utils/schemaUtils.ts b/client/src/utils/schemaUtils.ts index e7fe2c8f..42d77d43 100644 --- a/client/src/utils/schemaUtils.ts +++ b/client/src/utils/schemaUtils.ts @@ -302,7 +302,7 @@ export function formatFieldLabel(key: string): string { } /** - * Resolves $ref references in a JSON-RPC message's requestedSchema + * Resolves `$ref` references in a JSON-RPC "elicitation/create" message's `requestedSchema` field * @param message The JSON-RPC message that may contain $ref references * @returns A new message with resolved $ref references, or the original message if no resolution is needed */ @@ -325,10 +325,11 @@ export function resolveRefsInMessage(message: JSONRPCMessage): JSONRPCMessage { ...requestedSchema, properties: Object.fromEntries( Object.entries(requestedSchema.properties).map( - ([key, propSchema]) => [ - key, - resolveRef(propSchema, requestedSchema), - ], + ([key, propSchema]) => { + const resolved = resolveRef(propSchema, requestedSchema); + const normalized = normalizeUnionType(resolved); + return [key, normalized]; + }, ), ), },