Просмотр исходного кода

fix(frontend): Create a conversation without a query (#5711)

sp.wack 1 год назад
Родитель
Сommit
3236602919
1 измененных файлов с 3 добавлено и 5 удалено
  1. 3 5
      frontend/src/components/shared/task-form.tsx

+ 3 - 5
frontend/src/components/shared/task-form.tsx

@@ -40,8 +40,8 @@ export const TaskForm = React.forwardRef<HTMLFormElement>((_, 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<HTMLFormElement>((_, 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<HTMLFormElement>((_, ref) => {
     const formData = new FormData(event.currentTarget);
 
     const q = formData.get("q")?.toString();
-    if (!q) return;
-
     newConversationMutation.mutate({ q });
   };