MCPcopy Create free account
hub / github.com/tiann/hapi / handleSessionEnd

Method handleSessionEnd

hub/src/sync/sessionCache.ts:359–380  ·  view source on GitHub ↗
(payload: { sid: string; time: number })

Source from the content-addressed store, hash-verified

357 }
358
359 handleSessionEnd(payload: { sid: string; time: number }): void {
360 const t = clampAliveTime(payload.time) ?? Date.now()
361
362 const session = this.sessions.get(payload.sid) ?? this.refreshSession(payload.sid)
363 if (!session) return
364
365 if (!session.active && !session.thinking) {
366 return
367 }
368
369 session.active = false
370 session.thinking = false
371 session.thinkingAt = t
372 session.backgroundTaskCount = 0
373 this.pendingThinkingUntilBySessionId.delete(session.id)
374
375 this.publisher.emit({
376 type: 'session-updated',
377 sessionId: session.id,
378 data: { active: false, thinking: false, backgroundTaskCount: 0 } satisfies SessionPatch
379 })
380 }
381
382 expireInactive(now: number = Date.now()): string[] {
383 const sessionTimeoutMs = 30_000

Callers

nothing calls this directly

Calls 4

refreshSessionMethod · 0.95
clampAliveTimeFunction · 0.90
getMethod · 0.80
emitMethod · 0.45

Tested by

no test coverage detected