Skip to content

Migrate LocalConversation.emitEvent() to typed events, remove legacy format #115

@rbren

Description

@rbren

Problem

LocalConversation has two event emission methods:

  1. emitTypedEvent(event: BaseEvent) — proper typed events matching events/types.ts interfaces
  2. emitEvent({ type, timestamp, data }) — legacy format that creates ad-hoc events

The legacy method creates events like { kind: 'user_message', content } and { kind: 'paused' } that don't match any typed event interface. It even has a @deprecated JSDoc tag but is still used in 10+ places.

// Legacy — creates untyped events
this.emitEvent({
  type: 'message',
  timestamp: Date.now(),
  data: { kind: 'user_message', content },
});

// Proper — uses typed interfaces
this.emitTypedEvent(stateEvent);

Consumers receiving these events via callbacks get inconsistent shapes depending on which code path emitted them.

Proposed Fix

  • Convert all emitEvent() calls to use emitTypedEvent() with proper BaseEvent subtypes
  • For events like user_message and paused that have no existing typed interface, either:
    • Map them to existing types (e.g., user_message -> MessageEvent)
    • Create new typed interfaces if needed
  • Delete emitEvent() entirely

Impact

Low — consistency improvement. All events will match documented typed interfaces.


This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions