Skip to content

Commit

Permalink
Fix: Allow form submission with empty query if repo/files present (#5919
Browse files Browse the repository at this point in the history
)

Co-authored-by: openhands <[email protected]>
  • Loading branch information
amanape and openhands-agent authored Dec 30, 2024
1 parent 0e8e3c8 commit d8b33c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/components/shared/task-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export function TaskForm({ ref }: TaskFormProps) {
const [inputIsFocused, setInputIsFocused] = React.useState(false);
const newConversationMutation = useMutation({
mutationFn: (variables: { q?: string }) => {
if (variables.q) dispatch(setInitialQuery(variables.q));
if (!variables.q?.trim() && !selectedRepository && files.length === 0) {
throw new Error("No query provided");
}

if (variables.q?.trim()) dispatch(setInitialQuery(variables.q));
return OpenHands.newConversation({
githubToken: gitHubToken || undefined,
selectedRepository: selectedRepository || undefined,
Expand Down Expand Up @@ -90,9 +94,7 @@ export function TaskForm({ ref }: TaskFormProps) {
const formData = new FormData(event.currentTarget);

const q = formData.get("q")?.toString();
if (q?.trim()) {
newConversationMutation.mutate({ q });
}
newConversationMutation.mutate({ q });
};

return (
Expand Down

0 comments on commit d8b33c4

Please sign in to comment.