diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css
index 5eb6a1f..de4d5db 100644
--- a/src/main/resources/static/css/style.css
+++ b/src/main/resources/static/css/style.css
@@ -277,6 +277,101 @@ body {
animation: slideIn 0.3s ease-out;
}
+/* TodoWrite 工具调用样式 */
+.todo-write-call {
+ background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
+ border-radius: 12px;
+ padding: 16px;
+ margin: 12px 0;
+ box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
+ animation: slideIn 0.3s ease-out;
+}
+
+.todo-write-header {
+ font-weight: 600;
+ color: white;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 15px;
+}
+
+/* TodoWrite 进度展示样式 */
+.todo-write-progress {
+ background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
+ border-radius: 12px;
+ padding: 16px;
+ margin: 12px 0;
+ box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
+ animation: slideIn 0.3s ease-out;
+}
+
+.todo-progress-header {
+ font-weight: 600;
+ color: white;
+ margin-bottom: 12px;
+ font-size: 15px;
+}
+
+.progress-bar-container {
+ background: rgba(255, 255, 255, 0.3);
+ border-radius: 8px;
+ height: 8px;
+ margin-bottom: 12px;
+ overflow: hidden;
+}
+
+.progress-bar {
+ background: white;
+ height: 100%;
+ border-radius: 8px;
+ transition: width 0.3s ease;
+}
+
+.todo-list {
+ background: rgba(255, 255, 255, 0.95);
+ border-radius: 8px;
+ padding: 12px;
+}
+
+.todo-item {
+ padding: 8px 12px;
+ margin: 4px 0;
+ border-radius: 6px;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 14px;
+ transition: background 0.2s;
+}
+
+.todo-item:hover {
+ background: rgba(245, 158, 11, 0.1);
+}
+
+.todo-item.todo-pending {
+ color: #6b7280;
+}
+
+.todo-item.todo-in_progress {
+ color: #2563eb;
+ font-weight: 500;
+}
+
+.todo-item.todo-completed {
+ color: #059669;
+}
+
+.todo-status {
+ font-family: 'Courier New', monospace;
+ font-weight: bold;
+ min-width: 24px;
+}
+
+.todo-content {
+ flex: 1;
+}
+
.tool-call-header {
font-weight: 600;
color: white;
diff --git a/src/main/resources/static/js/chat.js b/src/main/resources/static/js/chat.js
index d776846..8af69ea 100644
--- a/src/main/resources/static/js/chat.js
+++ b/src/main/resources/static/js/chat.js
@@ -196,13 +196,23 @@ async function streamMessageWithTools(message) {
break;
case 'tool_call':
- // 显示工具调用
- appendToolCall(data.tool_name, data.arguments);
+ // 特殊处理 TodoWrite 工具调用
+ if (data.tool_name === 'TodoWrite') {
+ appendTodoWriteCall(data.arguments);
+ } else {
+ // 显示普通工具调用
+ appendToolCall(data.tool_name, data.arguments);
+ }
break;
case 'tool_response':
- // 显示工具响应
- appendToolResult(data.tool_name, data.response);
+ // 特殊处理 TodoWrite 工具响应
+ if (data.tool_name === 'TodoWrite') {
+ appendTodoWriteProgress(data.response);
+ } else {
+ // 显示普通工具响应
+ appendToolResult(data.tool_name, data.response);
+ }
break;
case 'assistant_message':
@@ -314,6 +324,100 @@ function createAssistantMessageWithoutLoading() {
// 显示工具调用(已废弃,直接在 sendMessageWithTools 中处理)
+// 添加 TodoWrite 工具调用展示
+function appendTodoWriteCall(arguments) {
+ const todoCallDiv = document.createElement('div');
+ todoCallDiv.className = 'todo-write-call';
+
+ const headerDiv = document.createElement('div');
+ headerDiv.className = 'todo-write-header';
+ headerDiv.innerHTML = '📋 创建任务列表';
+
+ todoCallDiv.appendChild(headerDiv);
+ messagesContainer.appendChild(todoCallDiv);
+ scrollToBottom();
+}
+
+// 添加 TodoWrite 进度展示
+function appendTodoWriteProgress(response) {
+ try {
+ // 尝试解析 JSON 响应
+ let todos = [];
+ if (typeof response === 'string') {
+ // 如果响应包含 JSON,尝试提取
+ const jsonMatch = response.match(/\{[\s\S]*"todos"[\s\S]*\}/);
+ if (jsonMatch) {
+ const data = JSON.parse(jsonMatch[0]);
+ todos = data.todos || [];
+ }
+ } else if (response.todos) {
+ todos = response.todos;
+ }
+
+ if (todos.length === 0) {
+ // 如果无法解析,显示原始响应
+ appendToolResult('TodoWrite', response);
+ return;
+ }
+
+ // 计算进度
+ const total = todos.length;
+ const completed = todos.filter(t => t.status === 'completed').length;
+ const inProgress = todos.filter(t => t.status === 'in_progress').length;
+ const percentage = total > 0 ? Math.round((completed / total) * 100) : 0;
+
+ // 创建进度展示元素
+ const progressDiv = document.createElement('div');
+ progressDiv.className = 'todo-write-progress';
+
+ // 进度头部
+ const headerDiv = document.createElement('div');
+ headerDiv.className = 'todo-progress-header';
+ headerDiv.innerHTML = `📊 任务进度: ${completed}/${total} 已完成 (${percentage}%)`;
+
+ // 进度条
+ const progressBarContainer = document.createElement('div');
+ progressBarContainer.className = 'progress-bar-container';
+
+ const progressBar = document.createElement('div');
+ progressBar.className = 'progress-bar';
+ progressBar.style.width = `${percentage}%`;
+
+ progressBarContainer.appendChild(progressBar);
+
+ // 任务列表
+ const todoListDiv = document.createElement('div');
+ todoListDiv.className = 'todo-list';
+
+ todos.forEach(todo => {
+ const todoItem = document.createElement('div');
+ todoItem.className = `todo-item todo-${todo.status}`;
+
+ let statusIcon = '[ ]';
+ if (todo.status === 'completed') {
+ statusIcon = '[✓]';
+ } else if (todo.status === 'in_progress') {
+ statusIcon = '[→]';
+ }
+
+ todoItem.innerHTML = `${statusIcon} ${todo.content}`;
+ todoListDiv.appendChild(todoItem);
+ });
+
+ progressDiv.appendChild(headerDiv);
+ progressDiv.appendChild(progressBarContainer);
+ progressDiv.appendChild(todoListDiv);
+
+ messagesContainer.appendChild(progressDiv);
+ scrollToBottom();
+
+ } catch (error) {
+ console.error('解析 TodoWrite 响应失败:', error);
+ // 降级到普通工具响应展示
+ appendToolResult('TodoWrite', response);
+ }
+}
+
// 添加工具调用展示
function appendToolCall(name, arguments) {
const toolCallDiv = document.createElement('div');