MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / startSessionActivity

Function startSessionActivity

source code/utils/sessionActivity.ts:94–117  ·  view source on GitHub ↗
(reason: SessionActivityReason)

Source from the content-addressed store, hash-verified

92 * is registered, start a periodic heartbeat timer.
93 */
94export function startSessionActivity(reason: SessionActivityReason): void {
95 refcount++
96 activeReasons.set(reason, (activeReasons.get(reason) ?? 0) + 1)
97 if (refcount === 1) {
98 oldestActivityStartedAt = Date.now()
99 if (activityCallback !== null && heartbeatTimer === null) {
100 startHeartbeatTimer()
101 }
102 }
103 if (!cleanupRegistered) {
104 cleanupRegistered = true
105 registerCleanup(async () => {
106 logForDiagnosticsNoPII('info', 'session_activity_at_shutdown', {
107 refcount,
108 active: Object.fromEntries(activeReasons),
109 // Only meaningful while work is in-flight; stale otherwise.
110 oldest_activity_ms:
111 refcount > 0 && oldestActivityStartedAt !== null
112 ? Date.now() - oldestActivityStartedAt
113 : null,
114 })
115 })
116 }
117}
118
119/**
120 * Decrement the activity refcount. When it reaches 0, stop the heartbeat timer

Callers 2

queryModelFunction · 0.85

Calls 5

startHeartbeatTimerFunction · 0.85
registerCleanupFunction · 0.85
logForDiagnosticsNoPIIFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected