🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(eval): capture a conversation turn as an eval case (#18889)
Arvin Xu4dd7a725628f
diff --git a/.agents/acceptance/common-mistakes.md b/.agents/acceptance/common-mistakes.mdindex ee4e5fdb3ad..fec498934b8 100644--- a/.agents/acceptance/common-mistakes.md+++ b/.agents/acceptance/common-mistakes.md@@ -485,6 +485,25 @@ non-negative overflow is a defect regardless of how the screenshot reads. Boundby the space the positioner publishes (`--available-height`, less the popup's own chrome)rather than relying on collision flipping.+### L-D12 — Assuming a menu dispatches an item just because it rendered++**Wrong approach:** add an entry to a message/context menu — especially a nested one under a+submenu — confirm from a screenshot that the label and icon appear where intended, and call+the entry verified.++**Why it fails:** menu rendering and menu dispatch are separate contracts here. The dropdown+only invokes an item that carries its own `onClick`, and the group wrapper attaches one to+top-level items only, so a nested child renders perfectly and does nothing when clicked — the+menu just closes, with no error, no toast, and no console output. Any routing the consumer+writes on the parent's side (by `keyPath` or otherwise) never runs, because the click was+dropped before it. A screenshot of an open submenu therefore proves placement and nothing+else.++**Correct approach:** for every menu entry you add, click it and assert the effect it is+supposed to have — a dialog opens, a request fires, a store field changes. Treat "the menu+closed and nothing happened" as the expected failure signature, not as a missed click. When+the entry is nested, verify the child's own dispatch wiring, not the parent's.+## Environment safety### L-S0 — Concluding a dependency moved from the root manifest alonediff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 1b7e519de83..a9b07b1a6df 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -983,9 +983,11 @@"mention.category.topics": "Topics","mention.category.workspaceAgents": "Workspace","mention.title": "Mention Members",+ "messageAction.advanced": "Advanced","messageAction.collapse": "Collapse Message","messageAction.continueGeneration": "Continue Generating","messageAction.continueGenerationUnsupported": "The current model doesn’t support continuing an assistant message. Try regenerating instead.",+ "messageAction.copyMessageId": "Copy Message ID","messageAction.copyOperationId": "Copy Operation ID","messageAction.delAndRegenerate": "Delete and Regenerate","messageAction.deleteDisabledByThreads": "This message has a subtopic and can’t be deleted",@@ -995,6 +997,8 @@"messageAction.reaction": "Add Reaction","messageAction.regenerate": "Regenerate","messageAction.regenerateAlreadyRunning": "This message is already being regenerated.",+ "messageAction.saveAsEvalCase.label": "Save as eval case",+ "messageAction.saveAsEvalCase.notCapturable": "This answer has no user turn before it, so it cannot be captured as a case.","messageAction.select": "Select","messageForward.bar.cancel": "Cancel","messageForward.bar.delete": "Delete",diff --git a/locales/en-US/eval.json b/locales/en-US/eval.jsonindex cf598330d9c..7b2c99ade60 100644--- a/locales/en-US/eval.json+++ b/locales/en-US/eval.json@@ -65,6 +65,30 @@"benchmark.edit.success": "Benchmark updated successfully","benchmark.edit.title": "Edit Benchmark","benchmark.empty": "No benchmarks yet. Create one to get started.",+ "capture.actual": "What it answered",+ "capture.captured": "Captured content",+ "capture.counterExample": "counter-example",+ "capture.counterExampleHint": "Kept as a counter-example for the judge. It is not written to \"Expected output\".",+ "capture.criteria": "Criteria",+ "capture.criteriaHint": "The judge does not see the prior context, so the criteria has to stand on its own.",+ "capture.criteriaPlaceholder": "What must a good answer do? e.g. it must not treat the user as the author of the quoted message.",+ "capture.criteriaRequired": "Write what a good answer must do",+ "capture.dataset": "Dataset",+ "capture.datasetPlaceholder": "Choose a dataset",+ "capture.datasetRequired": "Choose a dataset",+ "capture.done": "Done",+ "capture.error": "Failed to save the test case",+ "capture.expected": "Expected output",+ "capture.expectedPlaceholder": "Leave empty when you do not know the right answer — it is scored by the criteria alone",+ "capture.input": "Input",+ "capture.kind.negative": "Counter-example",+ "capture.kind.positive": "Good example",+ "capture.notCapturable": "This answer has no user turn before it, so it cannot be captured as a case.",+ "capture.positiveHint": "Kept as the expected output — the answer a good one should match.",+ "capture.save": "Save",+ "capture.saved": "Saved as a test case",+ "capture.title": "Save as eval case",+ "capture.view": "View now","caseDetail.actual": "Actual Output","caseDetail.chatArea.title": "Conversation","caseDetail.completionReason": "Status",@@ -441,6 +465,7 @@"testCaseDetail.expected": "Expected output","testCaseDetail.expected.empty": "Not set — scored by the criteria alone.","testCaseDetail.expected.placeholder": "Leave empty when there is no single right answer.",+ "testCaseDetail.expectedFromCapture": "Captured from the conversation as a good example.","testCaseDetail.notFound": "This test case no longer exists.","testCaseDetail.open": "Open case","testCaseDetail.role.assistant": "Assistant",diff --git a/locales/en-US/labs.json b/locales/en-US/labs.jsonindex 932159857f7..d30b72bd874 100644--- a/locales/en-US/labs.json+++ b/locales/en-US/labs.json@@ -16,6 +16,8 @@"features.codexAppServer.title": "Codex App Server Runtime","features.desktopSplitView.desc": "Show two desktop tabs side by side, with independent navigation and a resizable divider.","features.desktopSplitView.title": "Split Tab View",+ "features.evalCapture.desc": "Adds a message action that captures a conversation turn — its prior context, input and the answer it produced — as an evaluation test case.",+ "features.evalCapture.title": "Save a turn as an eval case","features.groupChat.desc": "Enable multi-agent group chat coordination.","features.groupChat.title": "Group Chat (Multi-Agent)","features.heteroSessionImport.desc": "Add an \"Import Local Agent Sessions\" entry to the topic list menu: scan local Claude Code / Codex CLI transcripts and import them as topics, with incremental sync on re-import.",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex a507057bda9..db2bab979e0 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -983,9 +983,11 @@"mention.category.topics": "话题","mention.category.workspaceAgents": "工作区","mention.title": "提及成员",+ "messageAction.advanced": "高级操作","messageAction.collapse": "收起消息","messageAction.continueGeneration": "继续生成","messageAction.continueGenerationUnsupported": "当前模型不支持继续生成助理消息,请尝试重新生成。",+ "messageAction.copyMessageId": "复制 Message ID","messageAction.copyOperationId": "复制 Operation ID","messageAction.delAndRegenerate": "删除并重新生成","messageAction.deleteDisabledByThreads": "该消息有子话题,无法删除",@@ -995,6 +997,8 @@"messageAction.reaction": "添加表情","messageAction.regenerate": "重新生成","messageAction.regenerateAlreadyRunning": "该消息正在重新生成中。",+ "messageAction.saveAsEvalCase.label": "保存为评测用例",+ "messageAction.saveAsEvalCase.notCapturable": "这条回答之前没有用户提问,无法作为用例捕获。","messageAction.select": "多选","messageForward.bar.cancel": "取消","messageForward.bar.delete": "删除",diff --git a/locales/zh-CN/eval.json b/locales/zh-CN/eval.jsonindex 6fc684daa37..94d8821f9bf 100644--- a/locales/zh-CN/eval.json+++ b/locales/zh-CN/eval.json@@ -65,6 +65,30 @@"benchmark.edit.success": "基准更新成功","benchmark.edit.title": "编辑基准","benchmark.empty": "暂无基准,请先创建一个。",+ "capture.actual": "实际输出",+ "capture.captured": "捕获内容",+ "capture.counterExample": "反例",+ "capture.counterExampleHint": "存为反例供判官参照,不会写入「期望输出」。",+ "capture.criteria": "判定标准",+ "capture.criteriaHint": "判官看不到前置上下文,标准需自包含。",+ "capture.criteriaPlaceholder": "合格的回答必须做到什么?例如:不得把用户当成被引用消息的作者。",+ "capture.criteriaRequired": "请写明合格回答必须做到什么",+ "capture.dataset": "数据集",+ "capture.datasetPlaceholder": "选择数据集",+ "capture.datasetRequired": "请选择数据集",+ "capture.done": "完成",+ "capture.error": "保存测试用例失败",+ "capture.expected": "期望输出",+ "capture.expectedPlaceholder": "不知道正确答案时留空 —— 仅按判定标准打分",+ "capture.input": "本轮输入",+ "capture.kind.negative": "反例",+ "capture.kind.positive": "正例",+ "capture.notCapturable": "这条回答之前没有用户提问,无法作为用例捕获。",+ "capture.positiveHint": "存为「期望输出」—— 合格回答应当对齐的答案。",+ "capture.save": "保存",+ "capture.saved": "已保存为测试用例",+ "capture.title": "保存为评测用例",+ "capture.view": "立即查看","caseDetail.actual": "实际输出","caseDetail.chatArea.title": "对话记录","caseDetail.completionReason": "状态",@@ -441,6 +465,7 @@"testCaseDetail.expected": "期望输出","testCaseDetail.expected.empty": "未填写 —— 仅按判定标准打分。","testCaseDetail.expected.placeholder": "没有唯一正确答案时留空。",+ "testCaseDetail.expectedFromCapture": "捕获自对话中的这条回答,作为正例。","testCaseDetail.notFound": "该测试用例已不存在。","testCaseDetail.open": "打开用例","testCaseDetail.role.assistant": "助手",diff --git a/locales/zh-CN/labs.json b/locales/zh-CN/labs.jsonindex 463e1db319d..d6b969447b2 100644--- a/locales/zh-CN/labs.json+++ b/locales/zh-CN/labs.json@@ -16,6 +16,8 @@"features.codexAppServer.title": "Codex App Server 运行时","features.desktopSplitView.desc": "在桌面端并排显示两个标签页,支持独立导航和拖拽调整分栏宽度。","features.desktopSplitView.title": "标签页分栏",+ "features.evalCapture.desc": "在消息动作里增加一项,把一轮对话(前置上下文、本轮输入与它产生的回答)捕获成评测用例。",+ "features.evalCapture.title": "把对话保存为评测用例","features.groupChat.desc": "启用多代理协同群聊功能。","features.groupChat.title": "群聊(多代理)","features.heteroSessionImport.desc": "在话题列表菜单中新增「导入本地 Agent 会话」入口:扫描本地 Claude Code / Codex CLI 的会话记录并导入为话题,重复导入时增量同步新消息。",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex ad815598083..ae5ce173bc9 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -698,7 +698,12 @@ export default {'messageAction.continueGeneration': 'Continue Generating','messageAction.continueGenerationUnsupported':'The current model doesn’t support continuing an assistant message. Try regenerating instead.',+ 'messageAction.advanced': 'Advanced',+ 'messageAction.copyMessageId': 'Copy Message ID','messageAction.copyOperationId': 'Copy Operation ID',+ 'messageAction.saveAsEvalCase.label': 'Save as eval case',+ 'messageAction.saveAsEvalCase.notCapturable':+ 'This answer has no user turn before it, so it cannot be captured as a case.','messageAction.delAndRegenerate': 'Delete and Regenerate','messageAction.regenerateAlreadyRunning': 'This message is already being regenerated.','messageAction.interrupted': 'Interrupted',diff --git a/packages/locales/src/default/eval.ts b/packages/locales/src/default/eval.tsindex 87f37f322b2..c2a66bc775e 100644--- a/packages/locales/src/default/eval.ts+++ b/packages/locales/src/default/eval.ts@@ -184,6 +184,35 @@ export default {'dataset.import.upload.text': 'Click or drag file here to upload','dataset.import.uploading': 'Uploading...','dataset.detail.backToEval': 'Back to Eval',+ 'capture.actual': 'What it answered',+ 'capture.captured': 'Captured content',+ 'capture.counterExample': 'counter-example',+ 'capture.counterExampleHint':+ 'Kept as a counter-example for the judge. It is not written to "Expected output".',+ 'capture.kind.negative': 'Counter-example',+ 'capture.kind.positive': 'Good example',+ 'capture.positiveHint': 'Kept as the expected output — the answer a good one should match.',+ 'capture.criteria': 'Criteria',+ 'capture.criteriaHint':+ 'The judge does not see the prior context, so the criteria has to stand on its own.',+ 'capture.criteriaPlaceholder':+ 'What must a good answer do? e.g. it must not treat the user as the author of the quoted message.',+ 'capture.criteriaRequired': 'Write what a good answer must do',+ 'capture.dataset': 'Dataset',+ 'capture.datasetPlaceholder': 'Choose a dataset',+ 'capture.datasetRequired': 'Choose a dataset',+ 'capture.done': 'Done',+ 'capture.error': 'Failed to save the test case',+ 'capture.expected': 'Expected output',+ 'capture.expectedPlaceholder':+ 'Leave empty when you do not know the right answer \u2014 it is scored by the criteria alone',+ 'capture.input': 'Input',+ 'capture.notCapturable':+ 'This answer has no user turn before it, so it cannot be captured as a case.',+ 'capture.save': 'Save',+ 'capture.saved': 'Saved as a test case',+ 'capture.title': 'Save as eval case',+ 'capture.view': 'View now','dataset.detail.backToBenchmark': 'Back to Benchmark','dataset.detail.caseCount': '{{count}} test case{{count, plural, one {} other {s}}}','dataset.detail.addRun': 'New Run',@@ -475,6 +504,7 @@ export default {'testCaseDetail.expected': 'Expected output','testCaseDetail.expected.empty': 'Not set \u2014 scored by the criteria alone.','testCaseDetail.expected.placeholder': 'Leave empty when there is no single right answer.',+ 'testCaseDetail.expectedFromCapture': 'Captured from the conversation as a good example.','testCaseDetail.open': 'Open case','testCaseDetail.notFound': 'This test case no longer exists.','testCaseDetail.saveFailed': 'Could not save this case.',diff --git a/packages/locales/src/default/labs.ts b/packages/locales/src/default/labs.tsindex af7df865bc4..1d924ad48ed 100644--- a/packages/locales/src/default/labs.ts+++ b/packages/locales/src/default/labs.ts@@ -27,6 +27,9 @@ export default {'features.desktopSplitView.title': 'Split Tab View','features.heteroSessionImport.desc':'Add an "Import Local Agent Sessions" entry to the topic list menu: scan local Claude Code / Codex CLI transcripts and import them as topics, with incremental sync on re-import.',+ 'features.evalCapture.desc':+ 'Adds a message action that captures a conversation turn — its prior context, input and the answer it produced — as an evaluation test case.',+ 'features.evalCapture.title': 'Save a turn as an eval case','features.heteroSessionImport.title': 'Local Agent Session Import','features.imessage.desc':'Connect agents to iMessage through the local LobeHub Desktop BlueBubbles bridge.',diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.tsindex f0f2e0de1a9..c18005371e7 100644--- a/packages/types/src/user/preference.ts+++ b/packages/types/src/user/preference.ts@@ -220,6 +220,8 @@ export const UserLabSchema = z.object({* enable the task delivery-acceptance (verify) config UI on the task detail*/enableTaskVerify: z.boolean().optional(),+ /** Capture a conversation turn as an eval test case (developer-facing). */+ enableEvalCapture: z.boolean().optional(),/*** enable the per-topic acceptance tray above the composer (author a topic's* delivery checklist inline)diff --git a/src/features/Conversation/Messages/Assistant/Actions/index.tsx b/src/features/Conversation/Messages/Assistant/Actions/index.tsxindex 9070a8c8713..fea35c11fe7 100644--- a/src/features/Conversation/Messages/Assistant/Actions/index.tsx+++ b/src/features/Conversation/Messages/Assistant/Actions/index.tsx@@ -12,10 +12,18 @@ import {const DEFAULT_BAR_WITH_TOOLS: MessageActionSlot[] = ['delAndRegenerate', 'copy'];const DEFAULT_BAR: MessageActionSlot[] = ['edit', 'copy'];+// The developer-facing actions live one level down, under Advanced: each is+// gated (dev mode, Labs) and rare, so flat they were noise in the menu that+// every user opens. It sits with the other utilities rather than after Delete —+// trailing the destructive group made a debugging aid read as a last resort.+// The submenu drops itself when none of its children apply.+const ADVANCED_GROUP: MessageActionSlot = {+ children: ['copyMessageId', 'copyOperationId', 'saveAsEvalCase'],+ key: 'advanced',+};const DEFAULT_MENU: MessageActionSlot[] = ['edit','copy',- 'copyOperationId','comments','branching','collapse',@@ -26,6 +34,8 @@ const DEFAULT_MENU: MessageActionSlot[] = ['share','select','divider',+ ADVANCED_GROUP,+ 'divider','regenerate','delAndRegenerate','del',diff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/advanced.test.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/advanced.test.tsnew file mode 100644index 00000000000..8b99800ec55--- /dev/null+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/advanced.test.ts@@ -0,0 +1,52 @@+/**+ * @vitest-environment happy-dom+ */+import type { UIChatMessage } from '@lobechat/types';+import { renderHook } from '@testing-library/react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { advancedAction } from './advanced';++const mocks = vi.hoisted(() => ({ isDevMode: true }));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock('@/store/user', () => ({+ useUserStore: (selector: (state: unknown) => unknown) => selector({}),+}));++vi.mock('@/store/user/selectors', () => ({+ userGeneralSettingsSelectors: {+ config: () => ({ isDevMode: mocks.isDevMode }),+ },+}));++const build = () =>+ renderHook(() =>+ advancedAction.useBuild({+ data: { content: 'Hello', role: 'assistant' } as UIChatMessage,+ id: 'message-1',+ role: 'assistant',+ }),+ ).result.current;++describe('advancedAction', () => {+ beforeEach(() => {+ mocks.isDevMode = true;+ });++ // The drawer is developer-facing as a whole, so the gate lives here rather+ // than on each child — this is what keeps a Labs-only child (capturing an+ // eval case) out of an ordinary user's menu.+ it('is absent when Advanced Tools (dev mode) is off', () => {+ mocks.isDevMode = false;++ expect(build()).toBeNull();+ });++ it('is the submenu shell when Advanced Tools is on', () => {+ expect(build()).toMatchObject({ key: 'advanced', label: 'messageAction.advanced' });+ });+});diff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/advanced.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/advanced.tsnew file mode 100644index 00000000000..678bf5571ce--- /dev/null+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/advanced.ts@@ -0,0 +1,35 @@+import { Wrench } from 'lucide-react';+import { useMemo } from 'react';+import { useTranslation } from 'react-i18next';++import { useUserStore } from '@/store/user';+import { userGeneralSettingsSelectors } from '@/store/user/selectors';++import { defineAction } from '../defineAction';++/**+ * Shell for the "Advanced" submenu — it carries only the label and icon; what+ * it contains is decided by the menu that lists it, and it disappears when+ * none of those children apply.+ *+ * It exists because the developer-facing actions (ids to paste into a trace,+ * capturing a turn as an eval case) are individually rare but collectively a+ * category, and left flat they crowd the menu everyone else uses.+ *+ * The whole drawer is developer-facing, so Advanced Tools gates it here rather+ * than child by child: one place to reason about, and it covers children that+ * carry no dev gate of their own (capturing a case is gated on Labs instead).+ */+export const advancedAction = defineAction({+ key: 'advanced',+ useBuild: () => {+ const { t } = useTranslation('chat');+ const isDevMode = useUserStore((s) => userGeneralSettingsSelectors.config(s).isDevMode);++ return useMemo(+ () =>+ isDevMode ? { icon: Wrench, key: 'advanced', label: t('messageAction.advanced') } : null,+ [t, isDevMode],+ );+ },+});diff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/copyMessageId.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/copyMessageId.tsnew file mode 100644index 00000000000..4603e9382b4--- /dev/null+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/copyMessageId.ts@@ -0,0 +1,39 @@+import { copyToClipboard } from '@lobehub/ui';+import { toast } from '@lobehub/ui/base-ui';+import { Braces } from 'lucide-react';+import { useMemo } from 'react';+import { useTranslation } from 'react-i18next';++import { useUserStore } from '@/store/user';+import { userGeneralSettingsSelectors } from '@/store/user/selectors';++import { defineAction } from '../defineAction';++/**+ * Dev-tool action (visible only with Advanced Tools enabled): copies this+ * message's id — the handle for `lh` queries, eval cases and bug reports.+ *+ * For a group message the useful id is the underlying assistant message, not+ * the aggregate group, same as `copyOperationId`.+ */+export const copyMessageIdAction = defineAction({+ key: 'copyMessageId',+ useBuild: (ctx) => {+ const { t } = useTranslation('chat');+ const isDevMode = useUserStore((s) => userGeneralSettingsSelectors.config(s).isDevMode);+ const messageId = ctx.contentBlock?.id ?? ctx.id;++ return useMemo(() => {+ if (!isDevMode || !messageId) return null;+ return {+ handleClick: async () => {+ await copyToClipboard(messageId);+ toast.success(t('copySuccess', { ns: 'common' }));+ },+ icon: Braces,+ key: 'copyMessageId',+ label: t('messageAction.copyMessageId'),+ };+ }, [t, isDevMode, messageId]);+ },+});diff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.test.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.test.tsindex 0ad0653157e..16bba45721e 100644--- a/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.test.ts+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.test.ts@@ -16,8 +16,8 @@ interface MockOperation {}const mocks = vi.hoisted(() => ({- copyToClipboard: vi.fn(),isDevMode: true,+ copyToClipboard: vi.fn(),messageOperationMap: {} as Record<string, string>,messageSuccess: vi.fn(),operations: {} as Record<string, MockOperation>,@@ -45,6 +45,16 @@ vi.mock('@/store/chat', () => ({}),}));+vi.mock('@/store/user', () => ({+ useUserStore: (selector: (state: unknown) => unknown) => selector({}),+}));++vi.mock('@/store/user/selectors', () => ({+ userGeneralSettingsSelectors: {+ config: () => ({ isDevMode: mocks.isDevMode }),+ },+}));+vi.mock('@/store/chat/selectors', () => ({operationSelectors: {// Test double for the parent-chain walk: climbs `parentOperationId` until@@ -60,16 +70,6 @@ vi.mock('@/store/chat/selectors', () => ({},}));-vi.mock('@/store/user', () => ({- useUserStore: (selector: (state: unknown) => unknown) => selector({}),-}));--vi.mock('@/store/user/selectors', () => ({- userGeneralSettingsSelectors: {- config: () => ({ isDevMode: mocks.isDevMode }),- },-}));-const build = (data: Partial<UIChatMessage> = {},role: MessageActionContext['role'] = 'assistant',diff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.tsindex e0d0ced8587..4adc419d87e 100644--- a/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.ts+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/copyOperationId.ts@@ -13,7 +13,9 @@ import { defineAction } from '../defineAction';/*** Dev-tool action (visible only with Advanced Tools enabled): copies the id of- * the operation that produced this message, for tracing/debugging.+ * the operation that produced this message, for tracing/debugging. It is gated+ * here as well as on the Advanced drawer, because it also appears flat in the+ * error, Task and AssistantGroup menus, which the drawer's gate does not reach.** Resolution order: the creation-provenance stamp persisted on the* block/message (`metadata.operationId`, survives reloads) → the live runtime@@ -27,7 +29,6 @@ export const copyOperationIdAction = defineAction({key: 'copyOperationId',useBuild: (ctx) => {const { t } = useTranslation('chat');-const isDevMode = useUserStore((s) => userGeneralSettingsSelectors.config(s).isDevMode);// For group messages the operation is associated with the underlyingdiff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/saveAsEvalCase.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/saveAsEvalCase.tsnew file mode 100644index 00000000000..f77ca2f97dc--- /dev/null+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/saveAsEvalCase.ts@@ -0,0 +1,63 @@+import { toast } from '@lobehub/ui/base-ui';+import i18next from 'i18next';+import { FlaskConical } from 'lucide-react';+import { useMemo } from 'react';+import { useTranslation } from 'react-i18next';++import { buildCaptureDraft, createEvalCaptureModal } from '@/features/EvalCapture';+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';+import { useUserStore } from '@/store/user';+import { labPreferSelectors } from '@/store/user/selectors';++import { dataSelectors, useConversationStoreApi } from '../../../../store';+import { defineAction } from '../defineAction';++/**+ * Capture this turn as an evaluation test case.+ *+ * Sits next to Regenerate because they are the same gesture aimed differently:+ * regenerate re-asks for another sample, this re-asks for another model and+ * keeps the result. Developer-facing, so it is behind a Labs toggle rather than+ * shown to everyone, and absent on anything but an assistant answer — a user+ * turn is the input to a case, not a case.+ */+export const saveAsEvalCaseAction = defineAction({+ key: 'saveAsEvalCase',+ useBuild: (ctx) => {+ const { t } = useTranslation('chat');+ const enabled = useUserStore(labPreferSelectors.enableEvalCapture);+ const navigate = useWorkspaceAwareNavigate();+ // The conversation store is context-scoped, not a global singleton, so an+ // imperative read needs the store api from context.+ const storeApi = useConversationStoreApi();++ return useMemo(() => {+ if (!enabled || ctx.role !== 'assistant') return null;++ return {+ handleClick: async () => {+ // The modal's own chrome is in the `eval` namespace, which the chat+ // route has never loaded — without this its title and buttons render+ // as raw keys.+ await i18next.loadNamespaces('eval');++ const messages = dataSelectors.displayMessages(storeApi.getState());+ const draft = buildCaptureDraft(messages as never, ctx.id);++ if (!draft) {+ toast.error(t('messageAction.saveAsEvalCase.notCapturable'));+ return;+ }++ createEvalCaptureModal({+ draft,+ onView: (testCaseId) => navigate(`/eval/cases/${testCaseId}`),+ });+ },+ icon: FlaskConical,+ key: 'saveAsEvalCase',+ label: t('messageAction.saveAsEvalCase.label'),+ };+ }, [enabled, ctx.role, ctx.id, t, navigate, storeApi]);+ },+});diff --git a/src/features/Conversation/Messages/components/MessageActionBar/index.test.tsx b/src/features/Conversation/Messages/components/MessageActionBar/index.test.tsxindex 6a312abcf15..7957851d942 100644--- a/src/features/Conversation/Messages/components/MessageActionBar/index.test.tsx+++ b/src/features/Conversation/Messages/components/MessageActionBar/index.test.tsx@@ -12,7 +12,10 @@ const permissionMock = vi.hoisted(() => ({}));const actionMocks = vi.hoisted(() => ({commentsAvailable: true,+ onCopyMessageId: vi.fn(),}));+/** Last `menu` prop handed to ActionIconGroup, so submenu wiring is assertable. */+const rendered = vi.hoisted(() => ({ menu: undefined as any }));vi.mock('@lobehub/ui', async (importOriginal) => ({...(await importOriginal<object>()),@@ -27,14 +30,17 @@ vi.mock('@lobehub/ui', async (importOriginal) => ({style?: React.CSSProperties;variant?: string;}) => (- <div- data-has-menu={String(!!menu)}- data-items={items.map((item) => item.key).join(',')}- data-menu={menu?.map((item) => item.key || item.type).join(',') ?? ''}- data-testid="action-group"- data-variant={variant}- style={style}- />+ (rendered.menu = menu),+ (+ <div+ data-has-menu={String(!!menu)}+ data-items={items.map((item) => item.key).join(',')}+ data-menu={menu?.map((item) => item.key || item.type).join(',') ?? ''}+ data-testid="action-group"+ data-variant={variant}+ style={style}+ />+ )),Block: ({ children }: { children: React.ReactNode }) => (<div data-testid="action-container">{children}</div>@@ -47,6 +53,7 @@ vi.mock('@/hooks/usePermission', () => ({vi.mock('./useBuildActions', () => ({useBuildActions: () => ({+ advanced: { key: 'advanced', label: 'Advanced' },comments: actionMocks.commentsAvailable? {key: 'comments',@@ -54,6 +61,11 @@ vi.mock('./useBuildActions', () => ({}: null,copy: { key: 'copy', label: 'Copy' },+ copyMessageId: {+ handleClick: actionMocks.onCopyMessageId,+ key: 'copyMessageId',+ label: 'Copy Message ID',+ },del: { key: 'del', label: 'Delete' },edit: { key: 'edit', label: 'Edit' },regenerate: { key: 'regenerate', label: 'Regenerate' },@@ -189,4 +201,29 @@ describe('MessageActionBar', () => {expect(screen.getByTestId('action-group')).toHaveAttribute('data-menu', 'edit,divider,del');});++ // The menu never invokes an item that has no `onClick` of its own, and+ // ActionIconGroup only attaches one to top-level items. Without this wiring a+ // submenu entry closes the menu and silently does nothing.+ it('lets a submenu child dispatch itself', () => {+ permissionMock.canEdit = true;+ actionMocks.onCopyMessageId.mockClear();++ render(+ <MessageActionBar+ bar={['copy']}+ menu={[{ children: ['copyMessageId'], key: 'advanced' }]}+ ctx={{+ data: { content: 'hello', role: 'assistant' } as UIChatMessage,+ id: 'message-1',+ role: 'assistant',+ }}+ />,+ );++ const child = rendered.menu?.[0]?.children?.[0];+ expect(child.key).toBe('copyMessageId');+ child.onClick();+ expect(actionMocks.onCopyMessageId).toHaveBeenCalledTimes(1);+ });});diff --git a/src/features/Conversation/Messages/components/MessageActionBar/index.tsx b/src/features/Conversation/Messages/components/MessageActionBar/index.tsxindex 88860d74cf2..d5202409b8e 100644--- a/src/features/Conversation/Messages/components/MessageActionBar/index.tsx+++ b/src/features/Conversation/Messages/components/MessageActionBar/index.tsx@@ -6,12 +6,22 @@ import { memo, useCallback, useMemo } from 'react';import { usePermission } from '@/hooks/usePermission';import { type MessageActionItem, type MessageActionItemOrDivider } from '../../../types';-import { DIVIDER_KEY, type MessageActionContext, type MessageActionSlot } from './types';+import { resolveSlots } from './resolveSlots';+import { type MessageActionContext, type MessageActionSlot } from './types';import { useBuildActions } from './useBuildActions';-const DIVIDER: MessageActionItemOrDivider = { type: 'divider' };const VIEWER_BAR: MessageActionSlot[] = ['copy', 'comments'];+/**+ * Prepares an item for `ActionIconGroup`, which owns dispatch for the items it+ * is handed — our own `handleClick` is not part of that contract, so it is+ * stripped and re-dispatched through `onActionClick`.+ *+ * Submenu children are the exception: `ActionIconGroup` only attaches an+ * `onClick` to top-level menu items, and the underlying menu ignores any item+ * that has none. A nested child therefore has to carry its own — without this,+ * clicking a submenu entry closes the menu and does nothing at all.+ */const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemType => {if ('type' in item && item.type === 'divider') return item as unknown as ActionIconGroupItemType;const { children, ...rest } = item as MessageActionItem;@@ -21,7 +31,7 @@ const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemreturn {...baseItem,children: children.map((child) => {- const nextChild = { ...child } as MessageActionItem;+ const nextChild = { ...child, onClick: () => child.handleClick?.() } as MessageActionItem;delete (nextChild as { handleClick?: unknown }).handleClick;return nextChild;}),@@ -30,48 +40,15 @@ const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemreturn baseItem as ActionIconGroupItemType;};+/** Top-level items by key; submenu children carry their own dispatch. */const buildActionsMap = (items: MessageActionItemOrDivider[]): Map<string, MessageActionItem> => {const map = new Map<string, MessageActionItem>();for (const item of items) {- if ('key' in item && item.key) {- map.set(String(item.key), item as MessageActionItem);- if ('children' in item && item.children) {- for (const child of item.children) {- if (child.key) {- map.set(`${item.key}.${child.key}`, child as unknown as MessageActionItem);- }- }- }- }+ if ('key' in item && item.key) map.set(String(item.key), item as MessageActionItem);}return map;};-const isDivider = (item: MessageActionItemOrDivider) => 'type' in item && item.type === 'divider';--/**- * Resolves slot keys against the built actions. Dividers are declarative- * group boundaries, not literal items: when the actions around one opt out- * (return null), leading/trailing/consecutive dividers are dropped so a- * conditionally hidden group never leaves a dangling separator.- */-const resolveSlots = (- slots: MessageActionSlot[],- built: Record<string, MessageActionItem | null>,-): MessageActionItemOrDivider[] => {- const out: MessageActionItemOrDivider[] = [];- for (const slot of slots) {- if (slot === DIVIDER_KEY) {- if (out.length > 0 && !isDivider(out.at(-1)!)) out.push(DIVIDER);- continue;- }- const item = built[slot];- if (item) out.push(item);- }- while (out.length > 0 && isDivider(out.at(-1)!)) out.pop();- return out;-};-interface MessageActionBarProps {/** Bar slots (always visible as icons) */bar: MessageActionSlot[];@@ -127,18 +104,10 @@ export const MessageActionBar = memo<MessageActionBarProps>(({ ctx, bar, leading[barItems, menuItems],);+ // Submenu children dispatch themselves (see `stripHandleClick`); what reaches+ // here is always a top-level item.const handleAction = useCallback((event: ActionIconGroupEvent) => {- if (event.keyPath && event.keyPath.length > 1) {- const parentKey = event.keyPath.at(-1);- const childKey = event.keyPath[0];- const parent = allActions.get(parentKey!);- if (parent && 'children' in parent && parent.children) {- const child = parent.children.find((c) => c.key === childKey);- child?.handleClick?.();- return;- }- }const action = allActions.get(event.key);action?.handleClick?.();},diff --git a/src/features/Conversation/Messages/components/MessageActionBar/resolveSlots.test.ts b/src/features/Conversation/Messages/components/MessageActionBar/resolveSlots.test.tsnew file mode 100644index 00000000000..561e2247f72--- /dev/null+++ b/src/features/Conversation/Messages/components/MessageActionBar/resolveSlots.test.ts@@ -0,0 +1,72 @@+import { describe, expect, it } from 'vitest';++import { type MessageActionItem } from '../../../types';+import { resolveSlots } from './resolveSlots';++const item = (key: string): MessageActionItem => ({ key, label: key }) as MessageActionItem;++describe('resolveSlots', () => {+ it('resolves plain keys and skips actions that opted out', () => {+ const out = resolveSlots(['copy', 'edit'], { copy: item('copy'), edit: null });+ expect(out).toEqual([item('copy')]);+ });++ it('drops leading, trailing and consecutive dividers', () => {+ const out = resolveSlots(['divider', 'copy', 'divider', 'divider', 'edit', 'divider'], {+ copy: item('copy'),+ edit: item('edit'),+ });+ expect(out).toEqual([item('copy'), { type: 'divider' }, item('edit')]);+ });++ describe('submenu groups', () => {+ it('nests the surviving children under the group action', () => {+ const out = resolveSlots(+ [{ children: ['copyMessageId', 'saveAsEvalCase'], key: 'advanced' }],+ {+ advanced: item('advanced'),+ copyMessageId: item('copyMessageId'),+ saveAsEvalCase: null,+ },+ );+ expect(out).toEqual([{ ...item('advanced'), children: [item('copyMessageId')] }]);+ });++ it('preserves the declared child order', () => {+ const out = resolveSlots([{ children: ['b', 'a'], key: 'advanced' }], {+ a: item('a'),+ advanced: item('advanced'),+ b: item('b'),+ });+ expect((out[0] as MessageActionItem).children?.map((c) => c.key)).toEqual(['b', 'a']);+ });++ // An "Advanced" entry that opens onto nothing is worse than no entry: both+ // children here are gated off (dev mode / Labs), which is the common case.+ it('drops the group entirely when no child survives', () => {+ const out = resolveSlots([{ children: ['copyMessageId'], key: 'advanced' }], {+ advanced: item('advanced'),+ copyMessageId: null,+ });+ expect(out).toEqual([]);+ });++ it('drops the group when the group action itself opted out', () => {+ const out = resolveSlots([{ children: ['copyMessageId'], key: 'advanced' }], {+ advanced: null,+ copyMessageId: item('copyMessageId'),+ });+ expect(out).toEqual([]);+ });++ // The divider before a dropped group must go with it.+ it('does not leave a dangling divider before a dropped group', () => {+ const out = resolveSlots(['copy', 'divider', { children: ['x'], key: 'advanced' }], {+ advanced: item('advanced'),+ copy: item('copy'),+ x: null,+ });+ expect(out).toEqual([item('copy')]);+ });+ });+});diff --git a/src/features/Conversation/Messages/components/MessageActionBar/resolveSlots.ts b/src/features/Conversation/Messages/components/MessageActionBar/resolveSlots.tsnew file mode 100644index 00000000000..9b29965986a--- /dev/null+++ b/src/features/Conversation/Messages/components/MessageActionBar/resolveSlots.ts@@ -0,0 +1,45 @@+import { type MessageActionItem, type MessageActionItemOrDivider } from '../../../types';+import { DIVIDER_KEY, type MessageActionSlot } from './types';++const DIVIDER: MessageActionItemOrDivider = { type: 'divider' };++const isDivider = (item: MessageActionItemOrDivider) => 'type' in item && item.type === 'divider';++/**+ * Resolves slot keys against the built actions. Dividers are declarative+ * group boundaries, not literal items: when the actions around one opt out+ * (return null), leading/trailing/consecutive dividers are dropped so a+ * conditionally hidden group never leaves a dangling separator.+ *+ * A submenu slot follows the same rule one level down — it disappears entirely+ * when none of its children survive, so an empty "Advanced" entry can never be+ * opened onto nothing.+ */+export const resolveSlots = (+ slots: MessageActionSlot[],+ built: Record<string, MessageActionItem | null>,+): MessageActionItemOrDivider[] => {+ const out: MessageActionItemOrDivider[] = [];+ for (const slot of slots) {+ if (slot === DIVIDER_KEY) {+ if (out.length > 0 && !isDivider(out.at(-1)!)) out.push(DIVIDER);+ continue;+ }++ if (typeof slot === 'object') {+ const parent = built[slot.key];+ if (!parent) continue;+ const children = slot.children+ .map((key) => built[key])+ .filter((child): child is MessageActionItem => Boolean(child));+ if (children.length === 0) continue;+ out.push({ ...parent, children });+ continue;+ }++ const item = built[slot];+ if (item) out.push(item);+ }+ while (out.length > 0 && isDivider(out.at(-1)!)) out.pop();+ return out;+};diff --git a/src/features/Conversation/Messages/components/MessageActionBar/types.ts b/src/features/Conversation/Messages/components/MessageActionBar/types.tsindex 9e6bdadfc84..d63de22465b 100644--- a/src/features/Conversation/Messages/components/MessageActionBar/types.ts+++ b/src/features/Conversation/Messages/components/MessageActionBar/types.ts@@ -24,10 +24,24 @@ export interface MessageActionDefinition {useBuild: (ctx: MessageActionContext) => MessageActionItem | null;}+/**+ * A submenu: one entry in the menu that opens a nested list of actions.+ *+ * The children are ordinary action keys, so a grouped action stays a normal+ * registry entry — grouping is a property of the menu that shows it, not of+ * the action.+ */+export interface MessageActionGroupSlot {+ /** Action keys to nest, in order. */+ children: string[];+ /** Registry key of the action that provides the submenu's label and icon. */+ key: string;+}+/*** Slot in a bar/menu list. A string is an action key; `'divider'` inserts a- * divider.+ * divider; an object nests its children in a submenu.*/-export type MessageActionSlot = string;+export type MessageActionSlot = string | MessageActionGroupSlot;export const DIVIDER_KEY = 'divider';diff --git a/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts b/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.tsindex 453dac29ab6..7299c173f29 100644--- a/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts+++ b/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts@@ -1,16 +1,19 @@import { useConversationResourceAccess } from '../../../hooks/useConversationResourceAccess';import { type MessageActionItem } from '../../../types';+import { advancedAction } from './actions/advanced';import { branchingAction } from './actions/branching';import { collapseAction } from './actions/collapse';import { commentsAction } from './actions/comments';import { continueGenerationAction } from './actions/continueGeneration';import { copyAction } from './actions/copy';+import { copyMessageIdAction } from './actions/copyMessageId';import { copyOperationIdAction } from './actions/copyOperationId';import { delAction } from './actions/del';import { delAndRegenerateAction } from './actions/delAndRegenerate';import { editAction } from './actions/edit';import { regenerateAction } from './actions/regenerate';import { restoreToInputAction } from './actions/restoreToInput';+import { saveAsEvalCaseAction } from './actions/saveAsEvalCase';import { selectAction } from './actions/select';import { shareAction } from './actions/share';import { translateAction } from './actions/translate';@@ -35,17 +38,20 @@ export const useBuildActions = (const { canUseResource } = useConversationResourceAccess();const actions: Record<string, MessageActionItem | null> = {+ advanced: advancedAction.useBuild(ctx),branching: branchingAction.useBuild(ctx),collapse: collapseAction.useBuild(ctx),comments: commentsAction.useBuild(ctx),continueGeneration: continueGenerationAction.useBuild(ctx),copy: copyAction.useBuild(ctx),+ copyMessageId: copyMessageIdAction.useBuild(ctx),copyOperationId: copyOperationIdAction.useBuild(ctx),del: delAction.useBuild(ctx),delAndRegenerate: delAndRegenerateAction.useBuild(ctx),edit: editAction.useBuild(ctx),regenerate: regenerateAction.useBuild(ctx),restoreToInput: restoreToInputAction.useBuild(ctx),+ saveAsEvalCase: saveAsEvalCaseAction.useBuild(ctx),select: selectAction.useBuild(ctx),share: shareAction.useBuild(ctx),translate: translateAction.useBuild(ctx),diff --git a/src/features/Conversation/types/ui.ts b/src/features/Conversation/types/ui.tsindex d276ed3286b..aa869b3b058 100644--- a/src/features/Conversation/types/ui.ts+++ b/src/features/Conversation/types/ui.ts@@ -19,7 +19,12 @@ export type RenderItem = FC<{ key: string } & UIChatMessage & ListItemProps>;* Action item with click handler*/export interface MessageActionItem extends ActionIconGroupItemType {- children?: Array<{ handleClick?: () => void; key: string; label: string }>;+ /**+ * Submenu entries. Full actions rather than a narrower shape: a nested item+ * carries the same icon and label as it would at the top level, since the+ * same registered action can appear either way.+ */+ children?: MessageActionItem[];handleClick?: () => void | Promise<void>;}diff --git a/src/features/EvalCapture/CaptureContent.tsx b/src/features/EvalCapture/CaptureContent.tsxnew file mode 100644index 00000000000..71abf38b2da--- /dev/null+++ b/src/features/EvalCapture/CaptureContent.tsx@@ -0,0 +1,268 @@+'use client';++import { Flexbox, Icon, TextArea } from '@lobehub/ui';+import { Segmented, Select, Text, toast } from '@lobehub/ui/base-ui';+import { Divider, Form } from 'antd';+import { createStaticStyles, cssVar } from 'antd-style';+import { ChevronRight } from 'lucide-react';+import { type FC, useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { agentEvalService } from '@/services/agentEval';++import { type CaptureDraft } from './buildCaptureDraft';+import { buildCapturePayload, type CapturedOutputKind } from './buildCapturePayload';++const styles = createStaticStyles(({ css }) => ({+ body: css`+ overflow: hidden;+ max-height: calc(78vh - 180px);+ `,+ label: css`+ font-size: ${cssVar.fontSizeSM};+ font-weight: 500;+ color: ${cssVar.colorTextSecondary};+ `,+ left: css`+ overflow-y: auto;+ flex: 0 0 46%;+ max-height: calc(78vh - 180px);+ padding-inline-end: 8px;+ `,+ msgBody: css`+ overflow-y: auto;++ /* Capped so one long turn cannot push the rest out of view; the full text+ stays reachable by scrolling inside the block. */+ max-height: 200px;+ padding-block: 10px;+ padding-inline: 12px;+ border-radius: 10px;++ font-size: ${cssVar.fontSize};+ line-height: 1.75;+ white-space: pre-wrap;++ background: ${cssVar.colorFillQuaternary};+ `,+ msgBodyMuted: css`+ overflow-y: auto;++ max-height: 96px;+ padding-block: 8px;+ padding-inline: 12px;+ border-radius: 10px;++ font-size: ${cssVar.fontSizeSM};+ line-height: 1.7;+ color: ${cssVar.colorTextTertiary};+ white-space: pre-wrap;++ background: ${cssVar.colorFillQuaternary};+ `,+ kind: css`+ /* Sized down to sit with the label it qualifies rather than compete with it. */+ font-size: ${cssVar.fontSizeSM};++ [role='tab'],+ button {+ padding-block: 1px;+ padding-inline: 8px;+ }+ `,+ msgHead: css`+ font-size: ${cssVar.fontSizeSM};+ font-weight: 500;+ color: ${cssVar.colorTextTertiary};+ `,+ chevron: css`+ transition: transform 0.15s ease;+ `,+ chevronOpen: css`+ transform: rotate(90deg);+ `,+ contextToggle: css`+ cursor: pointer;++ display: flex;+ gap: 6px;+ align-items: center;+ align-self: flex-start;++ padding: 0;+ border: none;++ font-size: ${cssVar.fontSizeSM};+ color: ${cssVar.colorTextTertiary};++ background: transparent;++ &:hover {+ color: ${cssVar.colorText};+ }+ `,+ right: css`+ overflow-y: auto;+ flex: 1;+ max-height: calc(78vh - 180px);+ padding-inline-end: 8px;+ `,+}));++export interface CaptureContentProps {+ draft: CaptureDraft;+ formId: string;+ onLoadingChange?: (loading: boolean) => void;+ onSaved: (testCaseId: string, datasetName: string) => void;+}++const ROLE_KEYS: Record<string, string> = {+ assistant: 'testCaseDetail.role.assistant',+ system: 'testCaseDetail.role.system',+ tool: 'testCaseDetail.role.tool',+ user: 'testCaseDetail.role.user',+};++const CaptureContent: FC<CaptureContentProps> = ({ draft, formId, onLoadingChange, onSaved }) => {+ const { t } = useTranslation('eval');+ const roleLabel = (role: string) => (ROLE_KEYS[role] ? t(ROLE_KEYS[role] as never) : role);+ const [form] = Form.useForm();+ const [datasets, setDatasets] = useState<Array<{ id: string; name: string }>>([]);+ const [contextOpen, setContextOpen] = useState(false);+ // A capture is usually a complaint, so the counter-example is the default —+ // but the same gesture is used to keep an answer that was right.+ const [kind, setKind] = useState<CapturedOutputKind>('negative');++ // Switching to "good example" fills the expected answer in, so what will be+ // saved is on screen rather than implied. Switching back only clears it when+ // it is still that same text — never something typed since.+ const handleKindChange = (next: CapturedOutputKind) => {+ setKind(next);+ const current = form.getFieldValue('expected');+ if (next === 'positive' && !current?.trim()) form.setFieldValue('expected', draft.actualOutput);+ if (next === 'negative' && current === draft.actualOutput) form.setFieldValue('expected', '');+ };++ useEffect(() => {+ // Every dataset is a valid destination, benchmark-owned or not — one list,+ // rather than fanning out per benchmark and stitching the halves together.+ void agentEvalService+ .listAllDatasets()+ .then((all) => setDatasets((all ?? []) as Array<{ id: string; name: string }>))+ .catch(() => setDatasets([]));+ }, []);++ const handleFinish = async (values: any) => {+ onLoadingChange?.(true);+ try {+ const created = await agentEvalService.createTestCase(+ buildCapturePayload(draft, values, kind),+ );++ const dataset = datasets.find((d) => d.id === values.datasetId);+ // Hands the modal over to its success phase. Deliberately not followed by+ // a `finally` that clears loading: that would re-render the form footer+ // over the success one the phase switch just installed.+ onSaved(created.id, dataset?.name ?? '');+ } catch {+ toast.error(t('capture.error'));+ onLoadingChange?.(false);+ }+ };++ return (+ <Flexbox horizontal className={styles.body} gap={16}>+ {/* Left: what is being captured — read-only, just verify it. */}+ <Flexbox className={styles.left} gap={12}>+ <span className={styles.label}>{t('capture.captured')}</span>+ {/* Collapsed by default: it is what the turn was said into, not what is+ being judged, and expanded it buries both below the fold. */}+ {draft.context.length > 0 && (+ <button+ className={styles.contextToggle}+ type="button"+ onClick={() => setContextOpen((v) => !v)}+ >+ <Icon+ className={contextOpen ? `${styles.chevron} ${styles.chevronOpen}` : styles.chevron}+ icon={ChevronRight}+ size={14}+ />+ {t('testCaseDetail.context', { count: draft.context.length })}+ </button>+ )}+ {contextOpen &&+ draft.context.map((message, index) => (+ <Flexbox gap={4} key={index}>+ <span className={styles.msgHead}>{roleLabel(message.role)}</span>+ <div className={styles.msgBodyMuted}>{message.content}</div>+ </Flexbox>+ ))}+ <Flexbox gap={4}>+ <span className={styles.msgHead}>{t('capture.input')}</span>+ <div className={styles.msgBody}>{draft.input}</div>+ </Flexbox>+ <Flexbox gap={6}>+ <Flexbox horizontal align="center" gap={10}>+ <span className={styles.msgHead}>{t('capture.actual')}</span>+ <Segmented+ className={styles.kind}+ size="small"+ value={kind}+ options={[+ { label: t('capture.kind.negative'), value: 'negative' },+ { label: t('capture.kind.positive'), value: 'positive' },+ ]}+ onChange={(value) => handleKindChange(value as CapturedOutputKind)}+ />+ </Flexbox>+ <div className={styles.msgBody}>{draft.actualOutput}</div>+ <Text style={{ fontSize: 12 }} type="secondary">+ {kind === 'positive' ? t('capture.positiveHint') : t('capture.counterExampleHint')}+ </Text>+ </Flexbox>+ </Flexbox>++ {/* Right: how it will be judged, and where it lands. */}+ <Flexbox className={styles.right} gap={12}>+ <Form form={form} id={formId} layout="vertical" onFinish={handleFinish}>+ <Form.Item+ label={t('capture.criteria')}+ name="criteria"+ rules={[{ message: t('capture.criteriaRequired'), required: true }]}+ >+ <TextArea+ autoSize={{ maxRows: 10, minRows: 5 }}+ placeholder={t('capture.criteriaPlaceholder')}+ />+ </Form.Item>+ <Text style={{ fontSize: 12 }} type="secondary">+ {t('capture.criteriaHint')}+ </Text>++ <Divider style={{ marginBlock: 12 }} />++ <Form.Item label={t('capture.expected')} name="expected">+ <TextArea+ autoSize={{ maxRows: 5, minRows: 3 }}+ placeholder={t('capture.expectedPlaceholder')}+ />+ </Form.Item>++ <Form.Item+ label={t('capture.dataset')}+ name="datasetId"+ rules={[{ message: t('capture.datasetRequired'), required: true }]}+ >+ <Select+ options={datasets.map((d) => ({ label: d.name, value: d.id }))}+ placeholder={t('capture.datasetPlaceholder')}+ />+ </Form.Item>+ </Form>+ </Flexbox>+ </Flexbox>+ );+};++export default CaptureContent;diff --git a/src/features/EvalCapture/CaptureSuccess.tsx b/src/features/EvalCapture/CaptureSuccess.tsxnew file mode 100644index 00000000000..11f136babc6--- /dev/null+++ b/src/features/EvalCapture/CaptureSuccess.tsx@@ -0,0 +1,46 @@+'use client';++import { Center, Flexbox, Icon } from '@lobehub/ui';+import { Text } from '@lobehub/ui/base-ui';+import { createStaticStyles, cssVar } from 'antd-style';+import { Check } from 'lucide-react';+import { type FC } from 'react';+import { useTranslation } from 'react-i18next';++const styles = createStaticStyles(({ css }) => ({+ mark: css`+ width: 56px;+ height: 56px;+ border-radius: 50%;++ color: ${cssVar.colorSuccess};++ background: ${cssVar.colorSuccessBg};+ `,+}));++export interface CaptureSuccessProps {+ datasetName: string;+}++const CaptureSuccess: FC<CaptureSuccessProps> = ({ datasetName }) => {+ const { t } = useTranslation('eval');++ return (+ <Center gap={16} paddingBlock={40}>+ <Center className={styles.mark}>+ <Icon icon={Check} size={26} />+ </Center>+ <Flexbox align="center" gap={6}>+ <Text style={{ fontSize: 16, fontWeight: 600 }}>{t('capture.saved')}</Text>+ {datasetName && (+ <Text style={{ fontSize: 13 }} type="secondary">+ {datasetName}+ </Text>+ )}+ </Flexbox>+ </Center>+ );+};++export default CaptureSuccess;diff --git a/src/features/EvalCapture/buildCaptureDraft.test.ts b/src/features/EvalCapture/buildCaptureDraft.test.tsnew file mode 100644index 00000000000..9385544be07--- /dev/null+++ b/src/features/EvalCapture/buildCaptureDraft.test.ts@@ -0,0 +1,82 @@+import { describe, expect, it } from 'vitest';++import { buildCaptureDraft, toPlainText } from './buildCaptureDraft';++const msg = (id: string, role: string, content: unknown) => ({ content, id, role });++describe('toPlainText', () => {+ it('passes a string through', () => {+ expect(toPlainText('hi')).toBe('hi');+ });++ it('joins content parts and drops the ones with no text', () => {+ expect(toPlainText([{ text: 'a' }, 'b', { image: 'x' }])).toBe('a\nb');+ });++ it('returns an empty string for content it cannot read', () => {+ expect(toPlainText(undefined)).toBe('');+ expect(toPlainText({ odd: 1 })).toBe('');+ });+});++describe('buildCaptureDraft', () => {+ const conversation = [+ msg('m1', 'system', 'you are helpful'),+ msg('m2', 'user', 'first question'),+ msg('m3', 'assistant', 'first answer'),+ msg('m4', 'user', 'second question'),+ msg('m5', 'assistant', 'second answer'),+ ];++ it('slices the answer, the turn that asked for it, and everything before as context', () => {+ const draft = buildCaptureDraft(conversation, 'm5')!;++ expect(draft.input).toBe('second question');+ expect(draft.actualOutput).toBe('second answer');+ expect(draft.context).toEqual([+ { content: 'first question', role: 'user' },+ { content: 'first answer', role: 'assistant' },+ ]);+ });++ it('drops the system message, which is harness context rather than a turn', () => {+ expect(buildCaptureDraft(conversation, 'm5')!.context.some((c) => c.role === 'system')).toBe(+ false,+ );+ });++ it('captures the first answer with no context at all', () => {+ const draft = buildCaptureDraft(conversation, 'm3')!;++ expect(draft.input).toBe('first question');+ expect(draft.context).toEqual([]);+ });++ it('refuses an answer with no user turn before it rather than inventing an input', () => {+ expect(buildCaptureDraft([msg('a1', 'assistant', 'orphan answer')], 'a1')).toBeUndefined();+ });++ it('refuses when the preceding user turn is empty', () => {+ const messages = [msg('u', 'user', ' '), msg('a', 'assistant', 'answer')];+ expect(buildCaptureDraft(messages, 'a')).toBeUndefined();+ });++ it('refuses a non-assistant target', () => {+ expect(buildCaptureDraft(conversation, 'm4')).toBeUndefined();+ });++ it('returns undefined for an unknown message id', () => {+ expect(buildCaptureDraft(conversation, 'nope')).toBeUndefined();+ });++ it('skips blank context turns but keeps the ones with content', () => {+ const messages = [+ msg('m1', 'assistant', ''),+ msg('m2', 'user', 'kept'),+ msg('m3', 'user', 'the question'),+ msg('m4', 'assistant', 'the answer'),+ ];++ expect(buildCaptureDraft(messages, 'm4')!.context).toEqual([{ content: 'kept', role: 'user' }]);+ });+});diff --git a/src/features/EvalCapture/buildCaptureDraft.ts b/src/features/EvalCapture/buildCaptureDraft.tsnew file mode 100644index 00000000000..623c4fe628f--- /dev/null+++ b/src/features/EvalCapture/buildCaptureDraft.ts@@ -0,0 +1,80 @@+/**+ * Turning a conversation turn into an eval case is a slicing problem: the case+ * is one assistant answer, the user turn that asked for it, and everything+ * before that as replayable context.+ */++export interface CaptureSourceMessage {+ content?: unknown;+ id: string;+ role?: string;+}++export interface CaptureDraft {+ /** The answer under scrutiny. Kept as a counter-example, never as `expected`. */+ actualOutput: string;+ /** Conversation replayed before `input`. */+ context: Array<{ content: string; role: string }>;+ /** The user turn the captured answer responded to. */+ input: string;+}++/** Content is a string on most messages and content parts on some. */+export const toPlainText = (content: unknown): string => {+ if (typeof content === 'string') return content;+ if (!Array.isArray(content)) return '';++ return content+ .map((part) => {+ if (typeof part === 'string') return part;+ const text = (part as { text?: unknown })?.text;+ return typeof text === 'string' ? text : '';+ })+ .filter(Boolean)+ .join('\n');+};++/**+ * Slice a capture out of the rendered conversation.+ *+ * Returns `undefined` when the answer has no user turn before it — an assistant+ * message with nothing that asked for it cannot be replayed as a case, and+ * guessing an input would fabricate the thing under test.+ */+export const buildCaptureDraft = (+ messages: CaptureSourceMessage[],+ assistantMessageId: string,+): CaptureDraft | undefined => {+ const answerIndex = messages.findIndex((message) => message.id === assistantMessageId);+ if (answerIndex < 0) return undefined;++ const answer = messages[answerIndex];+ if (answer.role !== 'assistant') return undefined;++ let inputIndex = -1;+ for (let i = answerIndex - 1; i >= 0; i--) {+ if (messages[i].role === 'user') {+ inputIndex = i;+ break;+ }+ }+ if (inputIndex < 0) return undefined;++ const input = toPlainText(messages[inputIndex].content);+ if (!input.trim()) return undefined;++ return {+ actualOutput: toPlainText(answer.content),+ // `system` is harness context rather than a turn someone took, and the eval+ // runner filters it on replay too — carrying it would misrepresent the case.+ context: messages+ .slice(0, inputIndex)+ .filter((message) => message.role !== 'system')+ .map((message) => ({+ content: toPlainText(message.content),+ role: message.role ?? 'user',+ }))+ .filter((message) => message.content.trim().length > 0),+ input,+ };+};diff --git a/src/features/EvalCapture/buildCapturePayload.test.ts b/src/features/EvalCapture/buildCapturePayload.test.tsnew file mode 100644index 00000000000..c797ec19e36--- /dev/null+++ b/src/features/EvalCapture/buildCapturePayload.test.ts@@ -0,0 +1,70 @@+import { describe, expect, it } from 'vitest';++import { type CaptureDraft } from './buildCaptureDraft';+import { buildCapturePayload } from './buildCapturePayload';++const draft: CaptureDraft = {+ actualOutput: 'the answer',+ context: [{ content: 'hi', role: 'user' }],+ input: 'the question',+};+const values = { criteria: 'must be right', datasetId: 'ds-1' };++describe('buildCapturePayload', () => {+ // Writing a wrong answer into `expected` would make it the target.+ it('keeps a counter-example out of expected', () => {+ const payload = buildCapturePayload(draft, values, 'negative');+ expect(payload.content.expected).toBeUndefined();+ expect(payload.metadata).toMatchObject({+ capturedOutput: 'the answer',+ capturedOutputKind: 'negative',+ });+ });++ it('promotes a positive example to expected', () => {+ const payload = buildCapturePayload(draft, values, 'positive');+ expect(payload.content.expected).toBe('the answer');+ expect(payload.metadata.capturedOutputKind).toBe('positive');+ });++ it('records the captured answer either way', () => {+ for (const kind of ['negative', 'positive'] as const) {+ expect(buildCapturePayload(draft, values, kind).metadata.capturedOutput).toBe('the answer');+ }+ });++ it('lets a written expected answer win over the captured one', () => {+ const payload = buildCapturePayload(+ draft,+ { ...values, expected: 'a better answer' },+ 'positive',+ );+ expect(payload.content.expected).toBe('a better answer');+ });++ it('accepts a written expected answer on a counter-example too', () => {+ const payload = buildCapturePayload(+ draft,+ { ...values, expected: 'what it should say' },+ 'negative',+ );+ expect(payload.content.expected).toBe('what it should say');+ });++ it('treats a whitespace-only expected answer as absent', () => {+ const payload = buildCapturePayload(draft, { ...values, expected: ' ' }, 'negative');+ expect(payload.content.expected).toBeUndefined();+ });++ // An empty answer is not an expectation, even when marked positive.+ it('does not promote an empty captured answer', () => {+ const payload = buildCapturePayload({ ...draft, actualOutput: ' ' }, values, 'positive');+ expect(payload.content.expected).toBeUndefined();+ });++ it('carries the context through as indexed messages', () => {+ const payload = buildCapturePayload(draft, values, 'negative');+ expect(payload.content.messages).toEqual([{ content: 'hi', id: 'capture-0', role: 'user' }]);+ expect(payload.content.input).toBe('the question');+ });+});diff --git a/src/features/EvalCapture/buildCapturePayload.ts b/src/features/EvalCapture/buildCapturePayload.tsnew file mode 100644index 00000000000..ece1502c15c--- /dev/null+++ b/src/features/EvalCapture/buildCapturePayload.ts@@ -0,0 +1,68 @@+import { type CaptureDraft } from './buildCaptureDraft';++/**+ * What the captured answer is being kept as.+ *+ * A capture is not always a complaint: the same gesture is used to keep an+ * answer that was right, and the two mean opposite things to a judge. A+ * counter-example must stay out of `expected` — writing a wrong answer there+ * makes it the target — while a positive example *is* the expected answer.+ */+export type CapturedOutputKind = 'negative' | 'positive';++export interface CaptureFormValues {+ criteria: string;+ datasetId: string;+ expected?: string;+}++export interface CapturePayload {+ content: {+ expected?: string;+ input: string;+ messages: Array<{ content: string; id: string; role: 'assistant' | 'user' }>;+ };+ datasetId: string;+ evalConfig: { criteria: string };+ evalMode: 'llm-rubric';+ metadata: {+ capturedOutput: string;+ capturedOutputKind: CapturedOutputKind;+ source: string;+ };+}++/**+ * The captured answer is recorded either way — it is where the case came from —+ * but only a positive one is allowed to stand in as the expected output, and+ * only when the author did not write a different one.+ */+export const buildCapturePayload = (+ draft: CaptureDraft,+ values: CaptureFormValues,+ kind: CapturedOutputKind,+): CapturePayload => {+ const typedExpected = values.expected?.trim();+ const expected =+ typedExpected || (kind === 'positive' ? draft.actualOutput.trim() || undefined : undefined);++ return {+ content: {+ expected,+ input: draft.input,+ messages: draft.context.map((message, index) => ({+ content: message.content,+ id: `capture-${index}`,+ role: message.role as 'assistant' | 'user',+ })),+ },+ datasetId: values.datasetId,+ evalConfig: { criteria: values.criteria },+ evalMode: 'llm-rubric',+ metadata: {+ capturedOutput: draft.actualOutput,+ capturedOutputKind: kind,+ source: 'conversation-capture',+ },+ };+};diff --git a/src/features/EvalCapture/index.tsx b/src/features/EvalCapture/index.tsxnew file mode 100644index 00000000000..c630bea71d0--- /dev/null+++ b/src/features/EvalCapture/index.tsx@@ -0,0 +1,90 @@+'use client';++import {+ Button,+ createModal,+ type ImperativeModalProps,+ ModalFooter,+ type ModalInstance,+} from '@lobehub/ui/base-ui';+import { t } from 'i18next';++import { type CaptureDraft } from './buildCaptureDraft';+import CaptureContent from './CaptureContent';+import CaptureSuccess from './CaptureSuccess';++export { buildCaptureDraft, type CaptureDraft } from './buildCaptureDraft';++let formIdSeed = 0;++export interface CreateEvalCaptureModalOptions {+ draft: CaptureDraft;+ /** Navigate to the saved case. Saving and inspecting are separate intents. */+ onView: (testCaseId: string) => void;+}++/**+ * Capture a conversation turn as an eval case.+ *+ * Two phases in one modal: the form, then a confirmation offering to inspect+ * the case or to stop. Saving does not navigate on its own — a comparison run+ * costs money and is rarely wanted in the same breath as filing the case.+ */+export const createEvalCaptureModal = ({+ draft,+ onView,+}: CreateEvalCaptureModalOptions): ModalInstance => {+ const formId = `eval-capture-${formIdSeed++}`;+ const ref: { instance?: ModalInstance } = {};++ // `createModal` renders `footer` verbatim — it supplies no chrome of its own,+ // so the padding and alignment have to come from `ModalFooter`. Without it the+ // buttons sit flush against the modal's rounded corner.+ const formFooter = (loading: boolean) => (+ <ModalFooter>+ <Button onClick={() => ref.instance?.close()}>{t('common:cancel')}</Button>+ <Button form={formId} htmlType="submit" loading={loading} type="primary">+ {t('capture.save', { ns: 'eval' })}+ </Button>+ </ModalFooter>+ );++ const setLoading = (loading: boolean) =>+ ref.instance?.update({ footer: formFooter(loading) } as Partial<ImperativeModalProps>);++ const onSaved = (testCaseId: string, datasetName: string) =>+ ref.instance?.update({+ content: <CaptureSuccess datasetName={datasetName} />,+ footer: (+ <ModalFooter>+ <Button onClick={() => ref.instance?.close()}>{t('capture.done', { ns: 'eval' })}</Button>+ <Button+ type="primary"+ onClick={() => {+ ref.instance?.close();+ onView(testCaseId);+ }}+ >+ {t('capture.view', { ns: 'eval' })}+ </Button>+ </ModalFooter>+ ),+ width: 460,+ } as Partial<ImperativeModalProps>);++ ref.instance = createModal({+ content: (+ <CaptureContent+ draft={draft}+ formId={formId}+ onLoadingChange={setLoading}+ onSaved={onSaved}+ />+ ),+ footer: formFooter(false),+ title: t('capture.title', { ns: 'eval' }),+ width: 1040,+ });++ return ref.instance;+};diff --git a/src/features/Settings/labs/features.ts b/src/features/Settings/labs/features.tsindex 45d8fd1fa0e..95f855a2ede 100644--- a/src/features/Settings/labs/features.ts+++ b/src/features/Settings/labs/features.ts@@ -18,6 +18,7 @@ type LabFeatureI18nKey =| 'claudeCodeSdk'| 'codexAppServer'| 'desktopSplitView'+ | 'evalCapture'| 'heteroSessionImport'| 'imessage'| 'inputMarkdown'@@ -70,6 +71,12 @@ export const LAB_FEATURES: LabFeatureItem[] = [searchKeywords: ['self-evolving', 'self learning', 'rule base'],stage: 'alpha',},+ {+ flag: 'enableEvalCapture',+ i18nKey: 'evalCapture',+ searchKeywords: ['eval', 'test case', 'capture', 'regression', 'benchmark'],+ stage: 'alpha',+ },{flag: 'enableTopicAcceptance',i18nKey: 'topicAcceptance',diff --git a/src/features/Settings/labs/index.test.tsx b/src/features/Settings/labs/index.test.tsxindex b7f97d45aad..f501948bee0 100644--- a/src/features/Settings/labs/index.test.tsx+++ b/src/features/Settings/labs/index.test.tsx@@ -5,6 +5,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { initServerConfigStore, Provider } from '@/store/serverConfig/store';import { useUserStore } from '@/store/user';+import { LAB_FEATURES } from './features';import Page from './index';vi.hoisted(() => {@@ -130,8 +131,10 @@ describe('Labs settings page', () => {const alphaTags = screen.getAllByText('stage.alpha.label');const betaTags = screen.getAllByText('stage.beta.label');- // Every toggle carries exactly one stage tag.- expect(alphaTags.length + betaTags.length).toBe(14);+ // Every toggle carries exactly one stage tag — counted against the registry+ // rather than a literal, so adding an experiment does not fail this test for+ // the wrong reason.+ expect(alphaTags.length + betaTags.length).toBe(LAB_FEATURES.length);});it('marks internal-testing experiments as alpha and usable ones as beta', () => {diff --git a/src/routes/(main)/eval/features/TestCaseDetail/index.tsx b/src/routes/(main)/eval/features/TestCaseDetail/index.tsxindex c98d986669e..e971805cf4a 100644--- a/src/routes/(main)/eval/features/TestCaseDetail/index.tsx+++ b/src/routes/(main)/eval/features/TestCaseDetail/index.tsx@@ -93,13 +93,17 @@ const TestCaseDetail = memo<TestCaseDetailProps>(({ datasetName, testCase }) =>typeof testCase.evalConfig?.criteria === 'string' ? testCase.evalConfig.criteria : undefined;const caseId =typeof testCase.metadata?.caseId === 'string' ? testCase.metadata.caseId : undefined;- // The answer this case was captured from. It is the counter-example, which is- // why it is stored apart from `expected` — and why it has to be visible here,- // or the case reads as if nothing ever went wrong.+ // The answer this case was captured from, and whether it was kept as the+ // wrong answer or the right one. A counter-example has to be visible here or+ // the case reads as if nothing ever went wrong; a positive one already *is*+ // the expected output, so repeating it as its own block would just say the+ // same thing twice. Captures made before the distinction existed are+ // counter-examples.const capturedOutput =typeof testCase.metadata?.capturedOutput === 'string'? testCase.metadata.capturedOutput: undefined;+ const capturedIsPositive = testCase.metadata?.capturedOutputKind === 'positive';const initial = useMemo(() => ({ criteria: criteria ?? '', expected: expected ?? '', input: content.input ?? '' }),@@ -197,7 +201,7 @@ const TestCaseDetail = memo<TestCaseDetailProps>(({ datasetName, testCase }) =>/></Flexbox>- {capturedOutput && (+ {capturedOutput && !capturedIsPositive && (<Flexbox gap={10}><Flexbox horizontal align="center" gap={8}><span className={styles.label}>{t('testCaseDetail.capturedOutput')}</span>@@ -241,7 +245,14 @@ const TestCaseDetail = memo<TestCaseDetailProps>(({ datasetName, testCase }) =>onChange={(e) => setDraft({ expected: e.target.value })}/>) : expected ? (- <div className={styles.prose}>{expected}</div>+ <>+ <div className={styles.prose}>{expected}</div>+ {capturedIsPositive && (+ <Text style={{ fontSize: 12 }} type="secondary">+ {t('testCaseDetail.expectedFromCapture')}+ </Text>+ )}+ </>) : (<Text style={{ fontSize: 12 }} type="secondary">{t('testCaseDetail.expected.empty')}diff --git a/src/services/agentEval.ts b/src/services/agentEval.tsindex 603a49ebb51..e64bda2ceac 100644--- a/src/services/agentEval.ts+++ b/src/services/agentEval.ts@@ -149,14 +149,21 @@ class AgentEvalService {choices?: string[];expected?: string;input: string;+ /**+ * Conversation replayed into the eval topic before `input` is sent. The+ * router has always accepted it; this client had not exposed it.+ */+ messages?: Array<{+ content: string;+ id?: string;+ parentId?: string;+ role: 'assistant' | 'system' | 'user';+ }>;};datasetId: string;- evalConfig?: { judgePrompt?: string };+ evalConfig?: { criteria?: string; judgePrompt?: string };evalMode?: RubricType;- metadata?: {- difficulty?: 'easy' | 'medium' | 'hard';- tags?: string[];- };+ metadata?: Record<string, unknown>;}) {return lambdaClient.agentEval.createTestCase.mutate(params);}diff --git a/src/store/user/slices/preference/selectors/labPrefer.ts b/src/store/user/slices/preference/selectors/labPrefer.tsindex ca87803bf73..43736aa929f 100644--- a/src/store/user/slices/preference/selectors/labPrefer.ts+++ b/src/store/user/slices/preference/selectors/labPrefer.ts@@ -19,6 +19,7 @@ export const labPreferSelectors = {enableCodexAppServer: (s: UserState): boolean => s.preference.lab?.enableCodexAppServer ?? false,enableDesktopSplitView: (s: UserState): boolean =>s.preference.lab?.enableDesktopSplitView ?? false,+ enableEvalCapture: (s: UserState): boolean => s.preference.lab?.enableEvalCapture ?? false,enableHeteroSessionImport: (s: UserState): boolean =>s.preference.lab?.enableHeteroSessionImport ?? false,enableImessage: (s: UserState): boolean => s.preference.lab?.enableImessage ?? false,