Skip to content

Conversation

@vedant-theagentic
Copy link

Summary

This PR adds conversation history management functionality to the frontend and fixes critical WebSocket and Docker networking issues in the backend.

Features Added

1. Conversation History Management

  • Automatic Persistence: Conversations are automatically saved to browser localStorage
  • Conversation List: View, load, and delete saved conversations via sidebar
  • Export Functionality: Export conversations as JSON or Markdown
  • UI Components:
    • History button in header (clock icon)
    • Conversation sidebar with metadata (title, date, message count)
    • Hover actions for quick export/delete

2. Technical Improvements

  • Redux middleware for automatic localStorage persistence
  • React context for managing conversation list state
  • Conversation management utilities (save, load, delete, export)
  • Auto-cleanup when storage quota exceeded (keeps 50 most recent)

Bug Fixes

1. WebSocket Connection Errors

Problem: WebSocket errors when clients disconnect - "Cannot call 'send' once a close message has been sent" and "WebSocket is not connected" errors.

Solution:

  • Added proper WebSocketDisconnect exception handling in cortex_on/main.py
  • Implemented connection state checks before sending messages
  • Added graceful cleanup in finally block
  • Prevents crashes when clients disconnect during task execution

Files Changed:

  • cortex_on/main.py - Enhanced WebSocket endpoint with proper error handling

2. Docker Networking Connection Error

Problem: cortex_on service couldn't connect to agentic_browser service - "Cannot connect to host localhost:8000" errors.

Solution:

  • Changed hardcoded localhost:8000 to use Docker service name agentic_browser:8000
  • Added support for AGENTIC_BROWSER_URL environment variable
  • Defaults to Docker service name for containerized deployments
  • Falls back to localhost for local development

Files Changed:

  • cortex_on/agents/web_surfer.py - Dynamic API URL configuration
  • cortex_on/agents/orchestrator_agent.py - Updated WebSurfer initialization

3. Minor Fixes

  • Fixed typo: a500500 in orchestrator_agent.py

Files Changed

New Files

  • frontend/src/dataStore/persistenceMiddleware.ts - Redux middleware for localStorage
  • frontend/src/utils/conversationUtils.ts - Conversation management utilities
  • frontend/src/components/home/ConversationList.tsx - Conversation sidebar component
  • frontend/src/contexts/ConversationContext.tsx - React context for state management

Modified Files

  • frontend/src/dataStore/store.ts - Added persistence middleware
  • frontend/src/dataStore/messagesSlice.ts - Added clearMessages action, localStorage loading
  • frontend/src/components/home/Header.tsx - Added History button
  • frontend/src/components/home/Chat.tsx - Integrated ConversationList
  • frontend/src/App.tsx - Added ConversationProvider
  • cortex_on/main.py - Fixed WebSocket error handling
  • cortex_on/agents/web_surfer.py - Fixed Docker networking
  • cortex_on/agents/orchestrator_agent.py - Updated WebSurfer init, fixed typo

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.

1 participant