fix(imessage): strip U+FFFD garbage chars from echo text key normalization#62191
fix(imessage): strip U+FFFD garbage chars from echo text key normalization#62191maguilar631697 wants to merge 4 commits into
Conversation
Greptile SummaryThis PR fixes three genuine iMessage echo-loop bugs (wrong
Confidence Score: 3/5Not safe to merge — two P1 regressions leave the echo-loop fix non-functional and break the TypeScript build. The missing extensions/imessage/src/monitor/types.ts (missing
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d07d423d42
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b565954865
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93c8eac0d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4b5e9e06a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04b7cd501a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Re: P2 on TTL increase — acknowledged tradeoff. The 30s window does widen the false-positive path for text-only matching on short repeated messages like "ok". However, the 4s TTL causes echo loops that flood users with 2-10+ duplicate replies — a much worse failure mode. The text-only matching path only fires when there's no usable message ID (normalized to A follow-up could add a minimum text length threshold to skip text-only matching for very short strings, but keeping that separate from this fix. |
04b7cd5 to
30b0af3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30b0af3990
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
30b0af3 to
8d5bd51
Compare
8d5bd51 to
782f8fa
Compare
Rebased — review comments no longer applicableThis PR has been rebased to only include the remaining unmerged fix: U+FFFD garbage char normalization in The previous fixes for TTL (4s → 30s) and The three P1 review comments from Greptile and ChatGPT Codex all reference files (
The only change remaining is a one-line regex addition in |
…ation imsg extracts message text from the SQLite attributedBody column via NSAttributedString, which injects U+FFFD replacement characters and C0/C1 control characters around rich-text spans. The echo cache stores clean outbound text, but the reflected copy carries these garbage characters, defeating text-based deduplication. See: openclaw#61312, openclaw#61821. Fixes openclaw#61312, openclaw#61821
bce01df to
eec4bb7
Compare
|
ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical. Source PR: #62191 |
|
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Current main and the latest release still lack the requested iMessage echo-cache normalization for leading U+FFFD/control-byte corruption, so this PR is not obsolete. The PR remains a relevant implementation candidate, but the provided current diff appears to need a regex syntax repair before it can land safely. Best possible solution: Keep this PR open for maintainer follow-up. The best path is to repair the leading-only regex using syntax-safe U+FFFD/U+FFFE/U+FFFF and C0/C1 ranges, keep the interior-control preservation tests, coordinate the overlap with #63581, and then land this or an equivalent iMessage plugin fix in extensions/imessage/src/monitor/echo-cache.ts. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 955b4df0939f. |
Summary
U+FFFD replacement characters and C0/C1 control characters injected by
imsgwhen extracting text fromNSAttributedString(attributedBodycolumn) break echo cache text-key matching, causing duplicate message delivery.The echo cache stores clean outbound text, but the reflected inbound copy carries garbage character prefixes —
normalizeEchoTextKey()only strips\r\n, so the keys never match and the echo slips through as a new inbound message.Fix: Strip
[\ufffd\ufffe\uffff\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]+before comparison innormalizeEchoTextKey().Previously included fixes (now upstream)
The original PR included two additional fixes that have since been merged independently by the OpenClaw team (#61619, #63868, #63980, #63989, #64000):
TTL 4s → 30s— shipped in 2026.4.10 (SENT_MESSAGE_TEXT_TTL_MS = 30e3)— shipped in 2026.4.10 withdestination_caller_idself-chat detectionisSelfChat+isAmbiguousSelfThreadThis PR now contains only the remaining unmerged fix.
Changes
extensions/imessage/src/monitor/echo-cache.ts: Strip U+FFFD/control chars innormalizeEchoTextKeyRelated Issues
Fixes #61312, #61821
Test Plan