diff --git a/frontend/src/widgets/FallbackWidget.tsx b/frontend/src/widgets/FallbackWidget.tsx
new file mode 100644
index 00000000..bc937334
--- /dev/null
+++ b/frontend/src/widgets/FallbackWidget.tsx
@@ -0,0 +1,14 @@
+import { useState } from "react";
+import type { WidgetProps } from "./types";
+
+export function FallbackWidget({ descriptor, onRespond }: WidgetProps) {
+ const [text, setText] = useState("");
+ return (
+
+
Widget non supportato (kind: {descriptor.widget}) — rispondi manualmente
+
{JSON.stringify(descriptor, null, 2)}
+
+ );
+}
diff --git a/frontend/src/widgets/registry.test.tsx b/frontend/src/widgets/registry.test.tsx
new file mode 100644
index 00000000..e1591e0a
--- /dev/null
+++ b/frontend/src/widgets/registry.test.tsx
@@ -0,0 +1,15 @@
+import { render, screen } from "@testing-library/react";
+import { register, resolve } from "./registry";
+import type { WidgetProps } from "./types";
+
+test("resolve returns the registered renderer", () => {
+ const Dummy = (_: WidgetProps) => dummy
;
+ register("dummy", Dummy);
+ expect(resolve("dummy")).toBe(Dummy);
+});
+
+test("resolve falls back for unknown kind and shows the JSON", () => {
+ const Comp = resolve("totally-unknown");
+ render( {}} />);
+ expect(screen.getByText(/Widget non supportato/i)).toBeInTheDocument();
+});
diff --git a/frontend/src/widgets/registry.ts b/frontend/src/widgets/registry.ts
new file mode 100644
index 00000000..9a36910d
--- /dev/null
+++ b/frontend/src/widgets/registry.ts
@@ -0,0 +1,13 @@
+import type React from "react";
+import type { WidgetProps } from "./types";
+import { FallbackWidget } from "./FallbackWidget";
+
+const registry = new Map>();
+
+export function register(kind: string, comp: React.FC) {
+ registry.set(kind, comp);
+}
+
+export function resolve(kind: string): React.FC {
+ return registry.get(kind) ?? FallbackWidget;
+}
diff --git a/frontend/src/widgets/types.ts b/frontend/src/widgets/types.ts
new file mode 100644
index 00000000..ccf6c382
--- /dev/null
+++ b/frontend/src/widgets/types.ts
@@ -0,0 +1,3 @@
+import type { WidgetDescriptor, UiResponse } from "../api/types";
+
+export type WidgetProps = { descriptor: WidgetDescriptor; onRespond: (r: UiResponse) => void };