feat: AI 命令执行实时流式推送到工作空间终端

- execWorkspaceCommand 新增 onOutput 回调,stdout/stderr 实时推送
- ipc.ts workspace:execTool 实时转发输出 + 发送 toolDone 完成通知
- 渲染进程 appendToolStreamOutput 流式显示,handleToolDone 显示退出状态
- 去掉 tool-handlers.ts 中的一次性完整输出推送
- 完整流程:用户确认 → 实时输出 → 完成通知 → AI 回复结果
This commit is contained in:
thzxx
2026-04-08 13:06:57 +08:00
parent d150b53116
commit d5e5f5f58a
6 changed files with 70 additions and 51 deletions
-11
View File
@@ -6,7 +6,6 @@
import * as fs from 'fs/promises';
import * as path from 'path';
import { checkPathAllowed, checkCommandAllowed } from './tool-security.js';
import { mainWindow } from './main.js';
import { execWorkspaceCommand } from './workspace.js';
export interface ToolResult {
@@ -271,16 +270,6 @@ export async function handleRunCommand(params: { command: string; cwd?: string;
// 通过 workspace 子进程执行,复用安全检查和进程管理
const result = await execWorkspaceCommand(params.command, params.cwd);
// 将命令和输出同步推送到工作空间终端面板
if (mainWindow) {
mainWindow.webContents.send('workspace:toolOutput', {
command: params.command,
stdout: result.stdout,
stderr: result.stderr,
exitCode: result.exitCode
});
}
return {
success: result.success,
stdout: result.stdout,