From 705214ed5bfad9d41b5d349cebb22f03612261aa Mon Sep 17 00:00:00 2001 From: Aishanee Shah Date: Thu, 9 Apr 2026 16:01:14 +0000 Subject: [PATCH] feat(watcher): trigger watcher after the first user message --- packages/core/src/core/client.ts | 5 +++-- packages/core/src/core/client_watcher.test.ts | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/core/src/core/client.ts b/packages/core/src/core/client.ts index f02e0c9d7e..031ff3857b 100644 --- a/packages/core/src/core/client.ts +++ b/packages/core/src/core/client.ts @@ -604,10 +604,11 @@ export class GeminiClient { this.sessionTurnCount++; + const watcherInterval = this.config.getExperimentalWatcherInterval(); if ( this.config.isExperimentalWatcherEnabled() && - this.sessionTurnCount > 0 && - this.sessionTurnCount % this.config.getExperimentalWatcherInterval() === 0 + (this.sessionTurnCount === 1 || + this.sessionTurnCount % watcherInterval === 0) ) { const watcherResult = await this.tryRunWatcher(prompt_id, signal); if (watcherResult?.feedback) { diff --git a/packages/core/src/core/client_watcher.test.ts b/packages/core/src/core/client_watcher.test.ts index 50fe7d0c3f..f9a3a2b4c2 100644 --- a/packages/core/src/core/client_watcher.test.ts +++ b/packages/core/src/core/client_watcher.test.ts @@ -137,7 +137,7 @@ describe('GeminiClient Watcher Integration', () => { 'gemini-pro', ); - clientAccess.sessionTurnCount = 1; // Will become 2 inside processTurn + clientAccess.sessionTurnCount = 0; // Will become 1 inside processTurn const promptId = 'test-prompt'; const signal = new AbortController().signal; @@ -214,7 +214,7 @@ describe('GeminiClient Watcher Integration', () => { 'gemini-pro', ); - clientAccess.sessionTurnCount = 1; // Will become 2 inside processTurn + clientAccess.sessionTurnCount = 0; // Will become 1 inside processTurn const promptId = 'test-prompt'; const signal = new AbortController().signal; @@ -347,8 +347,8 @@ describe('GeminiClient Watcher Integration', () => { } } - // With interval 5, it should trigger at turn 5 and turn 10 - expect(mockWatcherTool.build).toHaveBeenCalledTimes(2); + // With interval 5, it should trigger at turn 1, turn 5 and turn 10 + expect(mockWatcherTool.build).toHaveBeenCalledTimes(3); // Verify the status file exists const projectTempDir = config.storage.getProjectTempDir();