feat(watcher): trigger watcher after the first user message

This commit is contained in:
Aishanee Shah
2026-04-09 16:01:14 +00:00
parent 081f91db08
commit 705214ed5b
2 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -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) {
@@ -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();