fix: harden assistant authoring and UI

This commit is contained in:
ajnart committed 2026-08-13 19:56:56 +02:00
1 parent 3148ecb823
commit 11b941285b
45 files changed
+3848 -895

No files matched your search

@@ -0,0 +1,24 @@
import { describe, expect, test } from "vitest";
import { repairCustomWidgetToolInput } from "./assistant-tool-input-repair";
describe("repairCustomWidgetToolInput", () => {
test("repairs literal newlines generated inside a multiline Custom JSX template", () => {
const input = `{"definition":{"template":"<Stack>
<Text>{data.fixtures?.length} fixtures</Text>
</Stack>"}}`;
const repaired = repairCustomWidgetToolInput({ toolName: "customWidget_previewCreate", input });
expect(repaired).not.toBeNull();
expect(JSON.parse(repaired?.input ?? "")).toEqual({
definition: { template: "<Stack>\n <Text>{data.fixtures?.length} fixtures</Text>\n</Stack>" },
});
});
test("does not alter unrelated tools or guess at truncated JSON", () => {
expect(repairCustomWidgetToolInput({ toolName: "app_create", input: '{"name":"Wiki\npedia"}' })).toBeNull();
expect(
repairCustomWidgetToolInput({ toolName: "customWidget_create", input: '{"template":"<Text>broken' }),
).toBeNull();
});
});