Skip to content

Commit f2f73d1

Browse files
authored
fix: skip keyword injection on first message for correct session titles (#125)
1 parent 049134b commit f2f73d1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/hooks/keyword-detector/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export * from "./detector"
66
export * from "./constants"
77
export * from "./types"
88

9+
const sessionFirstMessageProcessed = new Set<string>()
10+
911
export function createKeywordDetectorHook() {
1012
return {
1113
"chat.message": async (
@@ -20,6 +22,14 @@ export function createKeywordDetectorHook() {
2022
parts: Array<{ type: string; text?: string; [key: string]: unknown }>
2123
}
2224
): Promise<void> => {
25+
const isFirstMessage = !sessionFirstMessageProcessed.has(input.sessionID)
26+
sessionFirstMessageProcessed.add(input.sessionID)
27+
28+
if (isFirstMessage) {
29+
log("Skipping keyword detection on first message for title generation", { sessionID: input.sessionID })
30+
return
31+
}
32+
2333
const promptText = extractPromptText(output.parts)
2434
const messages = detectKeywords(promptText)
2535

0 commit comments

Comments
 (0)