File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ interface FileDiff {
5959
6060const processedCallIds = new Set < string > ( ) ;
6161const pendingFiles = new Map < string , { language : string ; absoluteFile ?: string } > ( ) ;
62+ let lastActiveFile : string | null = null ;
6263
6364let _token : string | null = null ;
6465let _projectName = "unknown" ;
@@ -199,6 +200,7 @@ function trackFile(filePath: string): void {
199200 language,
200201 absoluteFile : filePath ,
201202 } ) ;
203+ lastActiveFile = filePath ;
202204}
203205
204206// ---- Event guard ----
@@ -286,6 +288,7 @@ export const plugin: Plugin = async (ctx) => {
286288
287289 // Initialize state
288290 initState ( ) ;
291+ lastActiveFile = null ;
289292 _projectDir = directory ;
290293 _worktree = worktree ;
291294 _projectName = `${ path . basename ( directory ) } opencode` ;
@@ -343,7 +346,11 @@ export const plugin: Plugin = async (ctx) => {
343346
344347 "chat.message" : async ( ) => {
345348 try {
346- // On any chat activity, try to process pending heartbeats
349+ // On any chat activity, try to process pending heartbeats.
350+ // Strict mode: only extend activity if a real file was previously touched.
351+ if ( _token && pendingFiles . size === 0 && lastActiveFile ) {
352+ trackFile ( lastActiveFile ) ;
353+ }
347354 if ( _token && pendingFiles . size > 0 ) {
348355 await processHeartbeats ( ) ;
349356 }
You can’t perform that action at this time.
0 commit comments