Skip to content

Commit 68b90ad

Browse files
committed
override ai prompt with preset if defined
1 parent 0c6ede1 commit 68b90ad

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
236236
const selectedTemplate = templates.find(
237237
(t) => t.id === selectedTemplateId,
238238
) as Template;
239+
240+
// Extract AI prompt from selected preset
241+
const selectedPreset = presets?.find((p) => p.ID === selectedPresetId);
242+
const presetAIPrompt = selectedPreset?.Parameters.find(
243+
(param) => param.Name === "ai_prompt",
244+
)?.Value;
245+
const isPromptReadOnly = !!presetAIPrompt;
239246
const {
240247
externalAuth,
241248
externalAuthError,
@@ -291,8 +298,7 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
291298

292299
const form = e.currentTarget;
293300
const formData = new FormData(form);
294-
const prompt = formData.get("prompt") as string;
295-
const templateID = formData.get("templateID") as string;
301+
const prompt = presetAIPrompt || (formData.get("prompt") as string);
296302

297303
try {
298304
await createTaskMutation.mutateAsync({
@@ -326,9 +332,13 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
326332
required
327333
id="prompt"
328334
name="prompt"
335+
value={presetAIPrompt || undefined}
336+
readOnly={isPromptReadOnly}
329337
placeholder={textareaPlaceholder}
330338
className={`border-0 resize-none w-full h-full bg-transparent rounded-lg outline-none flex min-h-[60px]
331-
text-sm shadow-sm text-content-primary placeholder:text-content-secondary md:text-sm`}
339+
text-sm shadow-sm text-content-primary placeholder:text-content-secondary md:text-sm ${
340+
isPromptReadOnly ? "opacity-60 cursor-not-allowed" : ""
341+
}`}
332342
/>
333343
<div className="flex items-center justify-between pt-2">
334344
<div className="flex items-center gap-4">

0 commit comments

Comments
 (0)
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