Skip to content

Add unit tests for Remote* classes and LocalConversation #4740

Description

@rbren

Problem

The following major classes have no unit tests — they're only covered by integration tests that require a running agent-server:

  • RemoteConversation (338 lines) — conversation lifecycle, message sending, WebSocket management
  • RemoteWorkspace (318 lines) — command execution, file upload/download, git operations
  • RemoteState (238 lines) — state caching, locking, event-driven updates
  • HttpClient (207 lines) — request building, error handling, URL construction
  • WebSocketCallbackClient (140 lines) — reconnection, message parsing, backoff
  • LocalConversation (953 lines) — agent loop, tool execution, all state management
  • RemoteEventsList (162 lines) — pagination, caching, merging
  • ConversationManager (166 lines) — multi-conversation CRUD

Furthermore, there are no tests for factory functions: createConversation, createWorkspace, createConversationAuto, createWorkspaceAuto.

The existing 157 unit tests cover hooks, events/types, security, stuck-detector, and secret-registry — which are pure logic modules. The core client functionality that actually talks to servers is untested at the unit level.

Proposed Fix

Add unit tests using a mock/stub HttpClient (or a lightweight fake that records calls):

  1. HttpClient: Test URL construction, query param handling, error parsing, timeout behavior
  2. RemoteConversation: Test start() creates correct request, sendMessage() formats messages, close() cleans up
  3. RemoteState: Test caching TTL, updateStateFromEvent(), unwrapState() normalization
  4. RemoteWorkspace: Test executeCommand() request format, fileUpload() FormData construction
  5. LocalConversation: Test agent loop iteration, tool dispatch, pause/resume, stuck detection integration
  6. Factory functions: Test type detection and error cases

Use a simple request-recording fake rather than heavy mocking frameworks. Assert on actual request shapes and response handling.

Impact

Medium — catches regressions in the most critical code paths without requiring a running server.


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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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