MCPcopy Create free account
hub / github.com/freecodexyz/free-code / recordUserActivity

Method recordUserActivity

src/utils/activityManager.ts:60–81  ·  view source on GitHub ↗

* Called when user interacts with the CLI (typing, commands, etc.)

()

Source from the content-addressed store, hash-verified

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.)

Callers 1

REPLFunction · 0.80

Calls 1

addMethod · 0.45

Tested by

no test coverage detected