Fix passing outdated Channel data for CidEvents to the ChatEventHandler.handleChatEvent#6381
Conversation
…Handler.handleChatEvent`.
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe PR optimizes channel resolution in event handling by implementing a hybrid lookup strategy. Instead of always fetching all channels from the database upfront, the code now checks in-memory active channel state first via a new Changes
Sequence DiagramsequenceDiagram
participant Event as Chat Event
participant Logic as QueryChannelsLogic
participant StateReg as StateRegistry<br/>(In-Memory)
participant DB as Database
participant Handler as Event Handler
Event->>Logic: parseChatEventResults(events)
loop For each event's target CID
Logic->>StateReg: getActiveChannelState(cid)
alt Channel is Active
StateReg-->>Logic: Channel snapshot
else Channel Not Active
StateReg-->>Logic: null
end
end
Note over Logic: Collect CIDs missing<br/>from in-memory state
Logic->>DB: selectChannels(missingCids)
DB-->>Logic: Channel data
Note over Logic: Merge in-memory entries<br/>with DB results
Logic->>Handler: handleChatEvent(event, resolvedChannel)
Handler-->>Logic: EventHandlingResult
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🚀 Available in v6.37.3 |


Goal
Currently we always read the
Channeldata from the DB before passing it to theChatEventHandler.handleChatEvent. This has two issues:OfflinePluginis not applied, theChannelwill always be null, even though we could have it in-memoryChatEventHandler.handleChatEventI processed. But the in-memory channel will always be up-to-date, because the event is handled state-side before callingChatEventHandler.handleChatEvent.This PR changes this logic so that we always prioritise the in-memory channel, and fallback to DB if the Channel is not found in-memory.
Implementation
Prioritise the in-memory channel state instead of offline state.
🎨 UI Changes
reveal_channel_before.mov
reveal_channel_after.mov
Testing
OfflinePlugin)Summary by CodeRabbit
Bug Fixes
Tests