* Called when user interacts with the CLI (typing, commands, etc.)
()
| 58 | * Called when user interacts with the CLI (typing, commands, etc.) |
| 59 | */ |
| 60 | recordUserActivity(): void { |
| 61 | // Don't record user time if CLI is active (CLI takes precedence) |
| 62 | if (!this.isCLIActive && this.lastUserActivityTime !== 0) { |
| 63 | const now = this.getNow() |
| 64 | const timeSinceLastActivity = (now - this.lastUserActivityTime) / 1000 |
| 65 | |
| 66 | if (timeSinceLastActivity > 0) { |
| 67 | const activeTimeCounter = this.getActiveTimeCounter() |
| 68 | if (activeTimeCounter) { |
| 69 | const timeoutSeconds = this.USER_ACTIVITY_TIMEOUT_MS / 1000 |
| 70 | |
| 71 | // Only record time if within the timeout window |
| 72 | if (timeSinceLastActivity < timeoutSeconds) { |
| 73 | activeTimeCounter.add(timeSinceLastActivity, { type: 'user' }) |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // Update the last user activity timestamp |
| 80 | this.lastUserActivityTime = this.getNow() |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Starts tracking CLI activity (tool execution, AI response, etc.) |