diff --git a/src/uipath/dev/server/frontend/src/components/chat/ChatInterrupt.tsx b/src/uipath/dev/server/frontend/src/components/chat/ChatInterrupt.tsx index 36059cd..3395423 100644 --- a/src/uipath/dev/server/frontend/src/components/chat/ChatInterrupt.tsx +++ b/src/uipath/dev/server/frontend/src/components/chat/ChatInterrupt.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useCallback } from "react"; import type { InterruptEvent } from "../../types/run"; interface Props { @@ -6,53 +6,429 @@ interface Props { onRespond: (data: Record) => void; } +/* ── JSON Schema helpers ─────────────────────────────────── */ + +interface SchemaProperty { + type?: string; + description?: string; + enum?: unknown[]; +} + +interface JsonSchema { + properties?: Record; +} + +function hasProperties( + schema: unknown, +): schema is JsonSchema & { properties: Record } { + if (typeof schema !== "object" || schema === null) return false; + const s = schema as Record; + return ( + typeof s.properties === "object" && + s.properties !== null && + Object.keys(s.properties as object).length > 0 + ); +} + +/* ── Per-field form input ────────────────────────────────── */ + +const inputStyle = { + color: "var(--text-primary)", + border: "1px solid var(--border)", + background: "var(--bg-primary)", +}; +const inputClass = + "w-full text-[11px] font-mono py-1 px-2 rounded focus:outline-none"; + +function FormField({ + name, + prop, + value, + onChange, +}: { + name: string; + prop: SchemaProperty; + value: unknown; + onChange: (v: unknown) => void; +}) { + const label = ( + + ); + + if (prop.enum && Array.isArray(prop.enum)) { + return ( +
+ {label} + +
+ ); + } + + if (prop.type === "boolean") { + return ( +
+ {label} + +
+ ); + } + + if (prop.type === "number" || prop.type === "integer") { + return ( +
+ {label} + + onChange(e.target.value === "" ? null : Number(e.target.value)) + } + step={prop.type === "integer" ? 1 : "any"} + className={inputClass} + style={inputStyle} + /> +
+ ); + } + + if (prop.type === "object" || prop.type === "array") { + const str = + typeof value === "string" + ? value + : JSON.stringify(value ?? null, null, 2); + return ( +
+ {label} +