refactor: improve auto mode service stop logic and event emission

- Updated the stopAutoLoop method to emit the "auto_mode_stopped" event immediately when the loop is explicitly stopped, enhancing event handling.
- Improved code readability by restructuring feature retrieval calls in integration tests for better clarity.
This commit is contained in:
Cody Seibert
2025-12-14 00:51:35 -05:00
parent b52b9ba236
commit 7b3be213e4
2 changed files with 26 additions and 16 deletions

View File

@@ -152,22 +152,27 @@ export class AutoModeService {
}
this.autoLoopRunning = false;
this.emitAutoModeEvent("auto_mode_stopped", {
message: "Auto mode stopped",
projectPath: this.config?.projectPath,
});
}
/**
* Stop the auto mode loop
*/
async stopAutoLoop(): Promise<number> {
const wasRunning = this.autoLoopRunning;
this.autoLoopRunning = false;
if (this.autoLoopAbortController) {
this.autoLoopAbortController.abort();
this.autoLoopAbortController = null;
}
// Emit stop event immediately when user explicitly stops
if (wasRunning) {
this.emitAutoModeEvent("auto_mode_stopped", {
message: "Auto mode stopped",
projectPath: this.config?.projectPath,
});
}
return this.runningFeatures.size;
}