mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-19 22:53:08 +00:00
refactor(06-03): migrate Batch 5 secondary routes and wire router index
- features/routes/list.ts: Add facadeFactory parameter, use facade.detectOrphanedFeatures - projects/routes/overview.ts: Add facadeFactory parameter, use facade.getRunningAgents/getStatusForProject - features/index.ts: Pass facadeFactory to list handler - projects/index.ts: Pass facadeFactory to overview handler - auto-mode/index.ts: Accept facadeFactory parameter and wire to all route handlers - All routes maintain backward compatibility with autoModeService fallback
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import { Router } from 'express';
|
||||
import type { FeatureLoader } from '../../services/feature-loader.js';
|
||||
import type { AutoModeService } from '../../services/auto-mode-service.js';
|
||||
import type { AutoModeServiceFacade } from '../../services/auto-mode/index.js';
|
||||
import type { SettingsService } from '../../services/settings-service.js';
|
||||
import type { NotificationService } from '../../services/notification-service.js';
|
||||
import { createOverviewHandler } from './routes/overview.js';
|
||||
@@ -13,14 +14,21 @@ export function createProjectsRoutes(
|
||||
featureLoader: FeatureLoader,
|
||||
autoModeService: AutoModeService,
|
||||
settingsService: SettingsService,
|
||||
notificationService: NotificationService
|
||||
notificationService: NotificationService,
|
||||
facadeFactory?: (projectPath: string) => AutoModeServiceFacade
|
||||
): Router {
|
||||
const router = Router();
|
||||
|
||||
// GET /overview - Get aggregate status for all projects
|
||||
router.get(
|
||||
'/overview',
|
||||
createOverviewHandler(featureLoader, autoModeService, settingsService, notificationService)
|
||||
createOverviewHandler(
|
||||
featureLoader,
|
||||
autoModeService,
|
||||
settingsService,
|
||||
notificationService,
|
||||
facadeFactory
|
||||
)
|
||||
);
|
||||
|
||||
return router;
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
import type { Request, Response } from 'express';
|
||||
import type { FeatureLoader } from '../../../services/feature-loader.js';
|
||||
import type { AutoModeService } from '../../../services/auto-mode-service.js';
|
||||
import type {
|
||||
AutoModeServiceFacade,
|
||||
RunningAgentInfo,
|
||||
ProjectAutoModeStatus,
|
||||
} from '../../../services/auto-mode/index.js';
|
||||
import type { SettingsService } from '../../../services/settings-service.js';
|
||||
import type { NotificationService } from '../../../services/notification-service.js';
|
||||
import type {
|
||||
@@ -149,7 +154,8 @@ export function createOverviewHandler(
|
||||
featureLoader: FeatureLoader,
|
||||
autoModeService: AutoModeService,
|
||||
settingsService: SettingsService,
|
||||
notificationService: NotificationService
|
||||
notificationService: NotificationService,
|
||||
facadeFactory?: (projectPath: string) => AutoModeServiceFacade
|
||||
) {
|
||||
return async (_req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
@@ -158,7 +164,15 @@ export function createOverviewHandler(
|
||||
const projectRefs: ProjectRef[] = settings.projects || [];
|
||||
|
||||
// Get all running agents once to count live running features per project
|
||||
const allRunningAgents = await autoModeService.getRunningAgents();
|
||||
// Use facade if available, otherwise fall back to autoModeService
|
||||
let allRunningAgents: RunningAgentInfo[];
|
||||
if (facadeFactory && projectRefs.length > 0) {
|
||||
// For running agents, we can use any project's facade since it's a global query
|
||||
const facade = facadeFactory(projectRefs[0].path);
|
||||
allRunningAgents = await facade.getRunningAgents();
|
||||
} else {
|
||||
allRunningAgents = await autoModeService.getRunningAgents();
|
||||
}
|
||||
|
||||
// Collect project statuses in parallel
|
||||
const projectStatusPromises = projectRefs.map(async (projectRef): Promise<ProjectStatus> => {
|
||||
@@ -169,7 +183,13 @@ export function createOverviewHandler(
|
||||
const totalFeatures = features.length;
|
||||
|
||||
// Get auto-mode status for this project (main worktree, branchName = null)
|
||||
const autoModeStatus = autoModeService.getStatusForProject(projectRef.path, null);
|
||||
let autoModeStatus: ProjectAutoModeStatus;
|
||||
if (facadeFactory) {
|
||||
const facade = facadeFactory(projectRef.path);
|
||||
autoModeStatus = facade.getStatusForProject(null);
|
||||
} else {
|
||||
autoModeStatus = autoModeService.getStatusForProject(projectRef.path, null);
|
||||
}
|
||||
const isAutoModeRunning = autoModeStatus.isAutoLoopRunning;
|
||||
|
||||
// Count live running features for this project (across all branches)
|
||||
|
||||
Reference in New Issue
Block a user