mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-17 10:03:08 +00:00
refactor(auto-mode): convert getStatusForProject to async and enhance feature retrieval
- Updated getStatusForProject method in AutoModeServiceCompat and its facade to be asynchronous, allowing for better handling of feature status retrieval. - Modified related status handlers in the server routes to await the updated method. - Introduced a new method, getRunningFeaturesForWorktree, in ConcurrencyManager to improve feature ID retrieval based on branch normalization. - Adjusted BoardView component to ensure consistent handling of running auto tasks across worktrees. These changes improve the responsiveness and accuracy of the auto mode feature in the application.
This commit is contained in:
@@ -89,16 +89,16 @@ export class AutoModeServiceCompat {
|
||||
// PER-PROJECT OPERATIONS (delegated to facades)
|
||||
// ===========================================================================
|
||||
|
||||
getStatusForProject(
|
||||
async getStatusForProject(
|
||||
projectPath: string,
|
||||
branchName: string | null = null
|
||||
): {
|
||||
): Promise<{
|
||||
isAutoLoopRunning: boolean;
|
||||
runningFeatures: string[];
|
||||
runningCount: number;
|
||||
maxConcurrency: number;
|
||||
branchName: string | null;
|
||||
} {
|
||||
}> {
|
||||
const facade = this.createFacade(projectPath);
|
||||
return facade.getStatusForProject(branchName);
|
||||
}
|
||||
|
||||
@@ -757,7 +757,7 @@ Address the follow-up instructions above. Review the previous work and make the
|
||||
* Get status for this project/worktree
|
||||
* @param branchName - The branch name, or null for main worktree
|
||||
*/
|
||||
getStatusForProject(branchName: string | null = null): ProjectAutoModeStatus {
|
||||
async getStatusForProject(branchName: string | null = null): Promise<ProjectAutoModeStatus> {
|
||||
const isAutoLoopRunning = this.autoLoopCoordinator.isAutoLoopRunningForProject(
|
||||
this.projectPath,
|
||||
branchName
|
||||
@@ -766,10 +766,12 @@ Address the follow-up instructions above. Review the previous work and make the
|
||||
this.projectPath,
|
||||
branchName
|
||||
);
|
||||
const runningFeatures = this.concurrencyManager
|
||||
.getAllRunning()
|
||||
.filter((f) => f.projectPath === this.projectPath && f.branchName === branchName)
|
||||
.map((f) => f.featureId);
|
||||
// Use branchName-normalized filter so features with branchName "main"
|
||||
// are correctly matched when querying for the main worktree (null)
|
||||
const runningFeatures = await this.concurrencyManager.getRunningFeaturesForWorktree(
|
||||
this.projectPath,
|
||||
branchName
|
||||
);
|
||||
|
||||
return {
|
||||
isAutoLoopRunning,
|
||||
|
||||
@@ -209,6 +209,41 @@ export class ConcurrencyManager {
|
||||
return Array.from(this.runningFeatures.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get running feature IDs for a specific worktree, with proper primary branch normalization.
|
||||
*
|
||||
* When branchName is null (main worktree), matches features with branchName === null
|
||||
* OR branchName matching the primary branch (e.g., "main", "master").
|
||||
*
|
||||
* @param projectPath - The project path
|
||||
* @param branchName - The branch name, or null for main worktree
|
||||
* @returns Array of feature IDs running in the specified worktree
|
||||
*/
|
||||
async getRunningFeaturesForWorktree(
|
||||
projectPath: string,
|
||||
branchName: string | null
|
||||
): Promise<string[]> {
|
||||
const primaryBranch = await this.getCurrentBranch(projectPath);
|
||||
const featureIds: string[] = [];
|
||||
|
||||
for (const [, feature] of this.runningFeatures) {
|
||||
if (feature.projectPath !== projectPath) continue;
|
||||
const featureBranch = feature.branchName ?? null;
|
||||
|
||||
if (branchName === null) {
|
||||
// Main worktree: match features with null branchName OR primary branch name
|
||||
const isPrimaryBranch =
|
||||
featureBranch === null || (primaryBranch && featureBranch === primaryBranch);
|
||||
if (isPrimaryBranch) featureIds.push(feature.featureId);
|
||||
} else {
|
||||
// Feature worktree: exact match
|
||||
if (featureBranch === branchName) featureIds.push(feature.featureId);
|
||||
}
|
||||
}
|
||||
|
||||
return featureIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update properties of a running feature
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user