Skip to content

Commit b153ba1

Browse files
committed
优化AI智能体组件,新增hideUserInput属性以控制用户输入气泡的显示,提升对话界面的灵活性和用户体验。同时,更新VectorizeModal组件,确保成功提示仅在提示文本不为空时显示,增强用户反馈的准确性。更新国际化文本,添加索引提醒内容,确保多语言支持的准确性和一致性。
1 parent 5a9a78a commit b153ba1

4 files changed

Lines changed: 84 additions & 50 deletions

File tree

src/components/AIagent.tsx

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ interface DialogRound {
7979
elementRef?: React.RefObject<HTMLDivElement>;
8080
knowledgeEntries?: string[];
8181
fileOperations?: FileOperation[];
82+
hideUserInput?: boolean; // 是否隐藏用户输入气泡
8283
}
8384

8485
// 自定义代码块组件
@@ -416,6 +417,7 @@ export default function AIagent({
416417
userInput: initialPrompt,
417418
aiResponse: "",
418419
files: relevantFiles,
420+
hideUserInput: true, // 隐藏第一轮用户输入气泡
419421
};
420422

421423
setDialogRounds([newRound]);
@@ -1473,31 +1475,33 @@ false
14731475
<div className="flex flex-col space-y-4 mb-4">
14741476
{dialogRounds.map((round, index) => (
14751477
<div key={index} className="flex flex-col space-y-2">
1476-
{/* 用户输入 */}
1477-
<div className="bg-blue-50 dark:bg-blue-900/30 p-3 rounded-lg">
1478-
<div className="flex items-center mb-2">
1479-
<div className="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white mr-2">
1480-
<svg
1481-
xmlns="http://www.w3.org/2000/svg"
1482-
className="h-5 w-5"
1483-
viewBox="0 0 20 20"
1484-
fill="currentColor"
1485-
>
1486-
<path
1487-
fillRule="evenodd"
1488-
d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
1489-
clipRule="evenodd"
1490-
/>
1491-
</svg>
1478+
{/* 用户输入 - 只有当hideUserInput为false或未定义时才显示 */}
1479+
{!round.hideUserInput && (
1480+
<div className="bg-blue-50 dark:bg-blue-900/30 p-3 rounded-lg">
1481+
<div className="flex items-center mb-2">
1482+
<div className="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white mr-2">
1483+
<svg
1484+
xmlns="http://www.w3.org/2000/svg"
1485+
className="h-5 w-5"
1486+
viewBox="0 0 20 20"
1487+
fill="currentColor"
1488+
>
1489+
<path
1490+
fillRule="evenodd"
1491+
d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
1492+
clipRule="evenodd"
1493+
/>
1494+
</svg>
1495+
</div>
1496+
<div className="font-medium text-blue-700 dark:text-blue-300">
1497+
{t("aiagent.user")}
1498+
</div>
14921499
</div>
1493-
<div className="font-medium text-blue-700 dark:text-blue-300">
1494-
{t("aiagent.user")}
1500+
<div className="text-gray-700 dark:text-gray-200 ml-10">
1501+
{round.userInput}
14951502
</div>
14961503
</div>
1497-
<div className="text-gray-700 dark:text-gray-200 ml-10">
1498-
{round.userInput}
1499-
</div>
1500-
</div>
1504+
)}
15011505

15021506
{/* AI响应 */}
15031507
<div
@@ -1659,23 +1663,45 @@ false
16591663
<p className="text-gray-600 dark:text-gray-300 text-center mb-6">
16601664
{t("aiagent.permissionDescription")}
16611665
</p>
1662-
<div className="bg-yellow-50 dark:bg-yellow-900/30 p-3 rounded-lg mb-6 w-full">
1663-
<div className="flex items-start">
1664-
<svg
1665-
xmlns="http://www.w3.org/2000/svg"
1666-
className="h-5 w-5 text-yellow-500 mt-0.5 mr-2 flex-shrink-0"
1667-
viewBox="0 0 20 20"
1668-
fill="currentColor"
1669-
>
1670-
<path
1671-
fillRule="evenodd"
1672-
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
1673-
clipRule="evenodd"
1674-
/>
1675-
</svg>
1676-
<p className="text-sm text-yellow-700 dark:text-yellow-200">
1677-
{t("aiagent.permissionWarning")}
1678-
</p>
1666+
<div className="space-y-3 mb-6 w-full">
1667+
<div className="bg-yellow-50 dark:bg-yellow-900/30 p-3 rounded-lg">
1668+
<div className="flex items-start">
1669+
<svg
1670+
xmlns="http://www.w3.org/2000/svg"
1671+
className="h-5 w-5 text-yellow-500 mt-0.5 mr-2 flex-shrink-0"
1672+
viewBox="0 0 20 20"
1673+
fill="currentColor"
1674+
>
1675+
<path
1676+
fillRule="evenodd"
1677+
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
1678+
clipRule="evenodd"
1679+
/>
1680+
</svg>
1681+
<p className="text-sm text-yellow-700 dark:text-yellow-200">
1682+
{t("aiagent.permissionWarning")}
1683+
</p>
1684+
</div>
1685+
</div>
1686+
1687+
<div className="bg-blue-50 dark:bg-blue-900/30 p-3 rounded-lg">
1688+
<div className="flex items-start">
1689+
<svg
1690+
xmlns="http://www.w3.org/2000/svg"
1691+
className="h-5 w-5 text-blue-500 mt-0.5 mr-2 flex-shrink-0"
1692+
viewBox="0 0 20 20"
1693+
fill="currentColor"
1694+
>
1695+
<path
1696+
fillRule="evenodd"
1697+
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
1698+
clipRule="evenodd"
1699+
/>
1700+
</svg>
1701+
<p className="text-sm text-blue-700 dark:text-blue-200">
1702+
{t("aiagent.indexingReminder")}
1703+
</p>
1704+
</div>
16791705
</div>
16801706
</div>
16811707
<div className="flex space-x-4">

src/components/VectorizeModal.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,15 @@ export default function VectorizeModal({ onClose }: VectorizeModalProps) {
154154
const estimatedTokens = savedFiles * 200;
155155
setTokensSaved(estimatedTokens);
156156

157-
// 显示成功提示,3秒后自动消失
158-
setShowSuccessToast(true);
159-
const timer = setTimeout(() => setShowSuccessToast(false), 5000);
160-
return () => clearTimeout(timer);
157+
// 只有当提示文本不为空时才显示提示
158+
if (t("vectorReport.resultCopied")) {
159+
// 显示成功提示,3秒后自动消失
160+
setShowSuccessToast(true);
161+
const timer = setTimeout(() => setShowSuccessToast(false), 5000);
162+
return () => clearTimeout(timer);
163+
}
161164
}
162-
}, [result, relevantFiles, currentScan]);
165+
}, [result, relevantFiles, currentScan, t]);
163166

