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

Method markMessageQueued

hub/src/sync/sessionCache.ts:282–307  ·  view source on GitHub ↗
(sessionId: string, time: number = Date.now())

Source from the content-addressed store, hash-verified

280 }
281
282 markMessageQueued(sessionId: string, time: number = Date.now()): void {
283 const session = this.sessions.get(sessionId) ?? this.refreshSession(sessionId)
284 if (!session) return
285 if (!session.active) return
286
287 const nextTime = clampAliveTime(time) ?? Date.now()
288 const wasThinking = session.thinking
289 const previousUpdatedAt = session.updatedAt
290
291 session.thinking = true
292 session.thinkingAt = nextTime
293 session.updatedAt = Math.max(session.updatedAt, nextTime)
294 this.pendingThinkingUntilBySessionId.set(session.id, nextTime + QUEUED_MESSAGE_THINKING_GRACE_MS)
295
296 if (!wasThinking || session.updatedAt !== previousUpdatedAt) {
297 this.lastBroadcastAtBySessionId.set(session.id, Date.now())
298 this.publisher.emit({
299 type: 'session-updated',
300 sessionId: session.id,
301 data: {
302 thinking: true,
303 updatedAt: session.updatedAt
304 } satisfies SessionPatch
305 })
306 }
307 }
308
309 applyBackgroundTaskDelta(sessionId: string, delta: { started: number; completed: number }): void {
310 const session = this.sessions.get(sessionId)

Callers 2

sendMessageMethod · 0.80

Calls 4

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

Tested by

no test coverage detected