fix: respawn controller multi-layer detection and cleanup

- Update idle detection from legacy '↵ send' to completion message pattern
  ("for Xm Xs" time patterns like "Worked for 2m 46s")
- Add confirming_idle state for false positive prevention
- Add completionConfirmMs (5s) and noOutputTimeoutMs (30s) config options
- Add multi-layer detection with confidence scoring (0-100%)
- Fix null pointer error in extractTokenCount with guard clause
- Fix respawn controller not stopping on session cleanup (broadcast respawn:stopped)
- Update tests to use new completion message patterns
- Add detection status UI display (confidence level, waiting state)
- Update CLAUDE.md with new detection documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-22 19:24:36 +01:00
co-authored by Claude Opus 4.5
parent 34fb33fbc6
commit ec92e5b1cf
8 changed files with 678 additions and 261 deletions
+6
View File
@@ -1271,6 +1271,8 @@ export class WebServer extends EventEmitter {
controller.stop();
controller.removeAllListeners();
this.respawnControllers.delete(sessionId);
// Notify UI that respawn is stopped for this session
this.broadcast('respawn:stopped', { sessionId, reason: 'session_cleanup' });
}
// Clear respawn timer
@@ -1445,6 +1447,10 @@ export class WebServer extends EventEmitter {
this.broadcast('respawn:stepCompleted', { sessionId, step });
});
controller.on('detectionUpdate', (detection: unknown) => {
this.broadcast('respawn:detectionUpdate', { sessionId, detection });
});
controller.on('log', (message: string) => {
this.broadcast('respawn:log', { sessionId, message });
});