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 }); };