Skip to content

Conversation

@rbren
Copy link
Contributor

@rbren rbren commented Oct 30, 2025

Overview

This PR transforms the example application homepage into a comprehensive conversation manager that demonstrates the full capabilities of the TypeScript SDK for interacting with OpenHands Agent Server conversations.

Changes Made

Homepage Transformation

  • Removed most existing homepage content while preserving the settings button
  • Replaced with a full-featured conversation manager interface

New ConversationManager React Component

  • List View: Display all existing conversations with their current state and latest events
  • Create: Form to create new conversations with customizable parameters
  • Messaging: Send messages to active conversations and view responses
  • Delete: Remove conversations with confirmation
  • Real-time Updates: Shows conversation status, latest events, and current state

SDK Enhancements

  • Added ConversationManager class for conversation CRUD operations
  • Added ConversationSearchRequest and ConversationSearchResponse types
  • Added ConversationManagerOptions configuration type
  • Updated exports to include new conversation management functionality

Debugging & Investigation (Latest Updates)

  • Added comprehensive logging to trace API key/model name confusion causing 401 errors
  • HTTP request body logging in http-client.ts to see exact request payload
  • Agent object and request logging in remote-conversation.ts to trace data flow
  • Investigating where model name is incorrectly being passed as API key in HTTP requests

Technical Implementation

  • TypeScript: Full type safety throughout the conversation manager
  • React Hooks: Modern React patterns with useState and useEffect
  • CSS Styling: Comprehensive styling for a polished user interface
  • Error Handling: Robust error handling for API operations
  • Loading States: User feedback during async operations

Features Demonstrated

  1. Conversation Listing: Browse all conversations with metadata
  2. Conversation Creation: Create new conversations with custom settings
  3. Message Exchange: Send messages and receive agent responses
  4. State Monitoring: View current conversation state and latest events
  5. Conversation Management: Delete conversations when no longer needed

Current Status

Completed Features:

  • Conversation creation with proper agent configuration
  • Conversation listing with pagination support
  • Message sending functionality
  • Conversation deletion
  • Settings integration
  • Error handling and user feedback

🔍 Under Investigation:

  • 401 authentication errors during conversation creation
  • API key/model name field confusion in HTTP requests
  • Added debugging logs to trace the issue

Files Modified

  • example/src/App.tsx - Updated to use ConversationManager
  • example/src/components/ConversationManager.tsx - New React component
  • example/src/components/ConversationManager.css - Component styling
  • example/vite.config.ts - Updated port configuration
  • src/conversation/conversation-manager.ts - New SDK class
  • src/conversation/remote-conversation.ts - Added debugging logs
  • src/client/http-client.ts - Added request body logging
  • src/models/conversation.ts - Added new types
  • src/index.ts - Updated exports

Testing

  • ✅ TypeScript compilation passes
  • ✅ Example application builds successfully
  • ✅ All SDK exports are properly typed
  • ✅ React component renders without errors
  • 🔍 Investigating 401 authentication errors with debugging logs

Usage

The conversation manager provides an intuitive interface for:

  • Developers learning the SDK capabilities
  • Testing conversation workflows
  • Demonstrating OpenHands Agent Server integration

This implementation serves as both a functional tool and a comprehensive example of how to build applications using the TypeScript SDK.

Next Steps

  1. Resolve the API key/model name confusion causing 401 errors
  2. Remove debugging logs once issue is identified and fixed
  3. Add comprehensive error recovery mechanisms
  4. Enhance UI/UX based on user feedback

- Remove most homepage content, keeping only settings button
- Add ConversationManager React component with full CRUD functionality
- Implement conversation listing, creation, messaging, and deletion
- Display latest event and current state for each conversation
- Add ConversationManager class to SDK for API operations
- Export new types: ConversationSearchRequest/Response, ConversationManagerOptions
- Update example app to showcase conversation management capabilities

Co-authored-by: openhands <openhands@all-hands.dev>
- Update CreateConversationRequest interface to use Message type instead of string
- Convert string initialMessage to proper Message object in RemoteConversation.create
- Add Message import to conversation models
- Fixes 422 error when creating conversations with initial messages

Co-authored-by: openhands <openhands@all-hands.dev>
- Added HTTP request body logging in http-client.ts
- Added agent object and request logging in remote-conversation.ts
- These logs will help identify where model name is being passed as API key
- Investigating 401 authentication errors in conversation creation
- Add loadConversationDetails function to fetch RemoteConversation and events
- Update conversation click handler to load details when selected
- Add conversation events display with messages, actions, and observations
- Add proper styling for events list with color-coded event types
- Clear conversation details when conversation is deleted or deselected
- Show loading state while fetching conversation details

