MCPcopy Index your code
hub / github.com/codeaashu/claude-code / onUserMessage

Function onUserMessage

src/bridge/initReplBridge.ts:349–378  ·  view source on GitHub ↗
(text: string, bridgeSessionId: string)

Source from the content-addressed store, hash-verified

347 )
348 }
349 const onUserMessage = (text: string, bridgeSessionId: string): boolean => {
350 if (hasExplicitTitle || getCurrentSessionTitle(getSessionId())) {
351 return true
352 }
353 // v1 env-lost re-creates the session with a new ID. Reset the count so
354 // the new session gets its own count-3 derivation; hasTitle stays true
355 // (new session was created via getCurrentTitle(), which reads the count-1
356 // title from this closure), so count-1 of the fresh cycle correctly skips.
357 if (
358 lastBridgeSessionId !== undefined &&
359 lastBridgeSessionId !== bridgeSessionId
360 ) {
361 userMessageCount = 0
362 }
363 lastBridgeSessionId = bridgeSessionId
364 userMessageCount++
365 if (userMessageCount === 1 && !hasTitle) {
366 const placeholder = deriveTitle(text)
367 if (placeholder) patch(placeholder, bridgeSessionId, userMessageCount)
368 generateAndPatch(text, bridgeSessionId)
369 } else if (userMessageCount === 3) {
370 const msgs = getMessages?.()
371 const input = msgs
372 ? extractConversationText(getMessagesAfterCompactBoundary(msgs))
373 : text
374 generateAndPatch(input, bridgeSessionId)
375 }
376 // Also re-latches if v1 env-lost resets the transport's done flag past 3.
377 return userMessageCount >= 3
378 }
379
380 const initialHistoryCap = getFeatureValue_CACHED_WITH_REFRESH(
381 'tengu_bridge_initial_history_cap',

Callers 2

writeMessagesFunction · 0.85
writeMessagesFunction · 0.85

Calls 7

getCurrentSessionTitleFunction · 0.85
getSessionIdFunction · 0.85
deriveTitleFunction · 0.85
patchFunction · 0.85
generateAndPatchFunction · 0.85
extractConversationTextFunction · 0.85

Tested by

no test coverage detected