From 0cd020d6c5b81b44db04655e452544ff2da1de42 Mon Sep 17 00:00:00 2001 From: MT-Mint <798521692@qq.com> Date: Wed, 15 Apr 2026 11:40:16 +0800 Subject: [PATCH] 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 --- .../src/components/workspace/input-box.tsx | 4 +-- frontend/tests/e2e/input-and-compose.spec.ts | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/workspace/input-box.tsx b/frontend/src/components/workspace/input-box.tsx index a90c6b2a..9fe6c7ef 100644 --- a/frontend/src/components/workspace/input-box.tsx +++ b/frontend/src/components/workspace/input-box.tsx @@ -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({ diff --git a/frontend/tests/e2e/input-and-compose.spec.ts b/frontend/tests/e2e/input-and-compose.spec.ts index b4a6a02e..6de5b93c 100644 --- a/frontend/tests/e2e/input-and-compose.spec.ts +++ b/frontend/tests/e2e/input-and-compose.spec.ts @@ -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(); + }); });