Conversation Monitor
Relevant source files
The following files were used as context for generating this wiki page:
The Conversation Monitor is a specialized real-time analytics system designed to track, analyze, and visualize Claude Code interactions. It provides a modular architecture for monitoring conversation states, process executions, and file system changes to offer developers a comprehensive dashboard for AI-assisted development workflows. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:5-15, api/claude-code-monitor/README.md
The system operates across a distributed architecture, utilizing a backend core for state calculation and process detection, and a frontend suite for mobile and web visualization. By leveraging WebSockets, the monitor ensures ultra-fast, live updates to conversation statuses, allowing for immediate insight into active, waiting, or idle AI sessions. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:20-40, src/analytics-web/services/WebSocketService.js:10-25
Modular Architecture
The Conversation Monitor follows a modular design pattern to separate concerns between data acquisition, analysis, and notification. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:21-25
Core Components
| Component | Responsibility |
|---|---|
| StateCalculator | Detects conversation states (active, waiting, idle, completed) via message pattern analysis. |
| ProcessDetector | Monitors cross-platform Claude Code processes (macOS, Linux, Windows). |
| ConversationAnalyzer | Parses JSONL files, extracts metadata, and performs token counting. |
| FileWatcher | Provides real-time filesystem monitoring via Chokidar with refresh throttling. |
| DataCache | Manages multi-level caching for raw files, parsed data, and expensive computations. |
Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:52-120
System Workflow
The following diagram illustrates the flow from filesystem changes to real-time notification on the user interface.
Real-time Communication Service
The monitoring system relies on a specialized WebSocketService to bridge the gap between backend state changes and frontend visualizations. This service manages persistent connections, handles automatic reconnections, and processes subscription-based messaging. Sources: src/analytics-web/services/WebSocketService.js:1-15, cli-tool/docs_to_claude/ARCHITECTURE.md:164-175
WebSocket Protocol and Channels
The system categorizes real-time data into specific channels to optimize broadcast efficiency:
- data_updates: General refreshes of the conversation dataset.
- conversation_updates: Granular state changes for specific IDs.
- system_updates: Health and performance metrics.
Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:225-235
Connection Lifecycle
Analytics Visualization
The monitor includes dedicated views for different device types, including a mobile-optimized interface for tracking chats on the go. Sources: src/analytics-web/chats_mobile.html:1-20, src/chats-mobile.js:1-10
Conversation State Monitoring
The system identifies the following states to give developers insight into the Claude Code lifecycle:
- Active: Currently executing a tool or generating a response.
- Waiting: Pending user input or approval.
- Idle: No activity detected within a specific threshold.
- Completed: The task or session has finished.
Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:55-65
Feature Summary
| Feature | Implementation | Source |
|---|---|---|
| Cross-Platform | Process detection for Windows, macOS, Linux | ARCHITECTURE.md:73 |
| Mobile Optimized | chats_mobile.html using Tailwind CSS | chats_mobile.html |
| Caching | TTL-based expiration and dependency tracking | ARCHITECTURE.md:120 |
| Security | Input sanitization and environment variable configuration | ARCHITECTURE.md:330 |
Performance and Reliability
To ensure the monitor remains responsive during heavy development sessions, it implements several optimization strategies:
- Multi-Level Caching: Prevents redundant parsing of large JSONL conversation logs by caching parsed data and computation results. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:107-115
- Throttled Watching: The
FileWatcheruses intelligent throttling to prevent UI "flicker" during rapid file modifications. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:96 - Automatic Reconnection: The frontend service monitors the WebSocket state and implements an exponential backoff strategy for reconnections. Sources: src/analytics-web/services/WebSocketService.js:80-95
Health Metrics
The PerformanceMonitor component tracks memory usage, cache hit/miss ratios, and WebSocket message throughput to alert administrators of potential system strain. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:155-165
Conclusion
The Conversation Monitor provides a robust framework for supervising AI development activities. Through its modular backend components like the StateCalculator and its real-time frontend services, it transforms raw log data into actionable insights, ensuring that developers can maintain full visibility over their automated workflows. Sources: cli-tool/docs_to_claude/ARCHITECTURE.md:365-375, api/claude-code-monitor/README.md