[codex] fix(imessage): normalize attributed echo prefixes#66169
[codex] fix(imessage): normalize attributed echo prefixes#66169coder999999999 wants to merge 2 commits into
Conversation
Greptile SummaryAdds Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/imessage/src/monitor/echo-cache.ts
Line: 63
Comment:
**Dead branch in ternary**
`offset += second ? 3 : 2` — the `: 2` arm is unreachable. Reaching this line requires `third &&` to be truthy, meaning `text[offset+2]` is a valid character. A valid string index always returns a non-empty single-character string (truthy), and a defined `text[offset+2]` implies `text[offset+1]` (`second`) is also defined and truthy. So `second` is always truthy here and the offset always increments by `3`.
```suggestion
offset += 3;
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(imessage): normalize attributed echo..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Fixes iMessage echo-cache text matching when reflected messages include leading attributed-text marker bytes (e.g. \x93b\x02), preventing self-chat/direct-chat echo loops from re-entering the session.
Changes:
- Add leading attributed-prefix stripping to
normalizeEchoTextKey()before newline/trim normalization. - Add unit/regression tests covering attributed-prefix echo matching in the echo cache and the self-chat inbound decision path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extensions/imessage/src/monitor/echo-cache.ts | Adds attributed-prefix/control-prefix normalization for echo text keys. |
| extensions/imessage/src/monitor/monitor-provider.echo-cache.test.ts | Adds a regression test ensuring prefixed reflected text matches cached outbound text. |
| extensions/imessage/src/monitor/self-chat-dedupe.test.ts | Adds a regression test ensuring self-chat is_from_me=true reflections with prefix bytes are dropped as agent echoes. |
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. at source level. Current main's normalizer leaves the reported U+0093 b U+0002 prefix on the echo-cache key, and the self-chat inbound drop path depends on that key matching bodyText. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Rebase the attributed-prefix normalizer onto current main, preserve current marker cleanup and persisted echo-cache behavior, keep focused tests for both prefix families, and add inspectable after-fix proof before merge. Do we have a high-confidence way to reproduce the issue? Yes, at source level. Current main's normalizer leaves the reported U+0093 b U+0002 prefix on the echo-cache key, and the self-chat inbound drop path depends on that key matching bodyText. Is this the best way to solve the issue? No, not as this branch currently stands. The echo-cache normalizer is the right narrow seam, but the PR must be rebased over current main so it adds C1 attributed-prefix support without losing marker cleanup or persisted echo lookup. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f863447fe165. |
9d69f06 to
780395a
Compare
|
ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical. Source PR: #66169 |
|
Thanks! Closing as obsolete — covered upstream by #64000 ( |
Summary
\x93b\x02, which makes echo-cache text fallback miss the agent's own outbound text.extensions/imessage/src/monitor/echo-cache.tsnow strips the leading attributed-text marker pattern before newline/trim normalization, and targeted regression tests were added for cache matching plus the self-chat inbound decision path.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
normalizeEchoTextKey()normalized newlines and trimming only, so reflected texts like"\x93b\x02Cached reply"did not match the clean outbound text stored in the echo cache.chat.dbreflections can preserve short attributed-text marker bytes on some messages, especially richer/longer text.Regression Test Plan (if applicable)
extensions/imessage/src/monitor/monitor-provider.echo-cache.test.tsextensions/imessage/src/monitor/self-chat-dedupe.test.tsUser-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
imsgaccess to Messages databaseSteps
\x93b\x02.imsgto a real iMessage target and confirm delivery on the recipient device.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm check), and live iMessage test sends viaimsgduring validation.is_from_me=truereflection path with the same prefix shape; real iMessage delivery path remained functional while validating on macOS.Review Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations