Skip to content

Commit 567a596

Browse files
committed
Only count AI Coding when streaming multiple inserts
1 parent f83674c commit 567a596

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/wakatime.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class WakaTime {
3939
private AIDebounceTimeoutId: any = null;
4040
private AIdebounceMs = 1000;
4141
private AIdebounceCount = 0;
42-
private AIpasteLastTime: number = 0;
42+
private AIrecentPastes: number[] = [];
4343
private dependencies: Dependencies;
4444
private options: Options;
4545
private logger: Logger;
@@ -483,7 +483,7 @@ export class WakaTime {
483483
this.isAICodeGenerating = true;
484484
this.AIdebounceCount = 0;
485485
}
486-
this.AIpasteLastTime = now;
486+
this.AIrecentPastes.push(now);
487487
} else if (
488488
this.isAICodeGenerating &&
489489
e.contentChanges.length === 1 &&
@@ -497,7 +497,7 @@ export class WakaTime {
497497
this.AIDebounceTimeoutId = setTimeout(() => {
498498
if (this.AIdebounceCount > 1) {
499499
this.isAICodeGenerating = false;
500-
this.AIpasteLastTime = 0;
500+
this.AIrecentPastes = [];
501501
}
502502
}, this.AIdebounceMs);
503503
} else if (this.isAICodeGenerating) {
@@ -969,7 +969,8 @@ export class WakaTime {
969969
}
970970

971971
private recentlyAIPasted(time: number): boolean {
972-
return this.AIpasteLastTime + 100 >= time;
972+
this.AIrecentPastes = this.AIrecentPastes.filter((x) => x + 500 >= time);
973+
return this.AIrecentPastes.length > 3;
973974
}
974975

975976
private isDuplicateHeartbeat(file: string, time: number, selection: vscode.Position): boolean {

0 commit comments

Comments
 (0)