refactor(context-injector): remove chat.message hook, insert synthetic part in transform

- Remove injectPendingContext function (no longer needed)
- Remove createContextInjectorHook function (chat.message hook removed)
- Change transform hook from prepend to synthetic part insertion
- Follow empty-message-sanitizer pattern (minimal field set)
- synthetic: true flag hides content from UI but passes to model
- Synthetic part inserted BEFORE user text part
This commit is contained in:
justsisyphus 2026-01-16 17:42:43 +09:00
parent 188bbef018
commit d3e3371a77

View File

@ -142,14 +142,21 @@ export function createContextInjectorMessagesTransformHook(
return
}
const textPart = lastUserMessage.parts[textPartIndex] as { text?: string }
const originalText = textPart.text ?? ""
textPart.text = `${pending.merged}\n\n---\n\n${originalText}`
// empty-message-sanitizer 패턴 그대로 따름 (minimal fields)
const syntheticPart = {
id: `synthetic_hook_${Date.now()}`,
messageID: lastUserMessage.info.id,
sessionID: (lastUserMessage.info as { sessionID?: string }).sessionID ?? "",
type: "text" as const,
text: pending.merged,
synthetic: true, // UI에서 숨겨짐
}
log("[context-injector] Prepended context to last user message", {
lastUserMessage.parts.splice(textPartIndex, 0, syntheticPart as Part)
log("[context-injector] Inserted synthetic part with hook content", {
sessionID,
contextLength: pending.merged.length,
originalTextLength: originalText.length,
contentLength: pending.merged.length,
})
},
}