From b91eb47c22f65daad7c298bb57d7ab61a19b04e2 Mon Sep 17 00:00:00 2001 From: Luka Zivkovic Date: Fri, 16 Oct 2026 13:07:03 +0200 Subject: [PATCH 1/2] refactor(editor): Simplify mocked agent preview state --- .../InstanceAiTestAgentPreviewPanel.test.ts | 18 ++++++++++++++++++ .../InstanceAiTestAgentPreviewPanel.vue | 19 ++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/frontend/editor-ui/src/features/ai/instanceAi/__tests__/InstanceAiTestAgentPreviewPanel.test.ts b/packages/frontend/editor-ui/src/features/ai/instanceAi/__tests__/InstanceAiTestAgentPreviewPanel.test.ts index 5055321a88f..d0e26b31244 100644 --- a/packages/frontend/editor-ui/src/features/ai/instanceAi/__tests__/InstanceAiTestAgentPreviewPanel.test.ts +++ b/packages/frontend/editor-ui/src/features/ai/instanceAi/__tests__/InstanceAiTestAgentPreviewPanel.test.ts @@ -249,6 +249,24 @@ describe('InstanceAiTestAgentPreviewPanel', () => { expect(container.querySelector('a[href="https://example.com"]')).toBeInTheDocument(); }); + it('omits the seed example when the mocked preview returns no answer', async () => { + const store = useAgentEvalsStore(); + mockPreviewRun(store, { response: '' }); + const generateDraftCases = vi.spyOn(store, 'generateDraftCases').mockResolvedValue({ + cases: [{ input: 'Another request', whatToCheck: 'names the ticket', scenario: 'Vague' }], + }); + const user = userEvent.setup(); + const { findByTestId } = renderComponent(); + + await user.click(await findByTestId('instance-ai-test-agent-preview-check-harder')); + + expect(await findByTestId('instance-ai-test-agent-examples-check-agent')).toBeInTheDocument(); + expect(generateDraftCases).toHaveBeenCalledWith('project-1', 'agent-1', { + count: 10, + save: false, + }); + }); + it('renders the answer inside a fixed-height scrollable container regardless of length', async () => { const store = useAgentEvalsStore(); mockPreviewRun(store, { diff --git a/packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiTestAgentPreviewPanel.vue b/packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiTestAgentPreviewPanel.vue index 8f48cf1ab8f..ac9a3764d1b 100644 --- a/packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiTestAgentPreviewPanel.vue +++ b/packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiTestAgentPreviewPanel.vue @@ -56,8 +56,8 @@ const phase = ref('generating-preview'); // from `previewRun`'s response, which already ran the agent and returned the // final text. No run id, no polling: unlike the suite below, this never // touches a Data Table, dataset, or eval-run row at all. -const previewRequest = ref(null); -const previewAnswer = ref(null); +const previewInput = ref(''); +const previewOutput = ref(''); // Generated with `save: false` — a preview, not yet persisted. Nothing backs // these rows until "Check your agent" commits them, so dismissing or // refreshing mid-preview leaves no orphaned dataset behind. @@ -87,9 +87,6 @@ const previewVerdict = ref(null); // Whether the full example conversation is shown under "What we found". const conversationExpanded = ref(false); -const previewInput = computed(() => previewRequest.value ?? ''); -const previewOutput = computed(() => previewAnswer.value ?? ''); - // Nothing failed when the judge passed the answer, or when the case had no rule to // grade it against (`skipped`) — the card still shows, as a pass. A judge error is // different: the answer was never graded, so it must not read as "passed". @@ -189,8 +186,8 @@ async function runGeneratedPreview() { previewScenario.value = result.scenario || null; previewWhatToCheck.value = result.whatToCheck; previewVerdict.value = result.verdict; - previewRequest.value = result.input; - previewAnswer.value = result.response; + previewInput.value = result.input; + previewOutput.value = result.response; conversationExpanded.value = false; phase.value = 'awaiting-confirmation'; } catch (error) { @@ -443,8 +440,8 @@ async function onApplySuggestion() { ); return; } - previewRequest.value = preview.input; - previewAnswer.value = preview.response; + previewInput.value = preview.input; + previewOutput.value = preview.response; previewVerdict.value = preview.verdict; conversationExpanded.value = false; } @@ -538,7 +535,7 @@ function onDontCreateEvals() { @@ -610,7 +607,7 @@ function onDontCreateEvals() {