-
-
Notifications
You must be signed in to change notification settings - Fork 39
Refactor: Move command logic into command/domain/primitive layers
#533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Tauri IPC (Inter-Process Communication) layer by introducing a structured API contract pattern. The changes separate concerns by creating dedicated request/response types and moving business logic from IPC command handlers into domain layer handlers.
Key changes:
- Introduced structured request/response contracts for all IPC commands with type-safe definitions
- Created a domain layer (
domains/modules) that contains the actual business logic - Updated IPC command handlers to simply delegate to domain handlers
- Modified TypeScript API calls to wrap parameters in a
requestobject and unwrap responses
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/api/mesh.ts | Updated to wrap parameters in request objects for mesh operations |
| src/api/graph.ts | Updated to wrap parameters in request objects and unwrap graph responses |
| src/api/connection.ts | Updated to wrap parameters in request objects and unwrap connection responses |
| src-tauri/src/lib.rs | Added new api and domains module declarations |
| src-tauri/src/ipc/commands/radio.rs | Refactored to delegate to domain handlers with new request/response types |
| src-tauri/src/ipc/commands/mesh.rs | Refactored to delegate to domain handlers with new request/response types |
| src-tauri/src/ipc/commands/graph.rs | Refactored to delegate to domain handlers with new request/response types |
| src-tauri/src/ipc/commands/connections.rs | Refactored to delegate to domain handlers with new request/response types |
| src-tauri/src/graph/ds/graph.rs | Removed extraneous blank line |
| src-tauri/src/domains/radio.rs | New file containing radio-related business logic handlers |
| src-tauri/src/domains/mesh.rs | New file containing mesh-related business logic handlers |
| src-tauri/src/domains/graph.rs | New file containing graph-related business logic handlers |
| src-tauri/src/domains/connections.rs | New file containing connection-related business logic handlers |
| src-tauri/src/domains/mod.rs | Module declarations for domain layer |
| src-tauri/src/api/primitives/radio.rs | Type definitions for radio primitives |
| src-tauri/src/api/primitives/mesh.rs | Type definitions for mesh primitives |
| src-tauri/src/api/primitives/graph.rs | Type definitions for graph primitives |
| src-tauri/src/api/primitives/connections.rs | Type definitions for connection primitives |
| src-tauri/src/api/primitives/mod.rs | Module declarations for API primitives |
| src-tauri/src/api/contracts/radio.rs | Request/response contract definitions for radio operations |
| src-tauri/src/api/contracts/mesh.rs | Request/response contract definitions for mesh operations |
| src-tauri/src/api/contracts/graph.rs | Request/response contract definitions for graph operations |
| src-tauri/src/api/contracts/connections.rs | Request/response contract definitions for connection operations |
| src-tauri/src/api/contracts/mod.rs | Module declarations for API contracts |
| src-tauri/src/api/mod.rs | Module declarations for API layer |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR refactors the IPC command handlers by introducing a layered architecture to improve code organization, maintainability, and testability.
The responsibility of a
commandis solely to manage Tauri dependency injection and delegate all work to thedomain. Adomainhandles the business logic required with fulfilling acommand. Aprimitiveis a struct that defines part of the contract between the Rust and TypeScript layers of the application.In the long-term,
primitiveswill have TypeScript types generated for use in TypeScript, which will replace the legacy generation flow which currently generates types for all protobuf types. Long-term this also opens up the possibility of removing the specta type generation from themeshtastic-rustSDK as it's always been somewhat buggy.Changes
New Architecture:
src-tauri/src/api/contracts/) - Type-safe request/response types for all commands across connections, graph, mesh, and radio modulessrc-tauri/src/api/primitives/) - Shared primitive types and data structures used across the API surfacesrc-tauri/src/domains/) - Extracted business logic from IPC handlers into dedicated domain modules containing the core functionalityRefactored Modules:
ipc/commands/connections.rs- Significantly reduced from 340+ lines by delegating to domain layeripc/commands/graph.rs- Streamlined command handlersipc/commands/mesh.rs- Simplified to focus on IPC concerns onlyipc/commands/radio.rs- Extracted radio logic into domain moduleFrontend Updates:
Benefits: