chore(ui): show real tool names and speed long inputs

This commit is contained in:
JOJO 2025-12-15 18:24:44 +08:00
parent 4617e00693
commit 3729cae4d2
3 changed files with 50 additions and 20 deletions

View File

@ -1288,11 +1288,7 @@ export class MonitorDirector implements MonitorDriver {
}
this.commandCurrentText = '';
}
const chars = Array.from(text);
for (const ch of chars) {
target.textContent = (target.textContent || '') + ch;
await sleep(28);
}
await this.typeSmartText(target, text);
this.commandCurrentText = text;
}
@ -1364,10 +1360,35 @@ export class MonitorDirector implements MonitorDriver {
target.textContent = code;
return;
}
const chars = Array.from(code);
await this.typeSmartText(target, code);
}
/**
*
*
*/
private async typeSmartText(target: HTMLElement, text: string) {
const lines = text.split('\n');
const long = lines.length > 8 || text.length > 400;
const lineDelay = 55;
if (long) {
target.textContent = '';
lines.forEach((line, idx) => {
target.textContent += (idx > 0 ? '\n' : '') + line;
});
// 行级动画:逐行显现
const chunks = target.textContent.split('\n');
target.textContent = '';
for (let i = 0; i < chunks.length; i += 1) {
target.textContent += (i > 0 ? '\n' : '') + chunks[i];
await sleep(lineDelay);
}
return;
}
const chars = Array.from(text);
for (const ch of chars) {
target.textContent = (target.textContent || '') + ch;
await sleep(24);
await sleep(26);
}
}
@ -2575,7 +2596,8 @@ export class MonitorDirector implements MonitorDriver {
this.sceneHandlers.modifyFile = this.sceneHandlers.appendFile;
this.sceneHandlers.runCommand = async (payload, runtime) => {
this.applySceneStatus(runtime, 'runCommand', '正在执行命令');
const toolLabel = payload?.name || payload?.tool || 'run_command';
this.applySceneStatus(runtime, 'runCommand', `调用 ${toolLabel}`);
const command = payload?.arguments?.command || payload?.result?.command || 'echo \"Hello\"';
const reuse = this.isWindowVisible(this.elements.commandWindow);
if (reuse) {
@ -2602,7 +2624,8 @@ export class MonitorDirector implements MonitorDriver {
};
this.sceneHandlers.runPython = async (payload, runtime) => {
this.applySceneStatus(runtime, 'runPython', '正在执行 Python');
const toolLabel = payload?.name || payload?.tool || 'run_python';
this.applySceneStatus(runtime, 'runPython', `调用 ${toolLabel}`);
const runId =
payload?.executionId ||
payload?.execution_id ||
@ -3058,8 +3081,9 @@ export class MonitorDirector implements MonitorDriver {
await sleep(600);
};
this.sceneHandlers.genericTool = async (_payload, runtime) => {
this.applySceneStatus(runtime, 'genericTool', '正在执行工具');
this.sceneHandlers.genericTool = async (payload, runtime) => {
const toolLabel = payload?.name || payload?.tool || 'tool';
this.applySceneStatus(runtime, 'genericTool', `调用 ${toolLabel}`);
await sleep(600);
};
}

View File

@ -10,10 +10,11 @@ export const SCENE_PROGRESS_LABELS: Record<string, string> = {
reader: '正在读取',
focus: '正在聚焦',
unfocus: '正在处理',
runCommand: '正在执行',
runPython: '正在执行',
// 运行类工具显示具体工具名,由运行时传入
runCommand: '',
runPython: '',
terminalSession: '正在连接终端',
terminalInput: '正在发送命令',
terminalInput: '',
terminalSnapshot: '正在获取终端',
memoryUpdate: '正在同步记忆',
todoCreate: '正在更新待办',
@ -27,11 +28,11 @@ export const SCENE_PROGRESS_LABELS: Record<string, string> = {
renameFile: '正在重命名',
terminalReset: '正在重置终端',
terminalSleep: '准备等待',
terminalRun: '正在执行',
terminalRun: '',
ocr: '正在提取',
memory: '正在同步记忆',
todo: '正在管理待办',
genericTool: '正在执行'
genericTool: ''
};
export function getSceneProgressLabel(name: string): string | null {

View File

@ -44,11 +44,11 @@ const RUNNING_STATUS_TEXTS: Record<string, string> = {
web_search: '正在搜索网络...',
extract_webpage: '正在提取网页...',
save_webpage: '正在保存网页...',
run_python: '正在执行Python代码...',
run_command: '正在执行命令...',
run_python: '',
run_command: '',
update_memory: '正在更新记忆...',
terminal_session: '正在管理终端会话...',
terminal_input: '正在发送终端输入...',
terminal_input: '',
terminal_snapshot: '正在获取终端快照...',
terminal_reset: '正在重置终端...'
};
@ -173,7 +173,12 @@ export function getToolStatusText(tool: any): string {
};
return runningMap[readType] || '正在读取文件...';
}
return RUNNING_STATUS_TEXTS[tool.name] || '正在执行...';
const label =
RUNNING_STATUS_TEXTS[tool.name] ||
tool.display_name ||
tool.name ||
'';
return label ? `调用 ${label}` : '调用工具中';
}
if (tool.status === 'completed') {
if (tool.name === 'read_file') {