fix(evocrm): runtime patches bugs 20-27 for evo-ai-crm-community rc5#116
Open
dvlexp wants to merge 1 commit into
Open
fix(evocrm): runtime patches bugs 20-27 for evo-ai-crm-community rc5#116dvlexp wants to merge 1 commit into
dvlexp wants to merge 1 commit into
Conversation
…crm-community rc5 Adds scripts/evocrm-patches/ with runtime patches for known issues in evo-ai-crm-community:1.0.0-rc5, applied via rxp_patches.rb loaded through Rails.application.config.to_prepare. Bug 26 (critical): Aurora MESSAGES_UPDATE status never progressed past sent Root cause: Whatsapp::EvolutionHandlers::Helpers#raw_message_id preferred :messageId (Evolution API v2 internal Prisma ID) over :keyId (wamid = source_id in CRM). For Cloud API (WABA) inboxes, :messageId never matches any CRM message -- find_message_by_source_id returns nil and the status update is silently discarded. Fix: invert priority to :keyId || :messageId || dig(:key, :id) Bug 27 (frontend): Active filter lost when paginating conversations Root cause: loadMoreConversations calls GET /conversations?page=N without active filters even when initial load used POST /conversations/filter. Fix: JS patch stores filter body in window._rxpFilterBody; getConversations when page>1 redirects to POST /conversations/filter preserving filters. Also includes patches for bugs 20-25 (ContactCompany validator, pipeline items N+1, LID/JID source_id collision, assignee_type filter, query_operator fix, right-click context menu, days_in_current_stage sort). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewer's GuideAdds a runtime monkey‑patch framework for Evo CRM (Rails + frontend) and implements fixes for bugs 1–27, with focus on Evolution/EvoGo WhatsApp integration, Aurora bot behavior, pipeline/conversation performance, and frontend filtering/pagination/right‑click behavior for evo-ai-crm-community rc5. Sequence diagram for Evolution MESSAGES_UPDATE handling with raw_message_id keyId priority (bug 26)sequenceDiagram
participant EvolutionAPI as EvolutionAPI_v2
participant IncomingService as IncomingMessageEvolutionService
participant Helpers as Whatsapp_EvolutionHandlers_Helpers
participant Message as MessageModel
EvolutionAPI->>IncomingService: perform (messages.update payload)
IncomingService->>IncomingService: process_messages_update
IncomingService->>Helpers: raw_message_id
Helpers-->>IncomingService: keyId || messageId || key.id
IncomingService->>Message: find_message_by_source_id(raw_message_id)
Message-->>IncomingService: existing_message
IncomingService->>Message: update(status: delivered)
Message-->>IncomingService: status_updated
IncomingService-->>EvolutionAPI: ack
Sequence diagram for filtered conversations pagination preserving filters (bug 27)sequenceDiagram
actor User
participant Browser as Browser_JS
participant API as Api_V1_ConversationsController
User->>Browser: apply filter (page 1)
Browser->>Browser: filterConversations
Browser->>Browser: window._rxpFilterBody = filter_body
Browser->>API: POST /conversations/filter page=1 body=_rxpFilterBody
API-->>Browser: filtered conversations page 1
User->>Browser: scroll (loadMoreConversations page>1)
Browser->>Browser: getConversations(page>1)
Browser->>API: POST /conversations/filter page=N body=_rxpFilterBody
API-->>Browser: filtered conversations page N
User->>Browser: new search (page=1)
Browser->>Browser: getConversations(page=1)
Browser->>Browser: window._rxpFilterBody = null
Browser->>API: GET /conversations page=1
API-->>Browser: unfiltered conversations page 1
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- rxp_patches.rb has grown into a very large, multi-purpose monkey-patch file; consider splitting it into smaller, domain-focused modules (e.g., WhatsApp/Evolution, Aurora bot, pipelines, frontend shims) and requiring them from a lightweight entrypoint to make future maintenance and rollback safer.
- Several runtime patches use class_eval/module_eval with direct method redefinitions (e.g., in Whatsapp::EvolutionHandlers::Helpers, ContactsController, PipelinesController); where possible, prefer prepend/Module wrappers or smaller, more targeted overrides so upstream method signature or behavior changes are less likely to be silently overridden in unexpected ways.
- The inline JavaScript injected in index.html (right-click fix and WebSocket watchdog) hardcodes behaviors like the 5-minute WS stale threshold; consider moving this logic into a dedicated asset file and making key constants configurable so it’s easier to adjust or disable in different environments.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- rxp_patches.rb has grown into a very large, multi-purpose monkey-patch file; consider splitting it into smaller, domain-focused modules (e.g., WhatsApp/Evolution, Aurora bot, pipelines, frontend shims) and requiring them from a lightweight entrypoint to make future maintenance and rollback safer.
- Several runtime patches use class_eval/module_eval with direct method redefinitions (e.g., in Whatsapp::EvolutionHandlers::Helpers, ContactsController, PipelinesController); where possible, prefer prepend/Module wrappers or smaller, more targeted overrides so upstream method signature or behavior changes are less likely to be silently overridden in unexpected ways.
- The inline JavaScript injected in index.html (right-click fix and WebSocket watchdog) hardcodes behaviors like the 5-minute WS stale threshold; consider moving this logic into a dedicated asset file and making key constants configurable so it’s easier to adjust or disable in different environments.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
Adds
scripts/evocrm-patches/with runtime monkey-patches for known issues inevo-ai-crm-community:1.0.0-rc5. Patches are loaded at startup viaRails.application.config.to_prepareinrxp_patches.rb.Bug 26 (critical) -- Aurora MESSAGES_UPDATE never progresses past
sentRoot cause:
Whatsapp::EvolutionHandlers::Helpers#raw_message_idprefers:messageIdover:keyId. For Evolution API v2 Cloud API (WABA) inboxes, themessages.updateevent payload contains two fields:messageIdcmqs7ozt705cepl01mlhe3z42keyIdwamid.HBgM...source_idin CRMWith the original priority,
find_message_by_source_id(messageId)always returnsniland the status update is silently discarded. Affects all WABA/Cloud API inboxes using Evolution API v2.Fix: One-line change -- invert priority to
:keyId || :messageId || dig(:key, :id).Safe: for
messages.upsertevents, neither:keyIdnor:messageIdexist and the existing fallback@raw_message.dig(:key, :id)continues to work normally.Bug 27 -- Filter lost when paginating conversations
Root cause:
loadMoreConversationsalways callsGET /conversations?page=Nwithout active filters, even when the initial load usedPOST /conversations/filter. Page 2+ returns unfiltered results.Fix: JS patch stores filter body in
window._rxpFilterBody;getConversationswhenpage > 1redirects toPOST /conversations/filterpreserving the active filter.Other patches (bugs 20-25)
query_operatorregression, right-click context menu fixassignee_typefilter missing fromConversations::FilterServicesource_idafter EvoGo JID swap collisionPipelineItem#days_in_current_stageN+1 with preloaded associationsTest plan
rxp_patches.rbto CRM container and restart Sidekiq[RXP_PATCH] Bug 26 v2 -- EvolutionHandlers#raw_message_id keyId>messageId fixsent → delivered🤖 Generated with Claude Code
Summary by Sourcery
Introduce a runtime patch bundle for evo-ai-crm-community rc5 that hot-fixes multiple backend and frontend issues around WhatsApp/Evolution integration, automations, pipelines, bots, and UI behavior without modifying upstream source.
Bug Fixes:
Enhancements: