fix: show error dialog on deserialization failure instead of silent fallback (Closes #79) #121

Merged
shahondin1624 merged 1 commits from feature/issue-79-deserialization-fallback-silently-replaces-user-data into main 2026-04-04 22:04:39 +02:00
Owner

Summary

  • When loading a saved character fails (corrupted data, schema change), the app now shows an error dialog instead of silently falling back to EXAMPLE_CHARACTER
  • Raw JSON is backed up to a separate storage key and displayed in the dialog for manual recovery
  • Added LoadStatus sealed class, LoadErrorDialog composable, and comprehensive tests

Changes

  • LoadStatus.kt (new): Sealed class representing load outcomes (Success, NoSavedData, Error)
  • LoadErrorDialog.kt (new): AlertDialog with error details, "Start Fresh" button, and expandable raw JSON view
  • CharacterViewModel.kt: Exposes loadStatus flow, backs up raw JSON on failure, adds acknowledgeLoadError() and tryRecoverFromJson() methods
  • App.kt: Observes loadStatus and shows LoadErrorDialog on error
  • TestTags.kt: Added load error dialog test tags
  • LoadErrorDialogTest.kt (new): 5 UI tests for dialog behavior
  • CharacterViewModelTest.kt: 3 new tests for LoadStatus model and recovery pattern

Acceptance Criteria

  • Failed deserialization shows an error dialog to the user
  • User can choose to start fresh or attempt recovery (view raw JSON)
  • The corrupted data is not silently overwritten (preserved as backup)
  • Error details are logged

Closes #79

## Summary - When loading a saved character fails (corrupted data, schema change), the app now shows an error dialog instead of silently falling back to EXAMPLE_CHARACTER - Raw JSON is backed up to a separate storage key and displayed in the dialog for manual recovery - Added `LoadStatus` sealed class, `LoadErrorDialog` composable, and comprehensive tests ## Changes - **LoadStatus.kt** (new): Sealed class representing load outcomes (Success, NoSavedData, Error) - **LoadErrorDialog.kt** (new): AlertDialog with error details, "Start Fresh" button, and expandable raw JSON view - **CharacterViewModel.kt**: Exposes `loadStatus` flow, backs up raw JSON on failure, adds `acknowledgeLoadError()` and `tryRecoverFromJson()` methods - **App.kt**: Observes `loadStatus` and shows `LoadErrorDialog` on error - **TestTags.kt**: Added load error dialog test tags - **LoadErrorDialogTest.kt** (new): 5 UI tests for dialog behavior - **CharacterViewModelTest.kt**: 3 new tests for LoadStatus model and recovery pattern ## Acceptance Criteria - [x] Failed deserialization shows an error dialog to the user - [x] User can choose to start fresh or attempt recovery (view raw JSON) - [x] The corrupted data is not silently overwritten (preserved as backup) - [x] Error details are logged Closes #79
shahondin1624 added 1 commit 2026-04-04 22:04:34 +02:00
When loading a saved character fails, the app now shows an error dialog
instead of silently replacing user data with EXAMPLE_CHARACTER. The raw
JSON is backed up and displayed for manual recovery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shahondin1624 merged commit d823c9b507 into main 2026-04-04 22:04:39 +02:00
shahondin1624 deleted branch feature/issue-79-deserialization-fallback-silently-replaces-user-data 2026-04-04 22:04:39 +02:00
Sign in to join this conversation.