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

Function ensureSystemReminderWrap

src/utils/messages.ts:1797–1817  ·  view source on GitHub ↗

* Ensure all text content in attachment-origin messages carries the * wrapper. This makes the prefix a reliable discriminator * for the post-pass smoosh (smooshSystemReminderSiblings) — no need for every * normalizeAttachmentForAPI case to remember to wrap. * * Idempotent: alr

(msg: UserMessage)

Source from the content-addressed store, hash-verified

1795 * Idempotent: already-wrapped text is unchanged.
1796 */
1797function ensureSystemReminderWrap(msg: UserMessage): UserMessage {
1798 const content = msg.message.content
1799 if (typeof content === 'string') {
1800 if (content.startsWith('<system-reminder>')) return msg
1801 return {
1802 ...msg,
1803 message: { ...msg.message, content: wrapInSystemReminder(content) },
1804 }
1805 }
1806 let changed = false
1807 const newContent = content.map(b => {
1808 if (b.type === 'text' && !b.text.startsWith('<system-reminder>')) {
1809 changed = true
1810 return { ...b, text: wrapInSystemReminder(b.text) }
1811 }
1812 return b
1813 })
1814 return changed
1815 ? { ...msg, message: { ...msg.message, content: newContent } }
1816 : msg
1817}
1818
1819/**
1820 * Final pass: smoosh any `<system-reminder>`-prefixed text siblings into the

Callers

nothing calls this directly

Calls 1

wrapInSystemReminderFunction · 0.85

Tested by

no test coverage detected