Skip to content

Commit 6d305df

Browse files
fix: use default preset when creating a workspace for task (#18623)
1 parent 29ef3a8 commit 6d305df

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const TaskFormSection: FC<{
206206
);
207207
};
208208

209-
type CreateTaskMutationFnProps = { prompt: string; templateId: string };
209+
type CreateTaskMutationFnProps = { prompt: string; template: Template };
210210

211211
type TaskFormProps = {
212212
templates: Template[];
@@ -236,8 +236,8 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
236236
: true;
237237

238238
const createTaskMutation = useMutation({
239-
mutationFn: async ({ prompt, templateId }: CreateTaskMutationFnProps) =>
240-
data.createTask(prompt, user.id, templateId),
239+
mutationFn: async ({ prompt, template }: CreateTaskMutationFnProps) =>
240+
data.createTask(prompt, user.id, template.id, template.active_version_id),
241241
onSuccess: async (task) => {
242242
await queryClient.invalidateQueries({
243243
queryKey: ["tasks"],
@@ -257,7 +257,7 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
257257
try {
258258
await createTaskMutation.mutateAsync({
259259
prompt,
260-
templateId: templateID,
260+
template: selectedTemplate,
261261
});
262262
} catch (error) {
263263
const message = getErrorMessage(error, "Error creating task");
@@ -601,10 +601,15 @@ export const data = {
601601
prompt: string,
602602
userId: string,
603603
templateId: string,
604+
templateVersionId: string,
604605
): Promise<Task> {
606+
const presets = await API.getTemplateVersionPresets(templateVersionId);
607+
const defaultPreset = presets.find((p) => p.Default);
605608
const workspace = await API.createWorkspace(userId, {
606609
name: `task-${generateWorkspaceName()}`,
607610
template_id: templateId,
611+
template_version_id: templateVersionId,
612+
template_version_preset_id: defaultPreset?.ID,
608613
rich_parameter_values: [
609614
{ name: AI_PROMPT_PARAMETER_NAME, value: prompt },
610615
],

0 commit comments

Comments
 (0)