-
Notifications
You must be signed in to change notification settings - Fork 238
fix: address issue causing failure to receive heartbeat #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
xwqin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
## Walkthrough
The changes in this pull request include renaming the `heart-beat` event to `heartbeat` in the `Wechaty` class for consistent event naming, whitespace cleanup and trailing space removal in the `Contact` class with an added explicit `return None` in the `say` method, and an enhancement to the `Room` class methods to support forced synchronization of room data via a new `force_sync` parameter.
## Changes
| File Path | Change Summary |
|------------------------------|-------------------------------------------------------------------------------------------------|
| src/wechaty/wechaty.py | Changed event name from `heart-beat` to `heartbeat` in `init_puppet_event_bridge` method for consistency. |
| src/wechaty/user/contact.py | Whitespace cleanup and trailing space removal; added explicit `return None` after sending `FileBox` in `say` method. |
| src/wechaty/user/room.py | Added `force_sync` parameter to `find_all` and `ready` methods to enable forced room data synchronization. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant Caller
participant Room
participant Puppet
Caller->>Room: find_all(query, force_sync)
loop for each room
Room->>Room: ready(force_sync)
alt force_sync is True or room not ready
Room->>Puppet: load room data
Puppet-->>Room: room data
else
Room-->>Room: return cached readiness
end
end
Room-->>Caller: list of ready rooms
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to a118af1 in 9 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_2PHvTa8He8mPfgfT
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -530,7 +530,7 @@ async def heartbeat_listener(payload: EventHeartbeatPayload) -> None: | |||
self.emit('heartbeat', payload.data) | |||
await self.on_heartbeat(payload) | |||
|
|||
puppet.on('heart-beat', heartbeat_listener) | |||
puppet.on('heartbeat', heartbeat_listener) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
The event name 'heart-beat' still exists in the code and needs to be updated
Found remaining instances of 'heart-beat' in src/wechaty/wechaty.py
that need to be updated for consistency:
- Line with
elif event_name == 'heart-beat'
: The condition should use 'heartbeat' - Line with
log.info('receive <heart-beat> event <%s>', payload)
: The log message should use 'heartbeat'
🔗 Analysis chain
LGTM! The event name change looks correct.
The change from 'heart-beat' to 'heartbeat' aligns with:
- The emit function's usage of 'heartbeat'
- The naming convention of other events in the codebase
- The event name in puppet.py
Let's verify there are no other occurrences of 'heart-beat' that need to be updated:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining instances of 'heart-beat' in the codebase
rg "heart-beat" -l
# Search for heartbeat event usage to ensure consistency
rg "heartbeat" -A 2 -B 2
Length of output: 2532
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/wechaty/user/room.py (1)
197-197
: Fix spacing in method signature.The
force_sync
parameter needs proper spacing around the comma and colon for PEP 8 compliance.- query: Optional[Union[str, RoomQueryFilter, Callable[[Contact], bool]]] = None,force_sync:bool=False) -> List[Room]: + query: Optional[Union[str, RoomQueryFilter, Callable[[Contact], bool]]] = None, force_sync: bool = False) -> List[Room]:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/wechaty/user/room.py
(3 hunks)
🔇 Additional comments (2)
src/wechaty/user/room.py (2)
231-231
: LGTM! Proper parameter passing for forced synchronization.The
force_sync
parameter is correctly passed to eachroom.ready()
call, enabling forced synchronization when requested by the caller.
318-318
: LGTM! Correct logic for force_sync behavior.The modified conditional logic properly implements the force_sync functionality:
- When
force_sync=False
and room is ready: returns early (existing behavior)- When
force_sync=True
: continues with synchronization regardless of current readiness stateThis ensures forced synchronization bypasses the cached readiness state as intended.
Rename 'heart-beat' to 'heartbeat' to align with emit in puppet.py:1017.
Important
Fixes heartbeat event listener in
wechaty.py
by renaming event from'heart-beat'
to'heartbeat'
.wechaty.py
by renaming event from'heart-beat'
to'heartbeat'
to match the emitted event name.wechaty.py
for consistency.This description was created by
for a118af1. It will automatically update as commits are pushed.
Summary by CodeRabbit