-
Notifications
You must be signed in to change notification settings - Fork 489
feat: implement cursor model migration and enhance auto mode function… #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * POST /start endpoint - Start auto mode loop for a project | ||
| */ | ||
|
|
||
| import type { Request, Response } from 'express'; | ||
| import type { AutoModeService } from '../../../services/auto-mode-service.js'; | ||
| import { createLogger } from '@automaker/utils'; | ||
| import { getErrorMessage, logError } from '../common.js'; | ||
|
|
||
| const logger = createLogger('AutoMode'); | ||
|
|
||
| export function createStartHandler(autoModeService: AutoModeService) { | ||
| return async (req: Request, res: Response): Promise<void> => { | ||
| try { | ||
| const { projectPath, maxConcurrency } = req.body as { | ||
| projectPath: string; | ||
| maxConcurrency?: number; | ||
| }; | ||
|
|
||
| if (!projectPath) { | ||
| res.status(400).json({ | ||
| success: false, | ||
| error: 'projectPath is required', | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| // Check if already running | ||
| if (autoModeService.isAutoLoopRunningForProject(projectPath)) { | ||
| res.json({ | ||
| success: true, | ||
| message: 'Auto mode is already running for this project', | ||
| alreadyRunning: true, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| // Start the auto loop for this project | ||
| await autoModeService.startAutoLoopForProject(projectPath, maxConcurrency ?? 3); | ||
|
|
||
| logger.info( | ||
| `Started auto loop for project: ${projectPath} with maxConcurrency: ${maxConcurrency ?? 3}` | ||
| ); | ||
|
|
||
| res.json({ | ||
| success: true, | ||
| message: `Auto mode started with max ${maxConcurrency ?? 3} concurrent features`, | ||
| }); | ||
| } catch (error) { | ||
| logError(error, 'Start auto mode failed'); | ||
| res.status(500).json({ success: false, error: getErrorMessage(error) }); | ||
| } | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * POST /stop endpoint - Stop auto mode loop for a project | ||
| */ | ||
|
|
||
| import type { Request, Response } from 'express'; | ||
| import type { AutoModeService } from '../../../services/auto-mode-service.js'; | ||
| import { createLogger } from '@automaker/utils'; | ||
| import { getErrorMessage, logError } from '../common.js'; | ||
|
|
||
| const logger = createLogger('AutoMode'); | ||
|
|
||
| export function createStopHandler(autoModeService: AutoModeService) { | ||
| return async (req: Request, res: Response): Promise<void> => { | ||
| try { | ||
| const { projectPath } = req.body as { | ||
| projectPath: string; | ||
| }; | ||
|
|
||
| if (!projectPath) { | ||
| res.status(400).json({ | ||
| success: false, | ||
| error: 'projectPath is required', | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| // Check if running | ||
| if (!autoModeService.isAutoLoopRunningForProject(projectPath)) { | ||
| res.json({ | ||
| success: true, | ||
| message: 'Auto mode is not running for this project', | ||
| wasRunning: false, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| // Stop the auto loop for this project | ||
| const runningCount = await autoModeService.stopAutoLoopForProject(projectPath); | ||
|
|
||
| logger.info( | ||
| `Stopped auto loop for project: ${projectPath}, ${runningCount} features still running` | ||
| ); | ||
|
|
||
| res.json({ | ||
| success: true, | ||
| message: 'Auto mode stopped', | ||
| runningFeaturesCount: runningCount, | ||
| }); | ||
| } catch (error) { | ||
| logError(error, 'Stop auto mode failed'); | ||
| res.status(500).json({ success: false, error: getErrorMessage(error) }); | ||
| } | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and avoid magic numbers, the default value for
maxConcurrency(which is3) should be extracted into a constant. This value is repeated three times in this block.You can define a constant at the top of the file:
And then use it like this: