Skip to content

Conversation

@rbren
Copy link
Contributor

@rbren rbren commented Oct 30, 2025

Problem

Events weren't displaying properly in the UI due to several issues:

  1. Property mismatch: The UI was looking for event.type but the API returns event.kind
  2. Content structure mismatch: The UI expected event.message and event.content properties, but different event types have different structures:
    • MessageEvent has llm_message.content array
    • ActionEvent has action object
    • ObservationEvent has observation property
    • etc.

This resulted in empty event boxes being displayed instead of actual event content.

Solution

🔧 Fixed Event Display Logic

  • Updated property access from event.type to event.kind to match API response
  • Created getEventDisplayContent() utility function to properly extract displayable content from different event types
  • Added proper content extraction for MessageEvent, ActionEvent, ObservationEvent, AgentErrorEvent, SystemPromptEvent, and PauseEvent

🎨 Implemented Expando UI

  • Shows only the most recent event by default for better UX
  • Added "Show All" button when there are multiple events
  • Most recent event is highlighted with a "Latest" badge and ring styling
  • Events are sorted by timestamp (most recent first)
  • Added content truncation for long messages (200 char limit with "truncated" indicator)
  • Added collapsible raw data details section for debugging

🏗️ Enhanced Type Definitions

  • Added specific event type interfaces (MessageEvent, ActionEvent, ObservationEvent, etc.)
  • Implemented proper discriminated unions for type safety
  • Updated exports to include new event types

🎯 UI Improvements

  • Better visual hierarchy with event kind, source, and timestamp display
  • Proper content formatting for different event types
  • Responsive design with proper spacing and colors
  • Maintained dark mode support
  • Added hover effects and smooth transitions

Testing

  • ✅ Built TypeScript client successfully
  • ✅ Built example app successfully
  • ✅ Created and ran unit test for event display logic
  • ✅ Verified all event types display correctly with proper content extraction

Files Changed

  • src/types/base.ts - Enhanced event type definitions
  • src/index.ts - Updated exports for new event types
  • example/src/components/ConversationManager.tsx - Fixed event display logic and implemented expando UI

Screenshots

The UI now properly displays events with their actual content instead of empty boxes, and provides a clean expando interface for viewing event history.


Note: This PR fixes a critical UI issue where events were not displaying properly, making the conversation interface much more usable for debugging and monitoring agent interactions.

@rbren can click here to continue refining the PR

- Fix property mismatch: UI was looking for event.type but API returns event.kind
- Add proper event content extraction for different event types (MessageEvent, ActionEvent, ObservationEvent, etc.)
- Implement expando UI showing most recent event by default with option to show all events
- Add enhanced type definitions for specific event types with proper discriminated unions
- Improve event display with better visual hierarchy, content truncation, and raw data details
- Add proper dark mode support and responsive design
- Sort events by timestamp with most recent first and highlight latest event

Co-authored-by: openhands <openhands@all-hands.dev>
@rbren rbren marked this pull request as ready for review October 30, 2025 16:13
- Add text-left class to all event content sections
- Ensure JSON raw data is properly left-aligned for better readability
- Maintain consistent left alignment throughout the events display
@rbren rbren merged commit 7e99198 into main Oct 30, 2025
6 checks passed
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