feat(watch): --new-only for --await-review — re-armable architect review-notifier without backlog spin

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
chahinebrini 2026-07-01 01:53:11 +02:00
parent caf60ea939
commit 1e29a7b9b9
2 changed files with 7 additions and 2 deletions

View File

@ -148,7 +148,7 @@ async function fetchReviewTasks(serverUrl: string): Promise<AgentHubEvent[]> {
*/
export async function watchEvents(
serverUrl: string,
options: { once?: boolean; role?: string; awaitReview?: boolean } = {},
options: { once?: boolean; role?: string; awaitReview?: boolean; newOnly?: boolean } = {},
): Promise<void> {
const url = new URL('/events', serverUrl);
// Pass role to the server for an additional server-side filter (saves
@ -181,7 +181,10 @@ export async function watchEvents(
// --await-review: surface a submission that's ALREADY pending on connect,
// so the architect isn't blind to reviews submitted before this watcher.
if (options.awaitReview) {
// --new-only suppresses this backlog check so the notifier can be re-armed
// without instantly exiting on a still-non-empty review queue (no spin) —
// it then fires only on the NEXT genuine task→review transition.
if (options.awaitReview && !options.newOnly) {
const pending = await fetchReviewTasks(serverUrl);
if (pending.length > 0) {
for (const ev of pending) console.log(formatEvent(ev));

View File

@ -620,6 +620,7 @@ export function createProgram(cwd: string): Command {
.option('--once', 'Exit 0 after the first event (useful as a blocking wait for agents)')
.option('--role <role>', 'Client-side role filter (only show events for this role)')
.option('--await-review', 'Exit when an implementer submits (task → review); architect review-queue notifier')
.option('--new-only', 'With --await-review: fire only on NEW submissions, ignore tasks already in review on connect (re-armable without spinning)')
.action(async (options) => {
const { serverUrl } = await resolveContext(program, cwd);
if (!serverUrl) {
@ -631,6 +632,7 @@ export function createProgram(cwd: string): Command {
once: options.once as boolean | undefined,
role: options.role as string | undefined,
awaitReview: options.awaitReview as boolean | undefined,
newOnly: options.newOnly as boolean | undefined,
});
});