fix(rules): categorize threads in historical/bulk runs#2774
Open
casar68 wants to merge 2 commits into
elie222:mainelie222/inbox-zero:mainfrom
casar68:fix/historical-thread-categorizationcasar68/inbox-zero:fix/historical-thread-categorizationCopy head branch name to clipboard
Open
fix(rules): categorize threads in historical/bulk runs#2774casar68 wants to merge 2 commits intoelie222:mainelie222/inbox-zero:mainfrom casar68:fix/historical-thread-categorizationcasar68/inbox-zero:fix/historical-thread-categorizationCopy head branch name to clipboard
casar68 wants to merge 2 commits into
elie222:mainelie222/inbox-zero:mainfrom
casar68:fix/historical-thread-categorizationcasar68/inbox-zero:fix/historical-thread-categorizationCopy head branch name to clipboard
Conversation
|
@casar68 is attempting to deploy a commit to the Inbox Zero OSS Program Team on Vercel. A member of the Team first needs to authorize it. |
casar68
force-pushed
the
fix/historical-thread-categorization
branch
from
June 2, 2026 07:34
87a6171 to
6a055ad
Compare
When bulk-processing past emails, threads were left uncategorized when their first message was outside the date range (or not processed). The bulk UIs dedupe to one representative message per thread (the most recent), which for a multi-message thread is a mid-thread message. The matcher's thread-continuity guard then skipped every runOnThreads=false categorization rule (the thread had no prior category), leaving the model only the conversation meta-rule -> no match -> the whole thread uncategorized. ~8% of bulk-processed emails (system notifications: deliveries, order updates, receipts) ended up with no label. Add an isHistorical flag threaded runRulesAction -> runRules -> findMatchingRules -> findPotentialMatchingRules. When set, the thread-continuity skip is bypassed so categorization runs on the representative message. The flag is set by both bulk entry points: runAiRules (BulkRunRules) and ProcessRules. Real-time is unchanged (flag defaults false): first message still categorizes, later messages still continue the existing category, no extra real-time AI calls. Safe under the bulk path's one-message-per-thread dedup (no concurrent same-thread categorization -> no competing labels). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
casar68
force-pushed
the
fix/historical-thread-categorization
branch
from
June 2, 2026 07:35
6a055ad to
ab151eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When bulk-processing past emails (the "Process rules" / assistant history UI), threads were left entirely uncategorized when their first message was outside the selected date range (or just not processed).
Root cause: the UI dedupes to one representative message per thread — the most recent (
ProcessRules.tsx). For a multi-message thread that representative is a mid-thread message (message.id !== message.threadId→isReplyInThreadtrue). The matcher's thread-continuity guard infindPotentialMatchingRulesthen skips everyrunOnThreads=falsecategorization rule (Notification, Receipt, Marketing, …) because the thread has no prior category, leaving the model only the conversation meta-rule → no match → the whole thread gets no label.Measured impact on a real bulk run: ~8% of processed emails (system notifications — deliveries, order updates, receipts) ended up with no category, all confirmed as threads with zero applied rule.
Fix
Add an
isHistoricalflag, set by the bulk UI, threadedrunRulesAction → runRules → findMatchingRules → findPotentialMatchingRules.When set, the thread-continuity skip is bypassed so categorization runs on the representative message and the thread gets categorized.
Why this is safe
isHistoricaldefaultsfalse): first message of a thread still categorizes; later messages still continue the existing category. No new real-time AI calls, no behaviour change.Test plan (TDD)
match-rules.test.ts(written first, watched fail, then green):skippedThreadRuleNames);pnpm test): 0 failures.pnpm --filter inbox-zero-ai build:cigreen (type-check across the threaded flag).🤖 Generated with Claude Code