Skip to content

[2FA Code Finder] Fix iMessage codes not showing on recent macOS - #32981

Open
maxpetretta wants to merge 2 commits into
raycast:mainfrom
maxpetretta:fix/imessage-2fa-tahoe-blank
Open

maxpetretta wants to merge 2 commits into
raycast:mainfrom
maxpetretta:fix/imessage-2fa-tahoe-blank

Conversation

@maxpetretta

@maxpetretta maxpetretta commented Oct 31, 2026 •

Copy link
Copy Markdown

Note

This PR was written by Claude Opus 5.5 (Anthropic's model, running in Claude Code) on behalf of @maxpetretta, who asked for the fix and confirmed it works on their Mac.

Description

Since the 2026-05-27 update (#28183, "Fix Time Sensitive iMessage codes"), the iMessage source finds no codes when message.text is NULL and the body only exists in attributedBody. On macOS 26 that is most incoming messages: 388 of the 400 most recent on the test machine.

The query read the body with cast(message.attributedBody as text). SQLite cuts that cast off at the first NUL byte, and in the typedstream blob that byte comes just before the message body. Every such message reached the extension as streamtyped…NSMutableAttributedString, extractCode found nothing, and the list showed the empty view.

Changes:

  • Fetch attributedBody with hex() and decode the NSString payload from the typedstream in decodeAttributedBody (src/utils.ts). Handles 1, 2 and 4 byte lengths.
  • combineMessageText keeps the Fix iMessage Time Sensitive code detection #28183 behaviour: a notification label such as "Time Sensitive" in message.text is still combined with the decoded body.
  • The code-candidate check and search now run on the decoded text in useMessages, since SQL can no longer see the body. The candidate check is the same as the old globs, which all reduce to three consecutive digits or capitals.
  • The query scans up to the 1000 most recent messages in the look back window, and the 100 result limit is applied after filtering, so newer unrelated messages can't hide a code. One poll at the full 1000 rows takes about 13 ms.
  • New tests build real typedstream blobs and go through the hex path. The existing binary-data tests use hand-written strings that never pass through SQLite, which is how this regression got past them.

Fixes #29673. Probably also the cause of #28593. Related: #21910.

Testing

  • macOS 26.7.1, Raycast 2.10.1: the store version showed an empty list. With this branch running through npm run dev, a newly received code appeared.
  • Against the same machine's chat.db: the old query path found a code in 0 of the last 400 incoming messages, and the decoded text found one in 31. All 24,889 attributedBody blobs from the past year have the NSString layout the decoder expects.
  • npm test (47 passed), npm run lint (0 errors, existing warnings only), npm run build.

Screencast

No UI changes. The list shows codes again.

Checklist

🤖 Generated with Claude Code

On recent macOS versions message.text is usually NULL and the body only
exists in attributedBody. The query cast that blob to text, which SQLite
truncates at the first NUL byte, right before the message body, so the
extension only ever saw "NSMutableAttributedString" and found no codes.

Fetch attributedBody as hex, decode the NSString payload from the
typedstream, and apply the code and search filters to the decoded text.
Notification labels stored in message.text are still combined with the
body.

Refs raycast#29673, raycast#21910

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: imessage-2fa Issues related to the imessage-2fa extension platform: macOS labels Oct 31, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

Thank you for your first contribution! 🎉

🔔 @yuercl @thomaspaulmann @arronhunt @hitolaus @taschaub @omaerkhan @clins1994 you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="fix/imessage-2fa-tahoe-blank"
FORK_URL="https://github.com/maxpetretta/extensions.git"
EXTENSION_NAME="imessage-2fa"
REPO_NAME="extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 15 business days.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects iMessage code discovery in the 2FA Code Finder.

The earlier missing-code issue remains partly unfixed and should be addressed before merging.

Summary

Restores iMessage code detection when macOS stores message text only in attributedBody.

  • The code finder reads message bodies stored in attributedBody.
  • The extension notes the fix and credits its contributor.

Reviews (2) · Last reviewed commit: "fix(imessage-2fa): limit results after f..." · Reviewed by Greptile

Comment thread extensions/imessage-2fa/src/messages.ts Resolved
The SQL query limited rows to 100 before the code and search filters,
which now run on the decoded body, so newer unrelated messages could
push an older code in the look back window out of the results. Scan up
to 1000 messages in the window and apply the 100 result limit after
filtering. Also add petretta to contributors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension fix / improvement Label for PRs with extension's fix improvements extension: imessage-2fa Issues related to the imessage-2fa extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2FA Code Finder]

2 participants