Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
override ai prompt with preset if defined
  • Loading branch information
johnstcn committed Jul 24, 2025
commit ec3d72d9f7386e03b7e17f29bda8853872cd0e51
16 changes: 13 additions & 3 deletions site/src/pages/TasksPage/TasksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
const selectedTemplate = templates.find(
(t) => t.id === selectedTemplateId,
) as Template;

// Extract AI prompt from selected preset
const selectedPreset = presets?.find((p) => p.ID === selectedPresetId);
const presetAIPrompt = selectedPreset?.Parameters.find(
(param) => param.Name === "ai_prompt",
)?.Value;
const isPromptReadOnly = !!presetAIPrompt;
const {
externalAuth,
externalAuthError,
Expand Down Expand Up @@ -291,8 +298,7 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {

const form = e.currentTarget;
const formData = new FormData(form);
const prompt = formData.get("prompt") as string;
const templateID = formData.get("templateID") as string;
const prompt = presetAIPrompt || (formData.get("prompt") as string);

try {
await createTaskMutation.mutateAsync({
Expand Down Expand Up @@ -326,9 +332,13 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
required
id="prompt"
name="prompt"
value={presetAIPrompt || undefined}
readOnly={isPromptReadOnly}
placeholder={textareaPlaceholder}
className={`border-0 resize-none w-full h-full bg-transparent rounded-lg outline-none flex min-h-[60px]
text-sm shadow-sm text-content-primary placeholder:text-content-secondary md:text-sm`}
text-sm shadow-sm text-content-primary placeholder:text-content-secondary md:text-sm ${
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be done later but it can be confusing for users that the Prompt is disabled because of a preset. In the dynamic parameters create workspace page, I label parameters when they are preset as such so user know why they can't be edited.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add a quick tooltip here

Copy link
Member Author

@johnstcn johnstcn Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0fd55e2

isPromptReadOnly ? "opacity-60 cursor-not-allowed" : ""
}`}
/>
<div className="flex items-center justify-between pt-2">
<div className="flex items-center gap-4">
Expand Down