feat(06-04): render inline references and enforce 6-item limit
- keep reference previews inside textarea area with dedicated UI - replace reference cap and toast copy from 10 to 6 - add e2e coverage for sixth-limit blocking behavior
This commit is contained in:
parent
5dd13df45f
commit
0cd020d6c5
|
|
@ -89,7 +89,7 @@ import { Tooltip } from "./tooltip";
|
|||
import { useThread } from "./messages/context";
|
||||
import type { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
|
||||
|
||||
const MAX_REFERENCES_PER_MESSAGE = 10;
|
||||
const MAX_REFERENCES_PER_MESSAGE = 6;
|
||||
|
||||
type MentionCandidate = {
|
||||
key: string;
|
||||
|
|
@ -331,7 +331,7 @@ export function InputBox({
|
|||
return prev;
|
||||
}
|
||||
if (prev.length >= MAX_REFERENCES_PER_MESSAGE) {
|
||||
toast.error("单条消息最多引用 10 个文件");
|
||||
toast.error("单条消息最多引用 6 个文件");
|
||||
return prev;
|
||||
}
|
||||
return prev.concat({
|
||||
|
|
|
|||
|
|
@ -155,4 +155,39 @@ test.describe("聊天工作台 / 输入区与发送", () => {
|
|||
// 该场景依赖特定后端/fixture 能制造 stale 引用;若环境无能力则显式跳过。
|
||||
testInfo.skip(true, "当前 E2E 环境无法稳定注入 stale 引用,使用 hooks 单测覆盖软失败逻辑。");
|
||||
});
|
||||
|
||||
test("DF-INPUT-009 引用上限为 6,第 7 个被阻止并提示", async (
|
||||
{ page },
|
||||
testInfo,
|
||||
) => {
|
||||
skipIfMissingThread(testInfo, THREAD_FOR_WELCOME, "FRONTEND_E2E_THREAD_ID");
|
||||
await openChat(page, reuseThreadChatEntry(THREAD_FOR_WELCOME!));
|
||||
|
||||
const textarea = page.locator("textarea[name='message']");
|
||||
await textarea.click();
|
||||
await textarea.fill("请参考这些文件 ");
|
||||
|
||||
await textarea.type("@");
|
||||
const panel = page.getByTestId("mention-candidate-panel").first();
|
||||
await expect(panel).toBeVisible();
|
||||
const initialItems = panel.locator("button");
|
||||
const candidateCount = await initialItems.count();
|
||||
testInfo.skip(candidateCount < 7, "当前线程候选文件不足 7 个,无法验证上限。");
|
||||
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
await textarea.type("@");
|
||||
const currentPanel = page.getByTestId("mention-candidate-panel").first();
|
||||
await expect(currentPanel).toBeVisible();
|
||||
await currentPanel.locator("button").nth(i).click();
|
||||
}
|
||||
|
||||
await expect(page.getByLabel("移除引用")).toHaveCount(6);
|
||||
|
||||
await textarea.type("@");
|
||||
await expect(panel).toBeVisible();
|
||||
await panel.locator("button").nth(6).click();
|
||||
|
||||
await expect(page.getByLabel("移除引用")).toHaveCount(6);
|
||||
await expect(page.getByText("单条消息最多引用 6 个文件")).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue