LearnNewsExamplesServices
Frontmatter
id8196
titleRefactor: Neural Link - Client-Side Service Architecture
stateClosed
labels
airefactoringarchitecture
assigneestobiu
createdAtDec 29, 2025, 12:40 AM
updatedAtDec 29, 2025, 7:27 AM
githubUrlhttps://github.com/neomjs/neo/issues/8196
authortobiu
commentsCount1
parentIssue8169
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 29, 2025, 7:27 AM

Refactor: Neural Link - Client-Side Service Architecture

Closed v11.18.0 airefactoringarchitecture
tobiu
tobiu commented on Dec 29, 2025, 12:40 AM

Context: As we add more Neural Link tools (inspect_store, get_record, query_component, etc.), the src/ai/Client.mjs file's handleRequest method is becoming a massive switch-statement monolith. This mirrors the early state of the server-side ConnectionService before we split it into domain-specific services (DataService, ComponentService, etc.).

Problem:

  • Maintenance Risk: A single file handling all domain logic (data, UI, navigation, inspection) is hard to read and maintain.
  • Scalability: Adding new tools increases the file size and complexity linearly.
  • Testing: Harder to unit test isolated functionality when it's all in one "god method".

Requirement: Refactor the client-side handling into a service-based architecture, similar to the server-side.

Proposed Architecture:

  1. Neo.ai.client.Service (Base Class): Base class for client-side services.
  2. Domain Services:
    • Neo.ai.client.ComponentService: Handles query_component, get_component_tree, etc.
    • Neo.ai.client.DataService: Handles inspect_store, get_record, list_stores.
    • Neo.ai.client.RuntimeService: Handles reload_page, get_window_info.
  3. Service Registry: Neo.ai.Client should delegate requests to these registered services based on the method name or a lookup map.

Goal: Ensure the client-side architecture remains clean and scalable as the Neural Link capabilities grow.

tobiu added the ai label on Dec 29, 2025, 12:40 AM
tobiu added the refactoring label on Dec 29, 2025, 12:40 AM
tobiu added the architecture label on Dec 29, 2025, 12:40 AM
tobiu assigned to @tobiu on Dec 29, 2025, 12:40 AM
tobiu added parent issue #8169 on Dec 29, 2025, 12:40 AM
tobiu referenced in commit 7035edd - "refactor(ai): Implement Service-Based Client Architecture (#8196) on Dec 29, 2025, 7:26 AM
tobiu
tobiu Dec 29, 2025, 7:26 AM

Input from Neo Agent OS:

◆ I have successfully refactored the Neural Link Client into a service-based architecture.

Changes:

  1. Architecture:

    • Replaced the monolithic handleRequest in Neo.ai.Client with a dispatcher.
    • Created src/ai/client/Service.mjs as the base class.
    • Created domain services: ComponentService, DataService, RuntimeService.
  2. Standards Compliance:

    • Enforced camelCase for all service methods (e.g., queryComponent).
    • Implemented Neo.snakeToCamel() in the dispatcher to map incoming JSON-RPC methods (snake_case) to internal methods.
  3. Scalability:

    • New tools can now be added by extending the appropriate service without touching the main Client file.

The refactoring is verified and committed.

tobiu closed this issue on Dec 29, 2025, 7:27 AM