iMessage module skips messages whose text is stored only in `attributedBody`
What happens
LIFEOS/PULSE/lib/messages-db.ts reads incoming messages from the text column and filters out rows where it is empty:
AND m.text IS NOT NULL
AND m.text != ''
Recent macOS versions often leave text empty and store the message only in attributedBody, an NSAttributedString archived in Apple's "streamtyped" format. Those messages never reach the DA. On my Mac this was 26% of all incoming messages (22,538 of 86,964, measured 2026-09-02), including every message sent to my own number.
This is separate from #1835, which fixed sending, attachments and self-chat echoes but still reads only text.
Fix
Select attributedBody, decode it when text is empty, and drop rows that decode to nothing:
--- a/LifeOS/install/LIFEOS/PULSE/lib/messages-db.ts
+++ b/LifeOS/install/LIFEOS/PULSE/lib/messages-db.ts
@@ -30,6 +30,50 @@
/**
+ * Decode the plain string out of a message's `attributedBody` blob.
+ *
+ * Layout relied on: the class marker `NSString`, a short type preamble, then
+ * a length-prefixed UTF-8 run introduced by '+'. A length byte under 0x81 is
+ * the length itself; 0x81 means a uint16 LE follows, 0x82 a uint32 LE. The
+ * first NSString in the blob is the message body.
+ *
+ * Returns "" for anything it cannot parse: an unreadable blob must degrade
+ * to "no message", never to a crash in the polling loop.
+ */
+export function decodeAttributedBody(blob: unknown): string {
+ if (!blob) return ""
+ let buf: Buffer
+ if (Buffer.isBuffer(blob)) buf = blob
+ else if (blob instanceof Uint8Array) buf = Buffer.from(blob)
+ else return ""
+
+ const marker = buf.indexOf("NSString", 0, "latin1")
+ if (marker === -1) return ""
+
+ // The preamble length varies slightly, so scan a small window for '+'.
+ const windowEnd = Math.min(marker + 20, buf.length)
+ for (let i = marker + 8; i < windowEnd; i++) {
+ if (buf[i] !== 0x2b) continue
+
+ let len: number
+ let start: number
+ const lenByte = buf[i + 1]
+ if (lenByte === undefined) return ""
+ if (lenByte === 0x81) {
+ if (i + 4 > buf.length) return ""
+ len = buf.readUInt16LE(i + 2)
+ start = i + 4
+ } else if (lenByte === 0x82) {
+ if (i + 6 > buf.length) return ""
+ len = buf.readUInt32LE(i + 2)
+ start = i + 6
+ } else {
+ len = lenByte
+ start = i + 2
+ }
+
+ if (len <= 0 || start + len > buf.length) return ""
+ return buf.subarray(start, start + len).toString("utf8")
+ }
+ return ""
+}
+
+/**
* Get new incoming messages since a given ROWID.
@@ -44,4 +88,5 @@
m.text,
+ m.attributedBody,
m.date,
@@ -55,4 +100,6 @@
AND m.is_from_me = 0
- AND m.text IS NOT NULL
- AND m.text != ''
+ AND (
+ (m.text IS NOT NULL AND m.text != '')
+ OR m.attributedBody IS NOT NULL
+ )
ORDER BY m.ROWID ASC
@@ -60,5 +107,6 @@
rowid: number
- text: string
+ text: string | null
+ attributedBody: Uint8Array | null
date: number
@@ -70,11 +118,15 @@
- return rows.map((row) => ({
- rowid: row.rowid,
- text: row.text,
- handle: row.handle,
- service: row.service,
- chatId: row.chat_id,
- // Convert Apple nanosecond timestamp to JS Date
- date: new Date((row.date / 1e9 + APPLE_EPOCH_OFFSET) * 1000),
- }))
+ return rows
+ .map((row) => ({
+ rowid: row.rowid,
+ // `text` wins when present; the blob is the fallback, not the default.
+ text: row.text && row.text !== "" ? row.text : decodeAttributedBody(row.attributedBody),
+ handle: row.handle,
+ service: row.service,
+ chatId: row.chat_id,
+ // Convert Apple nanosecond timestamp to JS Date
+ date: new Date((row.date / 1e9 + APPLE_EPOCH_OFFSET) * 1000),
+ }))
+ // A blob that could not be parsed yields "": drop it rather than answer noise.
+ .filter((msg) => msg.text.trim() !== "")
⚠️ Read before applying: this can start a self-reply loop
If the allowlisted handle is the user's own number (the self-chat setup), the bot's replies come back as is_from_me = 0 rows. In 7.40.4 those echoes are invisible only because their text is in attributedBody. Once they're decoded, the bot answers its own replies. This happened on my install on 2026-09-02: five self-replies in forty seconds before I stopped Pulse.
So this fix should land together with echo suppression for the self-chat case. #1835's zero-width-space prefix is one way to do it. I used a persistent buffer of recently sent text (chunk by chunk, because long replies are split and each chunk echoes separately) plus a per-handle rate cap as a backstop. I can share that part if useful.
Verified
This has run on my install since 2026-09-02, and messages with an empty text column now reach the DA. The decoder's tests replay real rows from my chat.db, so I haven't included them here.
Thanks @bak3r. The Pulse iMessage module was retired on 2026-09-21 and texting the DA now goes through Relay, so messages-db.ts is gone. The chat.db reader that remains (LIFEOS/TOOLS/Messages/ChatDb.ts) already selects attributedBody and decodes it when text is empty. The next release removes the old module from the public tree.