Introduce ComposerPromptEditor component using Lexical for rich text editing with @-mention support for files. Includes mention detection utilities and tests. Co-Authored-By: Claude Opus 4.5 <[email protected]>
28 lines
983 B
TypeScript
28 lines
983 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { splitPromptIntoComposerSegments } from "./composer-editor-mentions";
|
|
|
|
describe("splitPromptIntoComposerSegments", () => {
|
|
it("splits mention tokens followed by whitespace into mention segments", () => {
|
|
expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md please")).toEqual([
|
|
{ type: "text", text: "Inspect " },
|
|
{ type: "mention", path: "AGENTS.md" },
|
|
{ type: "text", text: " please" },
|
|
]);
|
|
});
|
|
|
|
it("does not convert an incomplete trailing mention token", () => {
|
|
expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md")).toEqual([
|
|
{ type: "text", text: "Inspect @AGENTS.md" },
|
|
]);
|
|
});
|
|
|
|
it("keeps newlines around mention tokens", () => {
|
|
expect(splitPromptIntoComposerSegments("one\n@src/index.ts \ntwo")).toEqual([
|
|
{ type: "text", text: "one\n" },
|
|
{ type: "mention", path: "src/index.ts" },
|
|
{ type: "text", text: " \ntwo" },
|
|
]);
|
|
});
|
|
});
|