Jason
80dd6e9381
refactor(api): unify AppType parsing with FromStr trait
BREAKING CHANGE: Remove support for legacy app_type/appType parameters.
All Tauri commands now accept only the 'app' parameter (values: "claude" or "codex").
Invalid app values will return localized error messages with allowed values.
This commit addresses code duplication and improves error handling:
- Consolidate AppType parsing into FromStr trait implementation
* Eliminates duplicate parse_app() functions across 3 command modules
* Provides single source of truth for app type validation
* Enables idiomatic Rust .parse::<AppType>() syntax
- Enhance error messages with localization
* Return bilingual error messages (Chinese + English)
* Include list of allowed values in error responses
* Use structured AppError::localized for better categorization
- Add input normalization
* Case-insensitive matching ("CLAUDE" → AppType::Claude)
* Automatic whitespace trimming (" codex \n" → AppType::Codex)
* Improves API robustness against user input variations
- Introduce comprehensive unit tests
* Test valid inputs with case variations
* Test whitespace handling
* Verify error message content and localization
* 100% coverage of from_str logic
- Update documentation
* Add CHANGELOG entry marking breaking change
* Update README with accurate architecture description
* Revise REFACTORING_MASTER_PLAN with migration examples
* Remove all legacy app_type/appType references
Code Quality Metrics:
- Lines removed: 27 (duplicate code)
- Lines added: 52 (including tests and docs)
- Code duplication: 3 → 0 instances
- Test coverage: 0% → 100% for AppType parsing
2025-10-30 12:33:35 +08:00
..
2025-10-28 15:58:04 +08:00
2025-10-16 13:02:38 +08:00
2025-10-30 12:33:35 +08:00
2025-10-16 09:38:41 +08:00
2025-10-12 22:27:02 +08:00
2025-10-25 10:08:06 +08:00