diff --git a/src/renderer/src/components/Popups/agent/AgentModal.tsx b/src/renderer/src/components/Popups/agent/AgentModal.tsx index 31e486079c..9a43906b5a 100644 --- a/src/renderer/src/components/Popups/agent/AgentModal.tsx +++ b/src/renderer/src/components/Popups/agent/AgentModal.tsx @@ -158,6 +158,35 @@ export const AgentModal: React.FC = ({ agent, trigger, isOpen: _isOpen, o })) }, []) + const addAccessiblePath = useCallback(async () => { + try { + const selected = await window.api.file.selectFolder() + if (!selected) { + return + } + setForm((prev) => { + if (prev.accessible_paths.includes(selected)) { + window.toast.warning(t('agent.session.accessible_paths.duplicate')) + return prev + } + return { + ...prev, + accessible_paths: [...prev.accessible_paths, selected] + } + }) + } catch (error) { + logger.error('Failed to select accessible path:', error as Error) + window.toast.error(t('agent.session.accessible_paths.select_failed')) + } + }, [t]) + + const removeAccessiblePath = useCallback((path: string) => { + setForm((prev) => ({ + ...prev, + accessible_paths: prev.accessible_paths.filter((item) => item !== path) + })) + }, []) + const modelOptions = useMemo(() => { // mocked data. not final version return (models ?? []).map((model) => ({ @@ -197,6 +226,12 @@ export const AgentModal: React.FC = ({ agent, trigger, isOpen: _isOpen, o return } + if (form.accessible_paths.length === 0) { + window.toast.error(t('agent.session.accessible_paths.required')) + loadingRef.current = false + return + } + if (isEditing(agent)) { if (!agent) { throw new Error('Agent is required for editing mode') @@ -207,7 +242,8 @@ export const AgentModal: React.FC = ({ agent, trigger, isOpen: _isOpen, o name: form.name, description: form.description, instructions: form.instructions, - model: form.model + model: form.model, + accessible_paths: [...form.accessible_paths] } satisfies UpdateAgentForm updateAgent(updatePayload) @@ -309,6 +345,34 @@ export const AgentModal: React.FC = ({ agent, trigger, isOpen: _isOpen, o value={form.description ?? ''} onValueChange={onDescChange} /> +
+
+ + {t('agent.session.accessible_paths.label')} + + +
+ {form.accessible_paths.length > 0 ? ( +
+ {form.accessible_paths.map((path) => ( +
+ + {path} + + +
+ ))} +
+ ) : ( +

{t('agent.session.accessible_paths.empty')}

+ )} +