Co-authored-by: openhands <openhands@all-hands.dev>
- Add debug logging to see actual conversation data structure
- Update ConversationInfo interface to include stats field from API response
- Add optional fields like title, created_at, updated_at to match API

Co-authored-by: openhands <openhands@all-hands.dev>
- Use agent.kind instead of agent.name (API returns kind: 'Agent')
- Display created_at timestamp instead of non-existent conversation_stats
- Add fallback for both kind and name fields to handle API variations
- Fix both conversation list and detail views

Co-authored-by: openhands <openhands@all-hands.dev>
- Add console logs to track conversation selection and data flow
- Remove unused state variables (selectedConversationDetails, currentAgent)
- Clean up references to removed state setters
- Debug conversation finding logic in details section

Co-authored-by: openhands <openhands@all-hands.dev>
- Fixed property access issues in JSX rendering
- Simplified data structure using single ConversationData interface
- Corrected SDK API usage (host instead of baseUrl, getAllConversations instead of listConversations)
- Fixed agent status access through state.getAgentStatus()
- Removed complex state mixing between ConversationInfo and RemoteConversation types
- Improved error handling and loading states
- Added proper TypeScript types for all data structures
- Cleaned up component structure for better maintainability

This resolves the conversation details display issue where data was available
but JSX rendering showed blank values due to incorrect property access.
- Changed ConversationManager to use settings.agentServerApiKey instead of settings.apiKey
- Updated useEffect dependency to watch for agentServerApiKey changes
- Keeps settings.apiKey for LLM authentication in agent creation
- Resolves issue where x-session-api-key header was incorrectly set with LLM key

This ensures proper separation between:
- agentServerApiKey: for authenticating with the OpenHands agent server
- apiKey: for LLM API calls within agent configurations
- Updated class names to match rewritten component (refresh-btn, create-btn, delete-btn, etc.)
- Changed conversation-layout to conversation-content for grid layout
- Updated header elements from h1/h2 to h2/h3 to match component structure
- Added styles for new component elements (loading, no-selection, details-content, etc.)
- Added proper styling for events-section, message-section, and detail-row elements
- Updated responsive design to use correct class names
- Fixed send button styling with send-btn class
- Added color: #374151 to .detail-row elements
- Added color to .event-message and .event-content elements
- Fixes conversation details being invisible due to white text on white background
- Added color: #374151 to .conversation-item for default text color
- Added color to .conversation-status elements
- Fixes conversation list items being invisible due to white text
- API returns events in { items: [...] } format, not directly as array
- Added proper handling to extract events from response.items
- Added debug logging to track response structure
@rbren
Copy link
Contributor Author

rbren commented Oct 30, 2025

@OpenHands fix

Run npm run format:check

> @openhands/agent-server-typescript-client@0.1.0 format:check
> prettier --check "src/**/*.ts" "examples/**/*.ts"

Checking formatting...
[warn] src/conversation/conversation-manager.ts
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
Error: Process completed with exit code 1.

@openhands-ai
Copy link

openhands-ai bot commented Oct 30, 2025

I'm on it! rbren can track my progress at all-hands.dev

- Added syncPromise to track initial sync completion
- Added ensureSynced() method to wait for sync before returning events
- Modified getEvents() to await sync completion before accessing cached events
- Fixes issue where getEvents() returned empty array before sync completed

This resolves the 'Loaded events: []' issue where events were not visible
in the conversation manager despite successful API responses.
@openhands-ai
Copy link

openhands-ai bot commented Oct 30, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • CI

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #10 at branch `feature/conversation-manager-homepage`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai
Copy link

openhands-ai bot commented Oct 30, 2025

Summary

I have successfully fixed the Prettier formatting issue that was causing the CI to fail on PR #10.

Problem: The npm run format:check command was failing due to code style issues in src/conversation/conversation-manager.ts.

Solution:

  1. Set up the development environment (Node.js 18.20.8, npm, and project dependencies)
  2. Ran npm run format to apply Prettier formatting fixes
  3. Committed and pushed the formatting changes to the feature/conversation-manager-homepage branch

Changes Made:

  • Applied Prettier formatting to src/conversation/conversation-manager.ts
  • Fixed line breaks, indentation, and added proper newline at end of file
  • No functional changes, only code style improvements

Verification:

  • npm run format:check now passes without any warnings
  • ✅ TypeScript compilation still works correctly
  • ✅ ESLint shows only warnings (no errors)

The CI formatting check should now pass, resolving the build failure that was preventing the PR from being merged.

View full conversation

@rbren rbren marked this pull request as ready for review October 30, 2025 04:54
@rbren rbren merged commit ccf4c9b 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