Refactor: Move command logic into command/domain/primitive layers#533
Merged
ajmcquilkin merged 8 commits intomainfrom Nov 2, 2025
Merged
Refactor: Move command logic into command/domain/primitive layers#533ajmcquilkin merged 8 commits intomainfrom
command/domain/primitive layers#533ajmcquilkin merged 8 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: