fix: clear prompt after task creation (#20344)

Fix https://github.com/coder/coder/issues/20255
This commit is contained in:
Bruno Quaresma
2025-10-17 09:56:07 -03:00
committed by GitHub
parent 16a863eab6
commit 09a41f3d1f
2 changed files with 6 additions and 0 deletions
@@ -145,6 +145,11 @@ export const OnSuccess: Story = {
const successMessage = await body.findByText(/task created/i);
expect(successMessage).toBeInTheDocument();
});
await step("Clears prompt", async () => {
const prompt = await canvas.findByLabelText(/prompt/i);
expect(prompt).toHaveValue("");
});
},
};
@@ -232,6 +232,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
await createTaskMutation.mutateAsync({
prompt,
});
setPrompt("");
} catch (error) {
const message = getErrorMessage(error, "Error creating task");
const detail = getErrorDetail(error) ?? "Please try again";