-
Notifications
You must be signed in to change notification settings - Fork 38
feat: Added ui to support input params for task creation #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
97dd3de
ea01ea0
6ad266b
b6739c5
795cc59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,9 @@ export function PromptInput({ prompt, setPrompt }: PromptInputProps) { | |
| const { taskID, agentName, updateParams } = useSafeSearchParams(); | ||
| const [isClient, setIsClient] = useState(false); | ||
| const [isSendingJSON, setIsSendingJSON] = useState(false); | ||
| const [isTaskParamsOpen, setIsTaskParamsOpen] = useState(false); | ||
| const [taskParams, setTaskParams] = useState(''); | ||
| const taskParamsViewRef = useRef<EditorView | null>(null); | ||
|
|
||
| const { agentexClient } = useAgentexClient(); | ||
|
|
||
|
|
@@ -119,9 +122,20 @@ export function PromptInput({ prompt, setPrompt }: PromptInputProps) { | |
| setPrompt(''); | ||
|
|
||
| if (!currentTaskId) { | ||
| let extraTaskParams: Record<string, unknown> = {}; | ||
| if (taskParams.trim()) { | ||
| try { | ||
| extraTaskParams = JSON.parse(taskParams); | ||
| } catch { | ||
| toast.error('Invalid Task Parameters JSON'); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| const task = await createTaskMutation.mutateAsync({ | ||
| agentName: agentName, | ||
| params: { | ||
| ...extraTaskParams, | ||
| description: prompt, | ||
| content: currentPrompt, | ||
| }, | ||
|
|
@@ -159,10 +173,32 @@ export function PromptInput({ prompt, setPrompt }: PromptInputProps) { | |
| sendMessageMutation, | ||
| setPrompt, | ||
| isSendingJSON, | ||
| taskParams, | ||
| ]); | ||
|
|
||
| return ( | ||
| <div className="flex w-full max-w-3xl flex-col gap-2"> | ||
| {!taskID && !isDisabled && ( | ||
| <div className="flex flex-col gap-1"> | ||
| <button | ||
| type="button" | ||
| className="text-muted-foreground hover:text-foreground ml-4 flex items-center gap-1 text-sm transition-colors" | ||
| onClick={() => setIsTaskParamsOpen(v => !v)} | ||
| > | ||
| <span>{isTaskParamsOpen ? '▾' : '▸'}</span> | ||
| Task Parameters | ||
| </button> | ||
| {isTaskParamsOpen && ( | ||
| <DataInput | ||
| prompt={taskParams} | ||
| setPrompt={setTaskParams} | ||
| isDisabled={isDisabled} | ||
| handleSendPrompt={handleSendPrompt} | ||
| codeMirrorViewRef={taskParamsViewRef} | ||
| /> | ||
| )} | ||
| </div> | ||
|
Comment on lines
+181
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The PR description says "Also only available in dev environment," but neither the UI panel (line 181) nor the Prompt To Fix With AIThis is a comment left during a code review.
Path: agentex-ui/components/primary-content/prompt-input.tsx
Line: 181-200
Comment:
**Missing dev-only guard on Task Parameters UI**
The PR description says "Also only available in dev environment," but neither the UI panel (line 181) nor the `extraTaskParams` parse logic (line 126) has a `process.env.NODE_ENV === 'development'` check. As-is, the Task Parameters accordion and its ability to inject arbitrary JSON into `createTask` are fully live in production, directly contradicting the stated design constraint.
How can I resolve this? If you propose a fix, please make it concise. |
||
| )} | ||
| <div | ||
| className={`border-input dark:bg-input ${isDisabled ? 'bg-muted scale-90 cursor-not-allowed' : 'scale-100'} flex w-full items-center justify-between rounded-4xl border py-2 pr-2 pl-6 shadow-sm transition-transform duration-300 disabled:cursor-not-allowed`} | ||
| > | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extraTaskParamsis applied whenevertaskParams.trim()is non-empty, regardless of whetherisTaskParamsOpenistrue. If a user opens the accordion, enters params, then closes it (collapsing the UI), the nexthandleSendPromptcall will still inject those params without any visible indicator — directly contradicting the visual affordance of the toggle. Gate the parse behindisTaskParamsOpenso that closing the accordion genuinely disables the params.Prompt To Fix With AI