Skip to content

Commit 1eee019

Browse files
Remove Mergeable check and fix Devin status polling (#2072)
- Remove bot-ci.ts which created the 'Mergeable: bot_ci' check - Remove related tests and fixtures for bot_ci handler - Fix Devin status polling to reconcile stuck checks on startup - Now fetches all sessions (not just running) on startup - Updates checks for finished/expired sessions immediately - Only tracks working/blocked sessions for ongoing polling - Update vitest config to pass with no tests Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent d695547 commit 1eee019

File tree

9 files changed

+44
-458
lines changed

9 files changed

+44
-458
lines changed

apps/bot/src/devin/poller.ts

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class DevinStatusPoller {
168168
this.logger.info("Discovering existing Devin sessions with open PRs...");
169169

170170
try {
171-
const { sessions } = await listDevinSessions({ status: "running" });
171+
const { sessions } = await listDevinSessions({});
172172

173173
for (const session of sessions) {
174174
if (!session.pull_request?.url) {
@@ -182,9 +182,6 @@ export class DevinStatusPoller {
182182
}
183183

184184
const detail = await getDevinSessionDetail(session.session_id);
185-
if (detail.status_enum !== DevinSessionStatus.Working) {
186-
continue;
187-
}
188185

189186
try {
190187
const octokit = await this.createOctokit();
@@ -198,15 +195,55 @@ export class DevinStatusPoller {
198195
continue;
199196
}
200197

201-
this.trackPR({
198+
const trackedPR: TrackedPR = {
202199
owner: parsed.owner,
203200
repo: parsed.repo,
204201
prNumber: parsed.prNumber,
205202
prUrl,
206203
headSha: pr.head.sha,
207204
sessionId: session.session_id,
208205
addedAt: Date.now(),
209-
});
206+
};
207+
208+
if (
209+
detail.status_enum === DevinSessionStatus.Working ||
210+
detail.status_enum === DevinSessionStatus.Blocked
211+
) {
212+
this.trackPR(trackedPR);
213+
} else if (detail.status_enum === DevinSessionStatus.Finished) {
214+
await this.updateCheckStatus(
215+
trackedPR,
216+
"completed",
217+
"success",
218+
{
219+
title: "Devin finished",
220+
summary: `Devin session ${session.session_id} has completed.`,
221+
},
222+
session.session_id,
223+
);
224+
} else if (detail.status_enum === DevinSessionStatus.Expired) {
225+
await this.updateCheckStatus(
226+
trackedPR,
227+
"completed",
228+
"cancelled",
229+
{
230+
title: "Devin session expired",
231+
summary: `Devin session ${session.session_id} has expired.`,
232+
},
233+
session.session_id,
234+
);
235+
} else if (detail.status_enum) {
236+
await this.updateCheckStatus(
237+
trackedPR,
238+
"completed",
239+
"neutral",
240+
{
241+
title: "Devin session ended",
242+
summary: `Devin session ${session.session_id} ended with status: ${detail.status_enum}`,
243+
},
244+
session.session_id,
245+
);
246+
}
210247
} catch {
211248
this.logger.error(`Failed to fetch PR details for ${prUrl}`);
212249
}

apps/bot/src/features/bot-ci.ts

Lines changed: 0 additions & 133 deletions
This file was deleted.

apps/bot/src/features/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from "./bot-ci.js";
21
export * from "./devin-status.js";
32
export * from "./fix-merge-conflict.js";
43
export * from "./pr-closed.js";

apps/bot/src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { ApplicationFunctionOptions, Probot } from "probot";
22

33
import { startDevinStatusPoller } from "./devin/index.js";
44
import {
5-
registerBotCiHandler,
65
registerDevinStatusHandler,
76
registerFixMergeConflictHandler,
87
registerPrClosedHandler,
@@ -17,13 +16,10 @@ export default (app: Probot, { getRouter }: ApplicationFunctionOptions) => {
1716
});
1817
}
1918

20-
// Start the poller before registering handlers to avoid race conditions
21-
// where handlers might call getDevinStatusPoller() before it's initialized
2219
if (process.env.NODE_ENV !== "test") {
2320
startDevinStatusPoller(app);
2421
}
2522

26-
registerBotCiHandler(app);
2723
registerDevinStatusHandler(app);
2824
registerFixMergeConflictHandler(app);
2925
registerPrClosedHandler(app);

apps/bot/test/fixtures/check_run.completed.failure.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

apps/bot/test/fixtures/check_run.completed.success.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

apps/bot/test/fixtures/check_run.created.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)