mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(desktop): implement DI auto-wiring and validation (#4782)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
8bb1e86511
commit
f45993ede2
11 changed files with 160 additions and 28 deletions
|
|
@ -0,0 +1,5 @@
|
|||
# Track desktop_di_autowiring_20260313 Context
|
||||
|
||||
- [Specification](./spec.md)
|
||||
- [Implementation Plan](./plan.md)
|
||||
- [Metadata](./metadata.json)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"track_id": "desktop_di_autowiring_20260313",
|
||||
"type": "chore",
|
||||
"status": "new",
|
||||
"created_at": "2026-03-13T12:00:00Z",
|
||||
"updated_at": "2026-03-13T12:00:00Z",
|
||||
"description": "Architecture Health & DI (Immediate Priority) * Desktop Koin checkModules() test: Add a test to ensure Desktop DI bindings are validated at compile-time/test-time so we catch missing interfaces early. * Auto-wire Desktop ViewModels: Configure KSP so we can eliminate the manual ViewModel wiring in DesktopKoinModule and rely on @KoinViewModel annotations like Android does."
|
||||
}
|
||||
16
conductor/archive/desktop_di_autowiring_20260313/plan.md
Normal file
16
conductor/archive/desktop_di_autowiring_20260313/plan.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Implementation Plan: Desktop DI Auto-Wiring and Validation
|
||||
|
||||
## Phase 1: Setup KSP for Desktop and Test Scaffolding
|
||||
- [x] Task: Update the `meshtastic.koin` convention plugin (or equivalent `build-logic` files) to apply KSP to the `jvmMain` (Desktop) target for `@KoinViewModel` auto-wiring.
|
||||
- [x] Task: Write Failing Test: Create `DesktopKoinTest.kt` in `desktop/src/test/kotlin/org/meshtastic/desktop/di/` using `kotlin.test`.
|
||||
- [x] Initialize Koin application.
|
||||
- [x] Include `desktopModule()`, `desktopPlatformModule()`, and `desktopPlatformStubsModule()`.
|
||||
- [x] Call `checkModules()` inside the test and ensure it fails if there are missing interfaces.
|
||||
- [x] Task: Implement to Pass Tests: Add any missing stubs or correct module includes in `desktopPlatformStubsModule()` to ensure the basic Koin graph resolves.
|
||||
- [x] Task: Conductor - User Manual Verification 'Phase 1: Setup KSP for Desktop and Test Scaffolding' (Protocol in workflow.md)
|
||||
|
||||
## Phase 2: Auto-wire ViewModels and Clean Up
|
||||
- [x] Task: Refactor: Remove manual `viewModel { ... }` blocks from `DesktopKoinModule.kt` (if any are present).
|
||||
- [x] Task: Implement: Ensure the desktop build configuration (`desktop/build.gradle.kts`) correctly includes the KSP-generated Koin modules and that KSP targets the JVM platform.
|
||||
- [x] Task: Implement to Pass Tests: Verify that running `./gradlew :desktop:test` succeeds and that `DesktopKoinTest.kt` validates the new KSP-wired graph.
|
||||
- [x] Task: Conductor - User Manual Verification 'Phase 2: Auto-wire ViewModels and Clean Up' (Protocol in workflow.md)
|
||||
25
conductor/archive/desktop_di_autowiring_20260313/spec.md
Normal file
25
conductor/archive/desktop_di_autowiring_20260313/spec.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Specification: Desktop DI Auto-Wiring and Validation
|
||||
|
||||
## Overview
|
||||
This track addresses immediate architecture health priorities for the Desktop KMP target:
|
||||
1. **Desktop Koin `checkModules()` test:** Add a compile-time/test-time validation test to ensure Desktop DI bindings resolve correctly and catch missing interfaces early.
|
||||
2. **Auto-wire Desktop ViewModels:** Configure KSP to generate Koin modules for ViewModels annotated with `@KoinViewModel` in the JVM target, eliminating the need for manual ViewModel wiring in `DesktopKoinModule`.
|
||||
|
||||
## Functional Requirements
|
||||
- **KSP Configuration:** Update the `meshtastic.koin` (or equivalent) convention plugin to apply KSP and Koin annotations processing to the `jvmMain` (Desktop) target.
|
||||
- **ViewModel Auto-Wiring:** Remove all manual `viewModel { ... }` definitions in `DesktopKoinModule` and ensure they are successfully replaced by the KSP-generated Koin modules.
|
||||
- **DI Validation Test:** Implement a new test file (e.g., `DesktopKoinTest.kt`) in `desktop/src/test/kotlin/org/meshtastic/desktop/di/` using `kotlin.test`.
|
||||
- **Test Scope:** The `checkModules()` test must include and validate all active Desktop Koin modules, including `desktopModule()`, `desktopPlatformModule()`, `desktopPlatformStubsModule()`, and any KSP-generated modules.
|
||||
|
||||
## Non-Functional Requirements
|
||||
- **Build Performance:** The addition of KSP to the JVM target should not unnecessarily degrade build times. Cacheability must be maintained.
|
||||
- **Style:** Adhere strictly to the project's existing Kotlin code style and Koin best practices.
|
||||
|
||||
## Acceptance Criteria
|
||||
- [ ] Running `./gradlew :desktop:test` executes the new `checkModules()` test successfully.
|
||||
- [ ] No manual ViewModel definitions remain in `DesktopKoinModule` for shared ViewModels (they are auto-wired).
|
||||
- [ ] If a dependency is missing from the Desktop DI graph, the `checkModules()` test fails explicitly.
|
||||
|
||||
## Out of Scope
|
||||
- Migrating other platforms (Android, iOS) DI implementations.
|
||||
- Refactoring the internal logic of the ViewModels themselves.
|
||||
Loading…
Add table
Add a link
Reference in a new issue