164167
const handleSubmit = async (e: React.FormEvent) => {
165168
e.preventDefault();
@@ -465,8 +468,11 @@ ${functions
465468
navigator.clipboard
466469
.writeText(result)
467470
.then(() => {
468-
setShowSuccessToast(true);
469-
setTimeout(() => setShowSuccessToast(false), 3000);
471+
// 只有当提示文本不为空时才显示提示
472+
if (t("vectorReport.resultCopied")) {
473+
setShowSuccessToast(true);
474+
setTimeout(() => setShowSuccessToast(false), 3000);
475+
}
470476
})
471477
.catch((err) => {
472478
console.error("复制失败:", err);
@@ -629,9 +635,9 @@ ${functions
629635
/>
630636
)}
631637

632-
{/* 成功提示 */}
638+
{/* 成功提示 - 只有当提示文本不为空时才显示 */}
633639
<AnimatePresence>
634-
{showSuccessToast && (
640+
{showSuccessToast && t("vectorReport.resultCopied") && (
635641
<motion.div
636642
initial={{ opacity: 0, y: -50 }}
637643
animate={{ opacity: 1, y: 0 }}

src/messages/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@
780780
"scanningTip": "You can enter your prompt now, but you'll need to wait for the scan to complete before vectorizing",
781781
"enableContentMatching": "Enable precise Mode (may increase processing time) @Deprecated",
782782
"copyPrompt": "Copy Prompt",
783-
"resultCopied": "Vectorization result copied to clipboard!",
783+
"resultCopied": "",
784784
"resultPreview": "Result Preview",
785785
"markdownFormat": "Markdown format",
786786
"resultDescription": "Structured Markdown text containing query, related file list, file contents, and optimization statistics",
@@ -876,6 +876,7 @@
876876
"permissionTitle": "Permission Required",
877877
"permissionDescription": "The agent needs permission to modify files in order to continue.",
878878
"permissionWarning": "Warning: The agent will be able to modify, delete, and create project files. Make sure you trust this operation.",
879+
"indexingReminder": "Note: Please ensure the 'Start Index' feature is enabled for the agent to access the latest code information.",
879880
"grantPermission": "Grant Permission",
880881
"cancel": "Cancel",
881882
"modifyFile": "Modify File",

src/messages/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@
780780
"scanningTip": "您可以先输入提示词,但需要等待扫描完成后才能进行向量化",
781781
"enableContentMatching": "启用精准模式(可能会增加处理时间) @Deprecated",
782782
"copyPrompt": "复制Prompt",
783-
"resultCopied": "向量化结果已复制到剪贴板!",
783+
"resultCopied": "",
784784
"resultPreview": "结果预览",
785785
"markdownFormat": "Markdown格式",
786786
"resultDescription": "已生成结构化的Markdown文本,包含查询内容、相关文件列表、文件内容和优化统计",
@@ -880,6 +880,7 @@
880880
"inputPlaceholder": "输入您的问题...按Ctrl+Enter发送",
881881
"permissionDescription": "智能体需要获取修改文件的权限才能继续操作。",
882882
"permissionWarning": "警告:智能体将能够修改、删除和创建项目文件。请确保您信任此操作。",
883+
"indexingReminder": "提示:请确保已启用持续索引功能,以便智能体能够获取最新的代码信息。",
883884
"grantPermission": "授予权限",
884885
"cancel": "取消",
885886
"modifyFile": "修改文件",

0 commit comments

Comments
 (0)