Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix PR close deployment filtering and deployment disabling

Tomas Valentaa59b23e207d1
diff --git a/api-service/deployment/in_memory.py b/api-service/deployment/in_memory.py
index a36517a8c..6e6b71281 100644
--- a/api-service/deployment/in_memory.py
+++ b/api-service/deployment/in_memory.py
@@ -57,12 +57,11 @@ class InMemoryDeploymentManager(AgentDeploymentManager):
async def remove_deployment(self, id: str):
deployment = await self.get_deployment(id)
- if not deployment:
- return
+ if deployment:
+ await deployment.agent.stop()
+ del self._deployments[deployment.id]
- await deployment.agent.stop()
- await db.update_deployment(deployment.id, enabled=False)
- del self._deployments[deployment.id]
+ await db.update_deployment(id, enabled=False)
async def get_deployment(self, id: str):
return self._deployments.get(id, None)
diff --git a/github/pullRequest.ts b/github/pullRequest.ts
index 275913a8a..14931a4d5 100644
--- a/github/pullRequest.ts
+++ b/github/pullRequest.ts
@@ -179,7 +179,9 @@ export async function getDeploymentsForPR({
installationID,
issueID,
repositoryID,
+ enabled,
}: {
+ enabled: boolean | undefined,
repositoryID: number,
issueID: number,
installationID: number,
@@ -201,7 +203,7 @@ export async function getDeploymentsForPR({
},
},
where: {
- enabled: true,
+ enabled,
AND: [
{
auth: {
diff --git a/github/webhooks.ts b/github/webhooks.ts
index 5bbefb7dd..22c039aa5 100644
--- a/github/webhooks.ts
+++ b/github/webhooks.ts
@@ -44,7 +44,7 @@ const pullRequestReopenedHandler: HandlerFunction<'pull_request.reopened', unkno
throw new Error('InstallationID not found')
}
- const deployments = await getDeploymentsForPR({ issueID, installationID, repositoryID })
+ const deployments = await getDeploymentsForPR({ issueID, installationID, repositoryID, enabled: undefined })
if (deployments.length === 0) {
console.log('No deployments found')
@@ -125,7 +125,7 @@ const pullRequestClosedHandler: HandlerFunction<'pull_request.closed', unknown>
throw new Error('InstallationID not found')
}
- const deployments = await getDeploymentsForPR({ issueID, installationID, repositoryID })
+ const deployments = await getDeploymentsForPR({ issueID, installationID, repositoryID, enabled: undefined })
if (deployments.length === 0) {
console.log('No deployments found')
@@ -209,7 +209,7 @@ const pullRequestEditHandler: HandlerFunction<'pull_request.edited', unknown> =
const [prompt, deployments] = await Promise.all([
getPromptFromPR({ client, issueNumber, repo, owner, body }),
- getDeploymentsForPR({ issueID, installationID, repositoryID }),
+ getDeploymentsForPR({ issueID, installationID, repositoryID, enabled: true }),
])
if (deployments.length === 0) {
@@ -310,7 +310,7 @@ const issueCommentHandler: HandlerFunction<'issue_comment', unknown> = async (ev
const [prompt, deployments] = await Promise.all([
getPromptFromPR({ client, issueNumber: pullNumber, repo, owner, body }),
- getDeploymentsForPR({ issueID: pr.data.id, installationID, repositoryID }),
+ getDeploymentsForPR({ issueID: pr.data.id, installationID, repositoryID, enabled: true }),
])
if (deployments.length === 0) {