Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 5 additions & 24 deletions src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const CreateAgentPage: React.FC = () => {
const [agentId, setAgentId] = useState('');
const [agentIdError, setAgentIdError] = useState<string | null>(null);
const [name, setName] = useState('');
const [nameError, setNameError] = useState<string | null>(null);
const [description, setDescription] = useState('');
const [prompt, setPrompt] = useState('');
const [readonly, setReadonly] = useState(defaultReadonlyForKind('mode'));
Expand Down Expand Up @@ -211,7 +210,6 @@ const CreateAgentPage: React.FC = () => {
setPendingTools(null);
setUserContextPolicy(new Set(detail.userContextPolicy));
setAgentIdError(null);
setNameError(null);
} catch (error) {
if (cancelled) {
return;
Expand Down Expand Up @@ -242,16 +240,6 @@ const CreateAgentPage: React.FC = () => {
[t],
);

const validateName = useCallback(
(value: string) => {
if (!value.trim()) {
return t('agentsOverview.form.nameRequired');
}
return null;
},
[t],
);

const toggleContextSection = useCallback((section: UserContextSection) => {
setUserContextPolicy((prev) => {
const next = new Set(prev);
Expand Down Expand Up @@ -372,10 +360,8 @@ const CreateAgentPage: React.FC = () => {

const handleSubmit = useCallback(async () => {
const nextAgentIdError = validateAgentId(agentId);
const nextNameError = validateName(name);
setAgentIdError(nextAgentIdError);
setNameError(nextNameError);
if (nextAgentIdError || nextNameError) {
if (nextAgentIdError) {
return;
}
if (!description.trim()) {
Expand All @@ -400,11 +386,13 @@ const CreateAgentPage: React.FC = () => {

setSubmitting(true);
try {
const normalizedId = agentId.trim();
const effectiveName = name.trim() || normalizedId;
const payload = {
kind,
level: kind === 'subagent' ? level : 'user',
id: agentId.trim(),
name: name.trim(),
id: normalizedId,
name: effectiveName,
description: description.trim(),
prompt: prompt.trim(),
readonly,
Expand Down Expand Up @@ -460,7 +448,6 @@ const CreateAgentPage: React.FC = () => {
t,
userContextPolicy,
validateAgentId,
validateName,
workspacePath,
]);

Expand Down Expand Up @@ -612,16 +599,10 @@ const CreateAgentPage: React.FC = () => {
value={name}
onChange={(event) => {
setName(event.target.value);
setNameError(validateName(event.target.value));
}}
onBlur={() => setNameError(validateName(name))}
placeholder={t('agentsOverview.form.namePlaceholder')}
inputSize="small"
error={!!nameError}
/>
{nameError ? (
<span className="th-create-panel__error" data-bf-component="create-agent-page" data-bf-part="error">{nameError}</span>
) : null}
</div>
</div>

Expand Down
9 changes: 4 additions & 5 deletions src/web-ui/src/locales/en-US/scenes/agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,12 @@
"kind": "Kind",
"kindAgentTooltip": "After creating it, you can select it directly as a standalone mode from the conversation input's mode picker.",
"kindSubagentTooltip": "After creating it, a primary agent can delegate subtasks to it. It is not available as a directly selectable mode.",
"id": "ID",
"idPlaceholder": "Stable identifier used in config and routing",
"id": "Agent ID",
"idPlaceholder": "Used by the model, config, and routing; cannot be changed after creation",
"idRequired": "ID is required",
"idFormat": "Must start with a letter and contain only letters, numbers, underscores, or hyphens",
"name": "Name",
"namePlaceholder": "Human-readable display name",
"nameRequired": "Name is required",
"name": "Name (optional)",
"namePlaceholder": "Used for display only; defaults to the Agent ID",
"level": "Level",
"modeUserOnly": "Custom modes are always user-level in the current release.",
"description": "Description",
Expand Down
9 changes: 4 additions & 5 deletions src/web-ui/src/locales/zh-CN/scenes/agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,12 @@
"kind": "类型",
"kindAgentTooltip": "创建后可在对话输入框的模式选择器中作为独立模式直接选择。",
"kindSubagentTooltip": "创建后主 Agent 可通过委派它完成子任务;不会作为可直接选择的模式。",
"id": "ID",
"idPlaceholder": "用于配置和路由的稳定标识符",
"id": "Agent ID",
"idPlaceholder": "用于模型识别、配置和路由,创建后不可修改",
"idRequired": "ID 不能为空",
"idFormat": "只能以字母开头,包含字母/数字/下划线/连字符",
"name": "名称",
"namePlaceholder": "界面展示名称",
"nameRequired": "名称不能为空",
"name": "名称(选填)",
"namePlaceholder": "仅用于展示,留空时使用 Agent ID",
"level": "级别",
"modeUserOnly": "当前版本中,自定义 mode 仅支持用户级。",
"description": "描述",
Expand Down
9 changes: 4 additions & 5 deletions src/web-ui/src/locales/zh-TW/scenes/agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,12 @@
"kind": "類型",
"kindAgentTooltip": "建立後可在對話輸入框的模式選擇器中作為獨立模式直接選擇。",
"kindSubagentTooltip": "建立後主 Agent 可透過委派它完成子任務;不會作為可直接選擇的模式。",
"id": "ID",
"idPlaceholder": "用於設定和路由的穩定識別符",
"id": "Agent ID",
"idPlaceholder": "用於模型識別、設定和路由,建立後不可修改",
"idRequired": "ID 不能為空",
"idFormat": "只能以字母開頭,包含字母/數字/下劃線/連字符",
"name": "名稱",
"namePlaceholder": "介面顯示名稱",
"nameRequired": "名稱不能為空",
"name": "名稱(選填)",
"namePlaceholder": "僅用於顯示,留空時使用 Agent ID",
"level": "級別",
"modeUserOnly": "目前版本中,自定義 mode 僅支援用戶級。",
"description": "描述",
Expand Down