From 32366029190557f60edaddc483969ca361166835 Mon Sep 17 00:00:00 2001 From: "sp.wack" <83104063+amanape@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:24:30 +0400 Subject: [PATCH] fix(frontend): Create a conversation without a query (#5711) --- frontend/src/components/shared/task-form.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/shared/task-form.tsx b/frontend/src/components/shared/task-form.tsx index ef97b1bfb8b7..07299a682453 100644 --- a/frontend/src/components/shared/task-form.tsx +++ b/frontend/src/components/shared/task-form.tsx @@ -40,8 +40,8 @@ export const TaskForm = React.forwardRef((_, ref) => { ); const [inputIsFocused, setInputIsFocused] = React.useState(false); const newConversationMutation = useMutation({ - mutationFn: (variables: { q: string }) => { - dispatch(setInitialQuery(variables.q)); + mutationFn: (variables: { q?: string }) => { + if (variables.q) dispatch(setInitialQuery(variables.q)); return OpenHands.newConversation({ githubToken: gitHubToken || undefined, selectedRepository: selectedRepository || undefined, @@ -51,7 +51,7 @@ export const TaskForm = React.forwardRef((_, ref) => { onSuccess: ({ conversation_id: conversationId }, { q }) => { posthog.capture("initial_query_submitted", { entry_point: "task_form", - query_character_length: q.length, + query_character_length: q?.length, has_repository: !!selectedRepository, has_files: files.length > 0, }); @@ -88,8 +88,6 @@ export const TaskForm = React.forwardRef((_, ref) => { const formData = new FormData(event.currentTarget); const q = formData.get("q")?.toString(); - if (!q) return; - newConversationMutation.mutate({ q }); };