fix: ghost-watch reactivation for consistent session restart
Problem: after a session completes, removeSession() deleted the file→session mapping. When the next user message caused the JSONL to be written, fs.watch fired but fileToSession returned undefined — silently dropped. Reactivation only happened on the next session-monitor poll (up to 2s later), and by then the watcher had missed the first lines of the new turn. Fix: - removeSession() keeps the file in fileToSession as a ghost marker - fs.watch fires → ghost detected → emit 'session-reactivate' - watcher-manager clears completedSessions cooldown + calls pollNow() - session-monitor re-detects immediately with no poll lag - Ghost removed after first fire (one-shot) Also adds SessionMonitor.pollNow() for forced immediate polling.
This commit is contained in:
@@ -108,6 +108,14 @@ class SessionMonitor extends EventEmitter {
|
||||
this._completedSessions.delete(sessionKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger an immediate poll without waiting for the next interval tick.
|
||||
* Used by ghost-watch reactivation to avoid up to pollMs latency.
|
||||
*/
|
||||
pollNow() {
|
||||
this._poll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all agent directories under transcriptDir.
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user