From 2ab771cb2e787d826378e2fc14ef1a01c167e3d9 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 26 Jun 2025 20:30:58 +0000 Subject: [PATCH] fix: use default preset when creating a workspace for task --- site/src/pages/TasksPage/TasksPage.tsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index f86979f8eae00..40848e6aa1590 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -192,7 +192,7 @@ const TaskFormSection: FC<{ ); }; -type CreateTaskMutationFnProps = { prompt: string; templateId: string }; +type CreateTaskMutationFnProps = { prompt: string; template: Template }; type TaskFormProps = { templates: Template[]; @@ -201,25 +201,25 @@ type TaskFormProps = { const TaskForm: FC = ({ templates }) => { const { user } = useAuthenticated(); const queryClient = useQueryClient(); - const [templateId, setTemplateId] = useState(templates[0].id); + const selectedTemplate = templates.find( + (t) => t.id === templateId, + ) as Template; const { externalAuth, externalAuthPollingState, startPollingExternalAuth, isLoadingExternalAuth, externalAuthError, - } = useExternalAuth( - templates.find((t) => t.id === templateId)?.active_version_id, - ); + } = useExternalAuth(selectedTemplate.active_version_id); const hasAllRequiredExternalAuth = externalAuth?.every( (auth) => auth.optional || auth.authenticated, ); const createTaskMutation = useMutation({ - mutationFn: async ({ prompt, templateId }: CreateTaskMutationFnProps) => - data.createTask(prompt, user.id, templateId), + mutationFn: async ({ prompt, template }: CreateTaskMutationFnProps) => + data.createTask(prompt, user.id, template.id, template.active_version_id), onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["tasks"], @@ -242,7 +242,7 @@ const TaskForm: FC = ({ templates }) => { try { await createTaskMutation.mutateAsync({ prompt, - templateId: templateID, + template: selectedTemplate, }); form.reset(); } catch (error) { @@ -533,10 +533,15 @@ export const data = { prompt: string, userId: string, templateId: string, + templateVersionId: string, ): Promise { + const presets = await API.getTemplateVersionPresets(templateVersionId); + const defaultPreset = presets.find((p) => p.Default); const workspace = await API.createWorkspace(userId, { name: `task-${generateWorkspaceName()}`, template_id: templateId, + template_version_id: templateVersionId, + template_version_preset_id: defaultPreset?.ID, rich_parameter_values: [ { name: AI_PROMPT_PARAMETER_NAME, value: prompt }, ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy