[kimi-task] [feat] Add visitor_state message handler #670

Closed
opened 2026-03-21 03:12:04 +00:00 by kimi · 1 comment
Collaborator

Epic: Matrix Unification

Task

Create src/infrastructure/visitor.py with a VisitorState dataclass and handler.
When a visitor connects to the Matrix and moves around, the frontend sends visitor_state messages.
The backend needs to track active visitors and broadcast their positions.

Files

  • src/infrastructure/visitor.py — NEW: VisitorState dataclass, VisitorRegistry (dict of active visitors)
  • tests/unit/test_visitor.py — NEW: test add/remove/update visitor, test broadcast format

Acceptance Criteria

  • VisitorState has: visitor_id, display_name, position (x,y,z), rotation, connected_at
  • VisitorRegistry.add(), .remove(), .update_position(), .get_all() methods
  • get_all() returns list of visitor_state dicts in Matrix protocol format
  • tox -e unit passes
  • tox -e lint passes

Context

The Matrix frontend sends visitor position via WebSocket as the user walks around with WASD.
Other visitors should see each other as stick figures. Currently no backend tracks this.

## Epic: Matrix Unification ## Task Create `src/infrastructure/visitor.py` with a VisitorState dataclass and handler. When a visitor connects to the Matrix and moves around, the frontend sends visitor_state messages. The backend needs to track active visitors and broadcast their positions. ## Files - src/infrastructure/visitor.py — NEW: VisitorState dataclass, VisitorRegistry (dict of active visitors) - tests/unit/test_visitor.py — NEW: test add/remove/update visitor, test broadcast format ## Acceptance Criteria - [ ] VisitorState has: visitor_id, display_name, position (x,y,z), rotation, connected_at - [ ] VisitorRegistry.add(), .remove(), .update_position(), .get_all() methods - [ ] get_all() returns list of visitor_state dicts in Matrix protocol format - [ ] tox -e unit passes - [ ] tox -e lint passes ## Context The Matrix frontend sends visitor position via WebSocket as the user walks around with WASD. Other visitors should see each other as stick figures. Currently no backend tracks this.
kimi self-assigned this 2026-03-21 03:12:04 +00:00
Author
Collaborator

PR #699 created.

Summary

Implemented src/infrastructure/visitor.py with:

  • VisitorState dataclass: visitor_id, display_name, position (x,y,z), rotation, connected_at
  • VisitorRegistry singleton: add(), remove(), update_position(), get(), get_all(), clear()
  • Matrix protocol format: get_all() returns visitor_state message dicts ready for WebSocket broadcast

Files Changed

  • src/infrastructure/visitor.py (new)
  • tests/unit/test_visitor.py (new)

Verification

  • All 2450 unit tests pass
  • Lint checks clean
  • Pre-push gate passed
PR #699 created. ## Summary Implemented `src/infrastructure/visitor.py` with: - **VisitorState** dataclass: visitor_id, display_name, position (x,y,z), rotation, connected_at - **VisitorRegistry** singleton: add(), remove(), update_position(), get(), get_all(), clear() - **Matrix protocol format**: get_all() returns visitor_state message dicts ready for WebSocket broadcast ## Files Changed - `src/infrastructure/visitor.py` (new) - `tests/unit/test_visitor.py` (new) ## Verification - All 2450 unit tests pass - Lint checks clean - Pre-push gate passed
kimi closed this issue 2026-03-21 13:56:21 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#670