Skip to content

Commit 96227fb

Browse files
authored
🐛 Translation unavailable when generating agent without business description
2 parents be25603 + 3d6e2f6 commit 96227fb

File tree

6 files changed

+36
-1
lines changed

6 files changed

+36
-1
lines changed

frontend/app/[locale]/setup/agents/components/AgentSetupOrchestrator.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import PromptManager from "./PromptManager";
3232
export default function AgentSetupOrchestrator({
3333
businessLogic,
3434
setBusinessLogic,
35+
businessLogicError = false,
3536
selectedTools,
3637
setSelectedTools,
3738
isCreatingNewAgent,
@@ -1021,6 +1022,7 @@ export default function AgentSetupOrchestrator({
10211022
: undefined
10221023
}
10231024
businessLogic={businessLogic}
1025+
businessLogicError={businessLogicError}
10241026
dutyContent={dutyContent}
10251027
constraintContent={constraintContent}
10261028
fewShotsContent={fewShotsContent}

frontend/app/[locale]/setup/agents/components/PromptManager.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export interface PromptManagerProps {
177177
// Basic data
178178
agentId?: number;
179179
businessLogic?: string;
180+
businessLogicError?: boolean;
180181
dutyContent?: string;
181182
constraintContent?: string;
182183
fewShotsContent?: string;
@@ -229,6 +230,7 @@ export interface PromptManagerProps {
229230
export default function PromptManager({
230231
agentId,
231232
businessLogic = "",
233+
businessLogicError = false,
232234
dutyContent = "",
233235
constraintContent = "",
234236
fewShotsContent = "",
@@ -543,10 +545,16 @@ export default function PromptManager({
543545
</div>
544546

545547
{/* 重新设计的容器:分为文本区域和控件区域 */}
546-
<div className="border border-gray-200 rounded-lg overflow-hidden bg-white shadow-sm" style={{ minHeight: "120px", maxHeight: "200px" }}>
548+
<div
549+
className={`border rounded-lg overflow-hidden bg-white shadow-sm transition-all duration-300 ${
550+
businessLogicError ? "border-red-500 border-2" : "border-gray-200"
551+
}`}
552+
style={{ minHeight: "120px", maxHeight: "200px" }}
553+
>
547554
{/* 文本内容区域 */}
548555
<div className="px-2 pt-2 pb-1 overflow-hidden" style={{ minHeight: "80px", maxHeight: "160px" }}>
549556
<Input.TextArea
557+
data-business-logic-input
550558
value={businessLogic}
551559
onChange={(e) => onBusinessLogicChange?.(e.target.value)}
552560
placeholder={t("businessLogic.placeholder")}

frontend/app/[locale]/setup/agents/config.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,30 @@ export default function AgentConfig() {
7575
const [isGeneratingAgent, setIsGeneratingAgent] = useState(false);
7676
const [isEmbeddingConfigured, setIsEmbeddingConfigured] = useState(false);
7777

78+
// Error state for business logic input
79+
const [businessLogicError, setBusinessLogicError] = useState(false);
80+
7881
// Only auto scan once flag
7982
const hasAutoScanned = useRef(false);
8083

8184
// Handle generate agent
8285
const handleGenerateAgent = async (selectedModel?: ModelOption) => {
8386
if (!businessLogic || businessLogic.trim() === "") {
87+
setBusinessLogicError(true);
8488
message.warning(
8589
t("businessLogic.config.error.businessDescriptionRequired")
8690
);
91+
// Scroll to business logic input after a short delay to ensure it's visible
92+
setTimeout(() => {
93+
const businessLogicInput = document.querySelector('[data-business-logic-input]');
94+
if (businessLogicInput) {
95+
businessLogicInput.scrollIntoView({ behavior: 'smooth', block: 'center' });
96+
}
97+
}, 100);
8798
return;
8899
}
100+
// Clear error when validation passes
101+
setBusinessLogicError(false);
89102

90103
const currentAgentId = getCurrentAgentId();
91104
if (!currentAgentId) {
@@ -296,6 +309,7 @@ export default function AgentConfig() {
296309
setDutyContent("");
297310
setConstraintContent("");
298311
setFewShotsContent("");
312+
setBusinessLogicError(false);
299313
// Clear agent name and description only when not in editing mode
300314
if (!isEditingAgent) {
301315
setAgentName("");
@@ -364,11 +378,13 @@ export default function AgentConfig() {
364378
if (isEditing && agent) {
365379
setAgentName(agent.name || "");
366380
setAgentDescription(agent.description || "");
381+
setBusinessLogicError(false);
367382
} else if (!isEditing) {
368383
// When stopping editing, clear name description box
369384
setAgentName("");
370385
setAgentDescription("");
371386
setAgentDisplayName("");
387+
setBusinessLogicError(false);
372388
}
373389
};
374390

@@ -388,6 +404,7 @@ export default function AgentConfig() {
388404
setFewShotsContent("");
389405
setAgentName("");
390406
setAgentDescription("");
407+
setBusinessLogicError(false);
391408
};
392409

393410
// Refresh tool list
@@ -427,10 +444,15 @@ export default function AgentConfig() {
427444
businessLogic={businessLogic}
428445
setBusinessLogic={(value) => {
429446
setBusinessLogic(value);
447+
// Clear error when user starts typing
448+
if (businessLogicError && value.trim() !== "") {
449+
setBusinessLogicError(false);
450+
}
430451
if (isCreatingNewAgent) {
431452
setBusinessLogic(value);
432453
}
433454
}}
455+
businessLogicError={businessLogicError}
434456
selectedTools={selectedTools}
435457
setSelectedTools={setSelectedTools}
436458
isCreatingNewAgent={isCreatingNewAgent}

frontend/public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@
672672
"businessLogic.config.message.generateSuccess": "Agent prompt generated successfully",
673673
"businessLogic.config.message.generateError": "Failed to generate agent prompt",
674674
"businessLogic.config.error.noAgentId": "Cannot continue: Agent ID is not set",
675+
"businessLogic.config.error.businessDescriptionRequired": "Please enter business description first",
675676
"businessLogic.config.error.nameEmpty": "Agent name cannot be empty",
676677
"businessLogic.config.error.saveFailed": "Failed to save agent",
677678
"businessLogic.config.error.saveRetry": "Failed to save agent, please try again later",

frontend/public/locales/zh/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@
672672
"businessLogic.config.message.generateSuccess": "智能体提示词生成成功",
673673
"businessLogic.config.message.generateError": "智能体提示词生成失败",
674674
"businessLogic.config.error.noAgentId": "无法继续:未设置Agent ID",
675+
"businessLogic.config.error.businessDescriptionRequired": "请先输入业务描述",
675676
"businessLogic.config.error.nameEmpty": "Agent名称不能为空",
676677
"businessLogic.config.error.saveFailed": "Agent保存失败",
677678
"businessLogic.config.error.saveRetry": "Agent保存失败,请稍后重试",

frontend/types/agentConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export interface TreeNodeDatum {
8787
export interface AgentSetupOrchestratorProps {
8888
businessLogic: string;
8989
setBusinessLogic: (value: string) => void;
90+
businessLogicError?: boolean;
9091
selectedTools: Tool[];
9192
setSelectedTools: (tools: Tool[]) => void;
9293
isCreatingNewAgent: boolean;

0 commit comments

Comments
 (0)