From 1b27b3ffa299237682fdcef48dcbcbf11a100a72 Mon Sep 17 00:00:00 2001
From: JOJO <1498581755@qq.com>
Date: Sun, 19 Apr 2026 16:57:23 +0800
Subject: [PATCH] fix: simplify enhanced display for personalization updates
---
.../components/chat/actions/ToolAction.vue | 28 +-------
.../components/chat/actions/toolRenderers.ts | 64 +++++++++++++++++++
2 files changed, 66 insertions(+), 26 deletions(-)
diff --git a/static/src/components/chat/actions/ToolAction.vue b/static/src/components/chat/actions/ToolAction.vue
index e03d325..00785fd 100644
--- a/static/src/components/chat/actions/ToolAction.vue
+++ b/static/src/components/chat/actions/ToolAction.vue
@@ -778,42 +778,18 @@ function renderManagePersonalization(result: any, args: any): string {
if (action === 'update') {
const field = String(result.updated_field || args.field || '');
- const oldValue = result.old_value ?? args.old_value;
const newValue = result.updated_value ?? args.value;
if (field) {
- html += `
字段:${escapeHtml(formatPersonalizationFieldLabel(field))}
`;
- html += `新值:${escapeHtml(formatPersonalizationFieldValue(field, newValue))}
`;
- if (oldValue !== undefined) {
- html += `旧值:${escapeHtml(formatPersonalizationFieldValue(field, oldValue))}
`;
- }
- }
- if (result?.theme_changed && result?.new_theme) {
- html += `主题刷新:${escapeHtml(formatPersonalizationFieldValue('theme', result.new_theme))}
`;
+ html += `修改项:${escapeHtml(formatPersonalizationFieldLabel(field))}
`;
+ html += `修改后:${escapeHtml(formatPersonalizationFieldValue(field, newValue))}
`;
}
html += '';
return html;
}
-
- const data = result?.data && typeof result.data === 'object' ? result.data : {};
- const entries = Object.entries(data);
- html += `配置项:${entries.length} 项
`;
html += '';
- if (entries.length > 0) {
- html += '';
- html += '
当前个性化配置
';
- html += '
';
- entries.forEach(([field, value]) => {
- html += '
';
- html += `${escapeHtml(formatPersonalizationFieldLabel(field))}`;
- html += `${escapeHtml(formatPersonalizationFieldValue(field, value))}`;
- html += '
';
- });
- html += '
';
- }
-
return html;
}
diff --git a/static/src/components/chat/actions/toolRenderers.ts b/static/src/components/chat/actions/toolRenderers.ts
index a463386..51ba563 100644
--- a/static/src/components/chat/actions/toolRenderers.ts
+++ b/static/src/components/chat/actions/toolRenderers.ts
@@ -98,6 +98,10 @@ export function renderEnhancedToolResult(
else if (name === 'update_memory') {
return renderUpdateMemory(result, args);
}
+ // 个性化管理类
+ else if (name === 'manage_personalization') {
+ return renderManagePersonalization(result, args);
+ }
// 待办事项类
else if (name === 'todo_create') {
@@ -626,6 +630,66 @@ function renderUpdateMemory(result: any, args: any): string {
return html;
}
+function formatPersonalizationFieldLabel(field: string): string {
+ const labelMap: Record = {
+ self_identify: 'AI 自称',
+ user_name: '用户称呼',
+ profession: '用户职业',
+ tone: '交流语气',
+ considerations: '注意事项',
+ theme: '主题',
+ communication_style: '交流风格',
+ enabled: '个性化开关'
+ };
+ return labelMap[field] || field;
+}
+
+function formatPersonalizationFieldValue(field: string, value: any): string {
+ if (value === null || value === undefined || value === '') {
+ return '未设置';
+ }
+ if (field === 'enabled') {
+ return value ? '开启' : '关闭';
+ }
+ if (field === 'considerations') {
+ if (!Array.isArray(value) || value.length === 0) {
+ return '未设置';
+ }
+ return value.map((item) => String(item)).join('、');
+ }
+ return String(value);
+}
+
+function renderManagePersonalization(result: any, args: any): string {
+ const action = String(args.action || result.action || 'read');
+ const status = formatToolStatusLabel(result, action === 'update' ? '✓ 已更新' : '✓ 已读取');
+ const field = String(result.updated_field || args.field || '');
+ const newValue = result.updated_value ?? args.value;
+
+ let html = '';
+ return html;
+ }
+
+ if (action === 'update' && field) {
+ html += `修改项:${escapeHtml(formatPersonalizationFieldLabel(field))}
`;
+ html += `修改后:${escapeHtml(formatPersonalizationFieldValue(field, newValue))}
`;
+ }
+
+ html += '';
+ return html;
+}
+
// 待办事项类渲染函数
function renderTodoCreate(result: any, args: any): string {
const status = formatToolStatusLabel(result, '✓ 已创建');