Skip to content

Extract socket controller into dedicated domain module#340

Merged
senamakel merged 14 commits intotinyhumansai:mainfrom
senamakel:fix/socket-controller
Apr 6, 2026
Merged

Extract socket controller into dedicated domain module#340
senamakel merged 14 commits intotinyhumansai:mainfrom
senamakel:fix/socket-controller

Conversation

@senamakel
Copy link
Copy Markdown
Member

Summary

  • Extracts the Socket.IO client from src/openhuman/skills/ into its own src/openhuman/socket/ domain module, following the controller migration checklist
  • Splits the 1279-line socket_manager.rs into 5 focused files: types.rs, manager.rs, ws_loop.rs, event_handlers.rs, schemas.rs
  • Adds 5 real RPC controller methods (socket.connect, socket.disconnect, socket.state, socket.emit, socket.connect_with_session) replacing the old stubs
  • Auto-connects to the backend on server startup if a session token is stored
  • Removes MCP tool sync and SkillRegistry dependency from socket — socket is now independent of skills
  • Generic channel message handling: any event ending with :message (e.g. telegram:message, channel:message) triggers the agent loop
  • Adds comprehensive event logging for all incoming socket events

Test plan

  • cargo check passes cleanly (no warnings)
  • cargo test --lib — all 1935 unit tests pass
  • Start core server and verify [socket] Auto-connect initiated in logs
  • Run node scripts/test-channel-receive.mjs to verify Telegram messages arrive
  • Call openhuman.socket_state RPC to verify connection status
  • Send a Telegram message and confirm agent loop triggers via logs

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

…bilityEngine directly

- Updated the test suite to eliminate the use of global_engine, replacing it with a direct instantiation of AccessibilityEngine.
- This change enhances test isolation and clarity by ensuring that each test operates with its own instance of the engine, improving reliability and maintainability.
- Introduced a new `socket` module to facilitate communication between skills, enhancing the modularity and organization of the codebase.
- Updated imports in `qjs_engine.rs` to reference the new `SocketManager` from the `socket` module, streamlining socket management for skill interactions.
- Removed the deprecated `socket_manager` module from the skills module, improving clarity and reducing redundancy in the code structure.
- Added socket-related registered controllers and schemas to the core build functions, enhancing the communication capabilities within the OpenHuman framework.
- Updated the `build_registered_controllers` and `build_declared_controller_schemas` functions to include socket components, ensuring comprehensive integration of the new socket module.
- Updated the `bootstrap_skill_runtime` function to initialize and register the `SocketManager` globally, allowing RPC handlers to access socket functionalities.
- Improved documentation to reflect the addition of socket management capabilities alongside the QuickJS skill runtime.
- Cleaned up imports in `event_handlers.rs` to streamline the codebase.
- Removed the `SocketManager` integration from the `bootstrap_skill_runtime` function, simplifying the socket management process.
- Eliminated the `socket_manager` field and related methods from the `RuntimeEngine` struct, streamlining the codebase.
- Cleaned up unused MCP handlers and socket-related imports in the event handlers, enhancing code clarity and maintainability.
- Eliminated unnecessary calls to `sync_tools()` in the `RuntimeEngine` during skill status changes, simplifying the skill lifecycle management.
- This change enhances performance by reducing redundant synchronization operations during skill execution and shutdown processes.
- Added logging for incoming socket events to improve observability, including event name and data size.
- Implemented detailed debug logging for event payloads, ensuring clarity on the data being processed.
- Updated event handling logic to streamline routing for webhook requests and inbound channel messages, enhancing the overall responsiveness of the system.
- Introduced logging for unhandled events to aid in debugging and monitoring.
- Updated the `bootstrap_skill_runtime` function to clone the `SocketManager` instance for global registration, ensuring proper socket management.
- Introduced background tasks for auto-starting skills and auto-connecting to the backend using stored session tokens, improving startup efficiency and user experience.
- Added detailed logging for session token checks and connection attempts, enhancing observability and debugging capabilities during socket operations.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Warning

Rate limit exceeded

@senamakel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 24 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 6 minutes and 24 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f5425b92-55d2-4b9d-91fb-1c5545ddf166

📥 Commits

Reviewing files that changed from the base of the PR and between bb1f2c3 and 082958f.

📒 Files selected for processing (22)
  • .husky/pre-push
  • app/package.json
  • app/src/components/settings/panels/ScreenIntelligencePanel.tsx
  • package.json
  • src/core/all.rs
  • src/core/jsonrpc.rs
  • src/core/screen_intelligence_cli.rs
  • src/openhuman/mod.rs
  • src/openhuman/screen_intelligence/engine.rs
  • src/openhuman/screen_intelligence/tests.rs
  • src/openhuman/skills/mod.rs
  • src/openhuman/skills/qjs_engine.rs
  • src/openhuman/skills/schemas.rs
  • src/openhuman/skills/socket_manager.rs
  • src/openhuman/socket/event_handlers.rs
  • src/openhuman/socket/manager.rs
  • src/openhuman/socket/mod.rs
  • src/openhuman/socket/schemas.rs
  • src/openhuman/socket/types.rs
  • src/openhuman/socket/ws_loop.rs
  • tests/skills_rpc_e2e.rs
  • tests/skills_sync_memory_test.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

senamakel and others added 6 commits April 5, 2026 22:39
- Introduced a new `manifests_in_dir` function to retrieve skill manifests from a specified directory, improving skill discovery.
- Added `select_skill_id` function to prioritize skill selection based on environment variables and preferred candidates, enhancing flexibility in test configurations.
- Updated the test suite to utilize the new skill selection logic, ensuring more robust and configurable test scenarios.
- Improved handling of tool selection with enhanced logging and fallback mechanisms for better debugging and usability.
- Introduced new scripts for Rust checks and formatting in both the main and app package.json files.
- Updated pre-push hook to include Rust compile checks, enhancing pre-push validation.
- Modified existing format commands to integrate Rust formatting, ensuring consistency across codebases.
- Adjusted the formatting of the description text for better readability by breaking it into multiple lines within the `ScreenIntelligencePanel` component.
The socket auto-connect was panicking with "Could not automatically
determine the process-level CryptoProvider" because tokio-tungstenite
uses rustls for wss:// but no crypto provider was installed. Install
the ring provider before each connect attempt.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tests hardcoded 'example-skill' which no longer exists in the
skills directory. Now dynamically picks the first available skill
(preferring server-ping) so tests work regardless of which skills
are present.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@senamakel senamakel merged commit b589a29 into tinyhumansai:main Apr 6, 2026
8 of 9 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.

1 participant