Skip to content

Conversation

@geyang
Copy link
Collaborator

@geyang geyang commented Nov 27, 2025

Summary

  • Simplified Event class with a unified __init__ that handles timestamp conversion centrally
  • Refactored ClientEvent and ServerEvent to use super().__init__() properly with cleaner inheritance
  • Moved the omit utility function from html_components.py to a new utils.py for better code organization
  • Added consistent type hints throughout the events module

Test plan

  • Run existing tests to verify event serialization/deserialization works correctly
  • Test client-server event communication in a live session
  • Verify timestamp handling for both client and server events

Note

Centralizes event initialization/timestamp handling, streamlines event constructors and typing, and moves omit helper to a new utils.py with updated imports.

  • Events:
    • Initialization: Unified Event.__init__ with centralized timestamp handling; ClientEvent/ServerEvent now call super().__init__.
    • Constructors/Typing: Simplified Update/Add/Upsert/Remove constructors and added consistent type hints; preserved _serialize behavior.
    • Minor tweaks: NullEvent default etype and ts=None; Frame frame_rate: float; ServerRPC UUID handling clarified.
  • Schemas:
    • html_components.py: Remove inline omit; import from vuer.utils.
  • Utils:
    • New utils.py introducing omit and used by html_components.py.

geyang and others added 2 commits October 20, 2025 23:11
- Simplify Event base class __init__ logic
- Fix and improve type annotations (use lowercase dict, add Optional/bool types)
- Remove redundant code and comments in ServerEvent subclasses
- Extract omit() utility to separate utils.py module
- Improve timestamp handling consistency across Event classes
- Fix incorrect docstrings (Remove class)
- Clean up varargs type hints (*elements: Element instead of List[Element])

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@geyang geyang requested a review from marvinluo1 November 27, 2025 01:35
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on December 3

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

self.etype = etype
self.__dict__.update(kwargs)
def __init__(self, **kwargs):
super().__init__(**kwargs)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing default values for ClientEvent attributes

The refactoring removed default values for etype and value attributes in ClientEvent. The old code set self.etype = None when not provided and had a class attribute value = None. The new code only sets these via kwargs, causing AttributeError when accessed but not provided. This breaks backward compatibility since __eq__ (line 36), __repr__ (line 43), and UPLOAD handling (line 48-54) all access these attributes, expecting them to exist.

Additional Locations (1)

Fix in Cursor Fix in Web


def __init__(self, data, etype: Optional[str] = None, ts: Optional[float] = None, **kwargs):
super().__init__(ts=ts, **kwargs)
self.data = data
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: ServerEvent etype not serialized from class attribute

The refactoring removed self.__dict__.update(etype=self.etype, **kwargs) from ServerEvent.__init__. This line copied the class attribute etype into the instance's __dict__, ensuring it was included in serialization. Without it, when etype is only a class attribute (as in Noop, Set, Update, etc.), it won't be in self.__dict__ and won't be included in the serialized output from _serialize(). The client requires etype to identify event types, so this breaks event communication.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

@marvinluo1 marvinluo1 left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants