File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -350,13 +350,15 @@ export class EngineManager {
350350 } ) ;
351351 }
352352
353- /** 停止引擎进程(插件停用时调用) */
353+ /** 停止引擎进程 */
354354 dispose ( ) : void {
355355 if ( this . _engineProc ) {
356- this . _outputChannel . appendLine ( "[引擎] 停止引擎进程 " ) ;
356+ this . _outputChannel . appendLine ( "[引擎] 停止引擎子进程 " ) ;
357357 this . _engineProc . kill ( ) ;
358358 this . _engineProc = null ;
359359 }
360+ // 无论是否有子进程引用,都通过端口找到并杀掉 8900 上的进程
361+ this . _killExistingEngine ( ) . catch ( ( ) => { } ) ;
360362 this . _setStatus ( "offline" ) ;
361363 }
362364
Original file line number Diff line number Diff line change @@ -334,6 +334,8 @@ export function activate(context: vscode.ExtensionContext): void {
334334 // ── 一键启动引擎(v15.0:自动下载+启动二进制,无需选择目录)──
335335 context . subscriptions . push (
336336 vscode . commands . registerCommand ( "testpilot-ai.launchEngine" , async ( ) => {
337+ // 清除用户主动断开标记
338+ sidebarProvider . setUserStopped ( false ) ;
337339 // 先检查引擎是否已在运行
338340 if ( await engineManager . isEngineRunning ( ) ) {
339341 vscode . window . showInformationMessage ( "✅ TestPilot AI 引擎已在运行中" ) ;
@@ -358,7 +360,9 @@ export function activate(context: vscode.ExtensionContext): void {
358360 // ── 一键关闭引擎(v10.1)──
359361 context . subscriptions . push (
360362 vscode . commands . registerCommand ( "testpilot-ai.stopEngine" , async ( ) => {
361- // 通过 engineManager 杀掉引擎子进程
363+ // 设置用户主动断开标记,阻止轮询自动重连
364+ sidebarProvider . setUserStopped ( true ) ;
365+ // 通过 engineManager 杀掉引擎进程(包括端口 8900 上的外部进程)
362366 engineManager . dispose ( ) ;
363367 outputChannel . appendLine ( "[TestPilot AI] 引擎进程已停止" ) ;
364368 // 断开 WebSocket 连接
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
2323 private _client : EngineClient ;
2424 private _context : vscode . ExtensionContext ;
2525 private _preflightChannel ?: vscode . OutputChannel ;
26+ /** 用户主动断开标记:阻止轮询自动重连 */
27+ private _userStopped = false ;
2628
2729 constructor (
2830 private readonly _extensionUri : vscode . Uri ,
@@ -33,6 +35,11 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
3335 this . _context = context ;
3436 }
3537
38+ /** 设置用户主动断开标记(stopEngine 时调用) */
39+ public setUserStopped ( stopped : boolean ) : void {
40+ this . _userStopped = stopped ;
41+ }
42+
3643 public resolveWebviewView (
3744 webviewView : vscode . WebviewView ,
3845 _context : vscode . WebviewViewResolveContext ,
@@ -291,6 +298,11 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
291298 }
292299
293300 private async _handleCheckEngine ( ) : Promise < void > {
301+ // 用户主动断开时,跳过健康检查,直接返回未连接
302+ if ( this . _userStopped ) {
303+ this . _postMessage ( { command : "engineStatus" , data : { connected : false } } ) ;
304+ return ;
305+ }
294306 try {
295307 const health = await this . _client . checkHealth ( ) ;
296308 this . _postMessage ( {
You can’t perform that action at this time.
0 commit comments