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

Function deriveTitle

src/bridge/initReplBridge.ts:555–569  ·  view source on GitHub ↗

* Quick placeholder title: strip display tags, take the first sentence, * collapse whitespace, truncate to 50 chars. Returns undefined if the result * is empty (e.g. message was only ). Replaced by * generateSessionTitle once Haiku resolves (~1-15s).

(raw: string)

Source from the content-addressed store, hash-verified

553 * generateSessionTitle once Haiku resolves (~1-15s).
554 */
555function deriveTitle(raw: string): string | undefined {
556 // Strip <ide_opened_file>, <session-start-hook>, etc. — these appear in
557 // user messages when IDE/hooks inject context. stripDisplayTagsAllowEmpty
558 // returns '' (not the original) so pure-tag messages are skipped.
559 const clean = stripDisplayTagsAllowEmpty(raw)
560 // First sentence is usually the intent; rest is often context/detail.
561 // Capture group instead of lookbehind — keeps YARR JIT happy.
562 const firstSentence = /^(.*?[.!?])\s/.exec(clean)?.[1] ?? clean
563 // Collapse newlines/tabs — titles are single-line in the claude.ai list.
564 const flat = firstSentence.replace(/\s+/g, ' ').trim()
565 if (!flat) return undefined
566 return flat.length > TITLE_MAX_LEN
567 ? flat.slice(0, TITLE_MAX_LEN - 1) + '\u2026'
568 : flat
569}
570
571

Callers 2

initReplBridgeFunction · 0.85
onUserMessageFunction · 0.85

Calls 1

Tested by

no test coverage detected