MCPcopy
hub / github.com/codeaashu/claude-code / startSessionActivity

Function startSessionActivity

src/utils/sessionActivity.ts:92–115  ·  view source on GitHub ↗
(reason: SessionActivityReason)

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected