feat(auto-mode): implement facade caching and enhance error handling

- Added caching for facades in AutoModeServiceCompat to persist auto loop state across API calls.
- Improved error handling in BoardView for starting and stopping auto mode, with user-friendly toast notifications.
- Updated WorktreePanel to manage auto mode state and concurrency limits more effectively.
- Enhanced useAutoMode hook to prevent state overwrites during transitions and synchronize UI with backend status.

This update optimizes performance and user experience in the auto mode feature.
This commit is contained in:
gsxdsm
2026-02-14 20:37:03 -08:00
parent bcc854234c
commit 0f0f5159d2
4 changed files with 70 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ import type { FacadeOptions, AutoModeStatus, RunningAgentInfo } from './types.js
export class AutoModeServiceCompat {
private readonly globalService: GlobalAutoModeService;
private readonly facadeOptions: FacadeOptions;
private readonly facadeCache = new Map<string, AutoModeServiceFacade>();
constructor(
events: EventEmitter,
@@ -47,10 +48,17 @@ export class AutoModeServiceCompat {
}
/**
* Create a facade for a specific project
* Get or create a facade for a specific project.
* Facades are cached by project path so that auto loop state
* (stored in the facade's AutoLoopCoordinator) persists across API calls.
*/
createFacade(projectPath: string): AutoModeServiceFacade {
return AutoModeServiceFacade.create(projectPath, this.facadeOptions);
let facade = this.facadeCache.get(projectPath);
if (!facade) {
facade = AutoModeServiceFacade.create(projectPath, this.facadeOptions);
this.facadeCache.set(projectPath, facade);
}
return facade;
}
// ===========================================================================