diff --git a/App/FeatureSet/Workers/Index.ts b/App/FeatureSet/Workers/Index.ts index 25d325b22b..6efad5c004 100644 --- a/App/FeatureSet/Workers/Index.ts +++ b/App/FeatureSet/Workers/Index.ts @@ -67,6 +67,9 @@ import logger from "Common/Server/Utils/Logger"; import "./Jobs/Probe/SendOwnerAddedNotification"; import "./Jobs/Probe/UpdateConnectionStatus"; +// Copilot Actions. +import "./Jobs/CopilotActions/MoveThemBackToQueueIfProcessingForLongtime"; + // Telemetry Monitors. import "./Jobs/TelemetryMonitor/MonitorTelemetryMonitor"; import Express, { ExpressApplication } from "Common/Server/Utils/Express"; diff --git a/App/FeatureSet/Workers/Jobs/CopilotActions/MoveThemBackToQueueIfProcessingForLongtime.ts b/App/FeatureSet/Workers/Jobs/CopilotActions/MoveThemBackToQueueIfProcessingForLongtime.ts index b52224e183..8708cdf11d 100644 --- a/App/FeatureSet/Workers/Jobs/CopilotActions/MoveThemBackToQueueIfProcessingForLongtime.ts +++ b/App/FeatureSet/Workers/Jobs/CopilotActions/MoveThemBackToQueueIfProcessingForLongtime.ts @@ -22,7 +22,7 @@ RunCron( await CopilotActionService.findBy({ query: { copilotActionStatus: CopilotActionStatus.PROCESSING, - statusChangedAt: QueryHelper.lessThanEqualTo(lastHour), + statusChangedAt: QueryHelper.lessThanEqualToOrNull(lastHour), }, select: { _id: true, diff --git a/Copilot/Init.ts b/Copilot/Init.ts index da0269c134..41b90a9205 100644 --- a/Copilot/Init.ts +++ b/Copilot/Init.ts @@ -28,8 +28,6 @@ let currentFixCount: number = 1; const init: PromiseVoidFunction = async (): Promise => { // check if copilot is disabled. - debugger; - if (GetIsCopilotDisabled()) { logger.info("Copilot is disabled. Exiting."); ProcessUtil.haltProcessWithSuccess(); diff --git a/Copilot/Service/CopilotActions/ImproveComments.ts b/Copilot/Service/CopilotActions/ImproveComments.ts index dc987c5c02..c9e56c89c0 100644 --- a/Copilot/Service/CopilotActions/ImproveComments.ts +++ b/Copilot/Service/CopilotActions/ImproveComments.ts @@ -16,6 +16,7 @@ import ServiceRepositoryUtil from "../../Utils/ServiceRepository"; import Dictionary from "Common/Types/Dictionary"; import ArrayUtil from "Common/Utils/Array"; import CopilotActionProp from "Common/Types/Copilot/CopilotActionProps/Index"; +import BadDataException from "Common/Types/Exception/BadDataException"; export default class ImproveComments extends CopilotActionBase { public isRequirementsMet: boolean = false; @@ -54,9 +55,6 @@ export default class ImproveComments extends CopilotActionBase { maxActionsToQueue: number; }): Promise> { // get files in the repo. - - debugger; - logger.debug( `${this.copilotActionType} - Getting files to queue for improve comments.`, ); @@ -113,6 +111,31 @@ export default class ImproveComments extends CopilotActionBase { return actionsPropsQueued; } + public override async getCommitMessage( + data: CopilotProcess, + ): Promise { + return ( + "Improved comments on " + (data.actionProp as FileActionProp).filePath + ); + } + + public override async getPullRequestTitle( + data: CopilotProcess, + ): Promise { + return ( + "Improved comments on " + (data.actionProp as FileActionProp).filePath + ); + } + + public override async getPullRequestBody( + data: CopilotProcess, + ): Promise { + return `Improved comments on ${(data.actionProp as FileActionProp).filePath} + + ${await this.getDefaultPullRequestBody()} + `; + } + public override isActionComplete(_data: CopilotProcess): Promise { return Promise.resolve(this.isRequirementsMet); } @@ -120,10 +143,18 @@ export default class ImproveComments extends CopilotActionBase { public override async onExecutionStep( data: CopilotProcess, ): Promise { - // Action Prompt + const filePath: string = (data.actionProp as FileActionProp).filePath; + + if (!filePath) { + throw new BadDataException("File Path is not set in the action prop."); + } + + const fileContent: string = await ServiceRepositoryUtil.getFileContent({ + filePath: filePath, + }); const codeParts: string[] = await this.splitInputCode({ - code: "", + code: fileContent, itemSize: 500, }); diff --git a/Copilot/Service/CopilotActions/Index.ts b/Copilot/Service/CopilotActions/Index.ts index 5627d2e495..83686e2714 100644 --- a/Copilot/Service/CopilotActions/Index.ts +++ b/Copilot/Service/CopilotActions/Index.ts @@ -39,7 +39,6 @@ export default class CopilotActionService { ActionDictionary[data.copilotAction.copilotActionType!]; if (!ActionType) { - debugger; throw new BadDataException("Invalid CopilotActionType"); } diff --git a/Copilot/Utils/CopilotAction.ts b/Copilot/Utils/CopilotAction.ts index c2e95d8c71..ea70039b3a 100644 --- a/Copilot/Utils/CopilotAction.ts +++ b/Copilot/Utils/CopilotAction.ts @@ -285,8 +285,6 @@ export default class CopilotActionUtil { throw new BadDataException("Repository Secret Key is required"); } - debugger; - const url: URL = URL.fromString( GetOneUptimeURL().toString() + "/api", ).addRoute(