AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(chat): skipping a slider or color question no longer sends its default as your answer (#17135)
Hazem Adel456c36cfec4e
diff --git a/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsx b/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsxindex b46a335e180..6dc802d6b70 100644--- a/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsx+++ b/packages/web/src/app/routes/chat-with-ai/components/multi-question-form.tsx@@ -123,9 +123,15 @@ export function MultiQuestionForm({}function handleSkip() {+ const answersWithoutSkipped = withoutStep({+ record: answers,+ step: currentStep,+ });+ setAnswers(answersWithoutSkipped);+ setAnswerValues((prev) => withoutStep({ record: prev, step: currentStep }));if (isLastStep) {if (submitted) return;- const lines = buildRecap(answers);+ const lines = buildRecap(answersWithoutSkipped);if (lines.length === 0) {onDismiss?.();return;@@ -527,3 +533,15 @@ function ChoiceBody({</div>);}++function withoutStep<T>({+ record,+ step,+}: {+ record: Record<number, T>;+ step: number;+}): Record<number, T> {+ return Object.fromEntries(+ Object.entries(record).filter(([key]) => Number(key) !== step),+ );+}diff --git a/packages/web/test/app/routes/chat-with-ai/multi-question-form-skip.test.tsx b/packages/web/test/app/routes/chat-with-ai/multi-question-form-skip.test.tsxnew file mode 100644index 00000000000..fc38f017db3--- /dev/null+++ b/packages/web/test/app/routes/chat-with-ai/multi-question-form-skip.test.tsx@@ -0,0 +1,61 @@+/**+ * @vitest-environment jsdom+ */+import { cleanup, fireEvent, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { MultiQuestionForm } from '@/app/routes/chat-with-ai/components/multi-question-form';+import { MultiQuestion } from '@/features/chat/lib/chat-store-types';++vi.mock('i18next', () => ({ t: (key: string) => key }));++afterEach(() => {+ cleanup();+});++describe('MultiQuestionForm Skip', () => {+ it('sends nothing when the only question, a color, is skipped', async () => {+ const { onSubmit, onDismiss } = renderForm([COLOR_QUESTION]);+ await screen.findByDisplayValue('#112233');++ fireEvent.click(screen.getByRole('button', { name: 'Skip' }));++ expect(onSubmit).not.toHaveBeenCalled();+ expect(onDismiss).toHaveBeenCalledTimes(1);+ });++ it('leaves a skipped color question out of the answers', async () => {+ const { onSubmit } = renderForm([CHOICE_QUESTION, COLOR_QUESTION]);++ fireEvent.click(screen.getByText('Gmail'));+ await screen.findByDisplayValue('#112233');+ fireEvent.click(screen.getByRole('button', { name: 'Skip' }));++ expect(onSubmit).toHaveBeenCalledWith('- **Which inbox?** Gmail');+ });+});++function renderForm(questions: MultiQuestion[]) {+ const onSubmit = vi.fn();+ const onDismiss = vi.fn();+ render(+ <MultiQuestionForm+ questions={questions}+ onSubmit={onSubmit}+ onDismiss={onDismiss}+ />,+ );+ return { onSubmit, onDismiss };+}++const CHOICE_QUESTION: MultiQuestion = {+ type: 'choice',+ question: 'Which inbox?',+ options: [{ label: 'Gmail' }, { label: 'Outlook' }],+};++const COLOR_QUESTION: MultiQuestion = {+ type: 'color',+ question: 'Brand color?',+ presets: ['#112233', '#445566'],+};