Wenchao An 4c05e88c52
feat: add inline @ references with multiple skill activation (#6063)
* feat(frontend): unify composer references with an @ picker

* feat: edit references inline and activate multiple skills

* docs: describe inline references and multiple skill selection

* fix: prevent sent drafts from returning and repair CI checks

* fix: reconcile inline references and address review feedback

* fix: preserve references through discovery errors and polish
2026-09-30 23:09:05 +08:00

37 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from "@rstest/core";
import { getMentionQuery } from "@/components/workspace/mentions/query";
describe("composer mention query", () => {
it("replaces only the query at the caret, keeping both sides of the draft", () => {
const text = "请使用 @research 分析结果";
const caret = text.indexOf(" 分析");
const query = getMentionQuery(text, caret)!;
expect(query.query).toBe("research");
});
it("allows Unicode and filenames", () => {
expect(getMentionQuery("@报告.pdf", 7)?.query).toBe("报告.pdf");
expect(getMentionQuery("(@报告", 4)?.query).toBe("报告");
});
it("does not activate in an email, URL, or completed text", () => {
for (const text of [
"a@example.com",
"https://host/@name",
"@name ",
"@@name",
"path/@name",
]) {
expect(getMentionQuery(text, text.length)).toBeNull();
}
});
it("keeps an unselected query as literal text", () => {
const text = "@unknown";
expect(getMentionQuery(text, text.length)).toEqual({
start: 0,
end: 8,
query: "unknown",
});
expect(text).toBe("@unknown");
});
});