feat(canvas): implement local node size pinning and reconciliation logic

- Added functions to handle local node size pins, ensuring that node sizes are preserved during reconciliation.
- Updated `reconcileCanvasFlowNodes` to incorporate size pinning logic.
- Enhanced tests to verify the correct behavior of size pinning in various scenarios.
- Updated related components to support new size pinning functionality.
This commit is contained in:
2026-04-10 08:48:34 +02:00
parent 26d008705f
commit 463830f178
12 changed files with 711 additions and 10 deletions

View File

@@ -104,9 +104,108 @@ describe("generateStructuredObjectViaOpenRouter", () => {
schema,
},
},
plugins: [{ id: "response-healing" }],
});
});
it("parses content when provider returns array text parts", async () => {
fetchMock.mockResolvedValueOnce(
createMockResponse({
ok: true,
status: 200,
json: {
choices: [
{
message: {
content: [
{ type: "text", text: '{"title": "Lemon"' },
{ type: "text", text: ', "confidence": 0.75}' },
],
},
},
],
},
}),
);
const result = await generateStructuredObjectViaOpenRouter<{
title: string;
confidence: number;
}>("test-api-key", {
model: "openai/gpt-5-mini",
messages: [{ role: "user", content: "hello" }],
schemaName: "test_schema",
schema: { type: "object" },
});
expect(result).toEqual({ title: "Lemon", confidence: 0.75 });
});
it("parses fenced json content", async () => {
fetchMock.mockResolvedValueOnce(
createMockResponse({
ok: true,
status: 200,
json: {
choices: [
{
message: {
content:
"Here is the result:\n```json\n{\n \"title\": \"LemonSpace\",\n \"confidence\": 0.88\n}\n```\nThanks.",
},
},
],
},
}),
);
const result = await generateStructuredObjectViaOpenRouter<{
title: string;
confidence: number;
}>("test-api-key", {
model: "openai/gpt-5-mini",
messages: [{ role: "user", content: "hello" }],
schemaName: "test_schema",
schema: { type: "object" },
});
expect(result).toEqual({ title: "LemonSpace", confidence: 0.88 });
});
it("returns message.parsed directly when provided", async () => {
fetchMock.mockResolvedValueOnce(
createMockResponse({
ok: true,
status: 200,
json: {
choices: [
{
message: {
parsed: {
title: "Parsed Result",
confidence: 0.99,
},
content: "not valid json",
},
},
],
},
}),
);
const result = await generateStructuredObjectViaOpenRouter<{
title: string;
confidence: number;
}>("test-api-key", {
model: "openai/gpt-5-mini",
messages: [{ role: "user", content: "hello" }],
schemaName: "test_schema",
schema: { type: "object" },
});
expect(result).toEqual({ title: "Parsed Result", confidence: 0.99 });
});
it("throws ConvexError code when response content is missing", async () => {
fetchMock.mockResolvedValueOnce(
createMockResponse({