Repository navigation
fix(crisp): re-arm stale check on customer messages only; dedupe skips threads with no recent customer message - #121
Merged
lihsaa591 merged 3 commits intoOct 14, 2026
Conversation
…s threads with no recent customer message
lihsaa591
deleted the
fix/crisp-customer-only-rearm-and-dedupe-freshness
branch
October 14, 2026 11:20
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.
Why
Two support-reported symptoms, each diagnosed from live Crisp metadata (message types, roles and timestamps only; no content).
session_3931e910was re-investigated 7 times in 3 weeks. Three of those (Sep 28, Oct 9, Oct 13) were triggered by a support agent's reply, not the customer. Both that finished returnedno_defectand still posted another note. The stale path treated any text message as new activity.session_f9e20b9bwas matched toeverest-forms-pro#1245two months after support resolved it (Aug 14). Thestate:resolvedevent is real, but Crisp had the thread asunresolvedagain, with no new message or event, from at least the Sep 2 seed (commit3be1fa7). The bot never touched it before Oct 13, so it did not reopen it.crisp-dedupe-active.mjshad no freshness gate and matched it anyway.Also found:
active.lastis absent (not frozen) on email-origin conversations, soactive.last ?? created_atmeasured age-since-creation. That is why every "stale NNNh" log line counted back to the creation date.Changes
crisp-classify.mjs: the stale path re-arms only on a new customer message (shouldReclassifyStale).checkedThroughAtnever moves backwards (nextCheckedThroughAt).crisp-classify.mjs: the pre-fetch gate takes the newest ofactive.last/updated_at/created_atas a hint only. Staleness is recomputed from real message timestamps once messages are fetched.crisp-dedupe-active.mjs: skips conversations whose newest customer message is older than 14 days (DEDUPE_MAX_QUIET_DAYS). Skipped threads are not marked notified, so a new customer message re-evaluates them. The step summary gains a "Skipped" count.scripts/crisp-activity.mjs/crisp-activity.test.mjs.debug-crisp-triage-not-investigatedskill updated (it saidactive.lastwas "frozen", which was wrong).Not changed
seed-escalated.mjs. It stamps from all message types, which only makes a thread re-arm later.Behavior change to be aware of
The 30-day
AUTO_ESCALATE_MAX_HOURScap is now measured from the last real message, not from creation. A long-lived thread that is still active can therefore become eligible, where before it was excluded by age. I expect this to be rare: conversations active at onboarding were seeded, and ones created later were already processed while under 30 days old.Testing
node --test scripts/*.test.mjs: 73 pass, including 13 new tests. Cases include the real shapes of both sessions (roles and timestamps only).npm testfails withMODULE_NOT_FOUNDon a clean master too (Node 22 and the directory arguments), so it was already broken locally and is unrelated to this change.main()paths against live Crisp, since they aren't unit-testable as written.stale ...hlog lines and the dedupe step summary's "Skipped" count.