feat: skip auto-review when active CI watcher exists
When the owner registers a CI watcher and completes the turn, the review loop no longer triggers. The watcher result will be posted via the reviewer bot, which the owner picks up and acts on, then the normal review loop resumes.
This commit is contained in:
11
src/db.ts
11
src/db.ts
@@ -1411,6 +1411,17 @@ export function deleteTask(id: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function hasActiveCiWatcherForChat(chatJid: string): boolean {
|
||||
const row = db
|
||||
.prepare(
|
||||
`SELECT 1 FROM scheduled_tasks
|
||||
WHERE chat_jid = ? AND status = 'active' AND prompt LIKE '[BACKGROUND CI WATCH]%'
|
||||
LIMIT 1`,
|
||||
)
|
||||
.get(chatJid);
|
||||
return !!row;
|
||||
}
|
||||
|
||||
export function getDueTasks(): ScheduledTask[] {
|
||||
const now = new Date().toISOString();
|
||||
return db
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
getLatestOpenPairedTaskForChat,
|
||||
getPairedTaskById,
|
||||
getPairedWorkspace,
|
||||
hasActiveCiWatcherForChat,
|
||||
updatePairedTask,
|
||||
upsertPairedProject,
|
||||
} from './db.js';
|
||||
@@ -390,6 +391,17 @@ export function completePairedExecutionContext(args: {
|
||||
}
|
||||
}
|
||||
|
||||
// Active CI watcher → skip auto-review until watcher completes.
|
||||
// The watcher result will be posted via reviewer bot, triggering
|
||||
// the owner to act on it, which then resumes the review loop.
|
||||
if (hasActiveCiWatcherForChat(task.chat_jid)) {
|
||||
logger.info(
|
||||
{ taskId, chatJid: task.chat_jid },
|
||||
'Active CI watcher found, deferring auto-review until watcher completes',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Normal turn → auto-trigger reviewer (if within round trip limit)
|
||||
if (task.round_trip_count >= PAIRED_MAX_ROUND_TRIPS) {
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user