Fix conversation initial state
- [ ] This change is worth documenting at https://docs.all-hands.dev/
- [x] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below
End-user friendly description of the problem this fixes or functionality this introduces.
This PR fixes issues with conversation state management in the OpenHands UI, particularly during the initial connection and startup phase. Users will experience more reliable connections when starting new conversations and better state handling when working with nested runtimes. The UI will now properly display connection status and handle state transitions more smoothly.
Summarize what the PR does, explaining any non-trivial design decisions.
Before this change, the switching between conversations can result in unneeded / broken fetches (The fetches are more likely to be broken when dealing with nested runtimes). This is because the state derived from redux is not cleared when you exit a conversation route. e.g.:
The initial state before this PR is a red 'Connected', which is not right - we now have it "Connecting to runtime":
This PR addresses several frontend state management issues and improves the handling of conversation state:
-
Frontend State Management Improvements:
- Created a new
useActiveConversationhook that abstracts the logic for fetching and refreshing conversation data - Refactored
useUserConversationto accept a custom refetch interval function - Added a new
CONNECTINGstate to the WebSocket client provider to better handle connection transitions - Improved state handling in various components to prevent UI flickering during state transitions
- Created a new
-
Nested Runtime Support:
- Enhanced Docker runtime implementation to better support nested runtime environments
- Fixed issues with state synchronization between parent and child runtimes
-
Code Refactoring:
- Extracted common logic into reusable hooks to improve code maintainability
- Improved type definitions for better TypeScript support
- Optimized refetch intervals for better performance and reduced API calls
These changes collectively improve the reliability and user experience of the OpenHands UI, particularly during conversation initialization and when working with complex runtime environments.
Link of any specific issues this addresses:
To run this PR locally, use the following command:
docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:7b9e607-nikolaik --name openhands-app-7b9e607 docker.all-hands.dev/all-hands-ai/openhands:7b9e607