Skip to content

Conversation

Hector-Zhuang
Copy link
Contributor

Currently, AI fails to handle link inline components correctly because the validation function does not iterate over the content array inside a link node.

image

Copy link

vercel bot commented Sep 5, 2025

@Hector-Zhuang is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@nperez0111
Copy link
Contributor

@Hector-Zhuang can we add a test case that proves that this fixes the intended use case?

@Hector-Zhuang
Copy link
Contributor Author

@nperez0111 I can do it. How do you use for generating these snapshots, or its by manual?

image

@nperez0111
Copy link
Contributor

@Hector-Zhuang I think this is where the tests should execute:

describe("Add", () => {
for (const testCase of addOperationTestCases) {
it(testCase.description, async () => {
const editor = testCase.editor();
await executeTestCase(editor, testCase);
});
}
});
describe("Update", () => {
for (const testCase of updateOperationTestCases) {
it(testCase.description, async () => {
const editor = testCase.editor();
await executeTestCase(editor, testCase);
});
}
});
describe("Delete", () => {
for (const testCase of deleteOperationTestCases) {
it(testCase.description, async () => {
const editor = testCase.editor();
const startDocLength = editor.document.length;
await executeTestCase(editor, testCase);
expect(editor.document.length).toBe(
startDocLength - testCase.baseToolCalls.length,
);
});
}
});
describe("Combined", () => {
for (const testCase of combinedOperationsTestCases) {
it(testCase.description, async () => {
const editor = testCase.editor();
await executeTestCase(editor, testCase);
});
}
});

Here is an example of one of the files which would probably need to be added onto to test that the validation is properly working:

import { getEmptyEditor } from "./editors/emptyEditor.js";
import { getSimpleEditor } from "./editors/simpleEditor.js";
import { DocumentOperationTestCase } from "./index.js";
export const addOperationTestCases: DocumentOperationTestCase[] = [
{
editor: getSimpleEditor,
description: "add a new paragraph (start)",
baseToolCalls: [
{
type: "add",
blocks: [{ content: "You look great today!" }],
referenceId: "ref1",
position: "before",
},
],
userPrompt:
"add a new paragraph with the text 'You look great today!' before the first sentence",
},
{
editor: getSimpleEditor,
description: "add a new paragraph (end)",
baseToolCalls: [
{
type: "add",
blocks: [{ content: "You look great today!" }],
referenceId: "ref2",
position: "after",
},
],
userPrompt:
"add a new paragraph with the text 'You look great today!' after the last sentence",
},
{
editor: getSimpleEditor,
description: "add a list (end)",
baseToolCalls: [
{
type: "add",
blocks: [
{ type: "bulletListItem", content: "Apples" },
{ type: "bulletListItem", content: "Bananas" },
],
referenceId: "ref2",
position: "after",
},
],
userPrompt:
"add a list with the items 'Apples' and 'Bananas' after the last sentence",
},
{
editor: getSimpleEditor,
description: "Add heading (h1) and code block",
baseToolCalls: [
{
type: "add",
blocks: [
{ type: "heading", content: "Code", props: { level: 1 } },
{
type: "codeBlock",
content: "console.log('hello world');",
props: { language: "javascript" },
},
],
referenceId: "ref2",
position: "after",
},
],
userPrompt:
"at the end of doc, add a h1 heading `Code` and a javascript code block with `console.log('hello world');`",
},
// TODO: fix cursor block
// {
// editor: getSimpleEditorWithCursorBetweenBlocks,
// description: "Add heading (based on cursor)",
// baseToolCalls: [
// {
// type: "add",
// blocks: [
// { type: "heading", content: "I love lamp", props: { level: 1 } },
// ],
// referenceId: "ref1",
// position: "after",
// },
// ],
// userPrompt:
// "at the end of doc, add a heading `Code` and a javascript code block with `console.log('hello world');`",
// },
{
editor: getEmptyEditor,
description: "add a new paragraph (empty doc)",
baseToolCalls: [
{
type: "update",
block: { content: "You look great today!" },
id: "ref1",
},
],
userPrompt: `write a new paragraph with the text 'You look great today!'`,
},
];

Thanks for this!

@Hector-Zhuang
Copy link
Contributor Author

@nperez0111 The unit test is added.

@nperez0111
Copy link
Contributor

@Hector-Zhuang the test doesn't pass though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants