Files
chanora/docs/superpowers/plans/2026-05-29-state-sync-ui-settings-validation.md
T

3.9 KiB

State Sync and UI Settings Validation Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Complete validation-backed state-sync evidence and UI settings persistence while updating DV documents.

Architecture: State reducer work stays in crates/chanora_state/src/lib.rs with Rust unit tests. UI settings persistence stays in apps/chanora_flutter/lib/services/ui_preferences_service.dart with Flutter service tests; app-level theme application is wired in apps/chanora_flutter/lib/main.dart only if needed by the persisted setting.

Tech Stack: Rust/cargo tests, Flutter/Dart, shared_preferences, Markdown documentation.


Task 1: State Reducer Validation

Files:

  • Modify: crates/chanora_state/src/lib.rs

  • Step 1: Write failing regression test

Add channel_delete_removes_clients_in_deleted_channel proving channel deletion removes clients assigned to that channel and emits client-removal deltas before the channel-removal delta.

  • Step 2: Verify RED

Run: cargo test -p chanora_state channel_delete_removes_clients_in_deleted_channel --locked

Expected: FAIL because deleted-channel clients remain in state.

  • Step 3: Implement minimal reducer fix

In StateEvent::ChannelDeleted, collect clients whose client.channel == id, remove them from clients and client_order, then emit deterministic ClientRemoved deltas before ChannelRemoved.

  • Step 4: Verify GREEN

Run: cargo test -p chanora_state channel_delete_removes_clients_in_deleted_channel --locked

Expected: PASS.

  • Step 5: Run full state crate tests

Run: cargo test -p chanora_state --locked

Expected: all state crate tests pass.

Task 2: UI Settings Persistence

Files:

  • Modify: apps/chanora_flutter/lib/services/ui_preferences_service.dart

  • Modify: apps/chanora_flutter/test/services/ui_preferences_service_test.dart

  • Modify: apps/chanora_flutter/lib/main.dart

  • Step 1: Add failing tests for theme persistence

Add tests for default system theme mode, saving dark, saving light, and invalid stored value fallback to system.

  • Step 2: Verify RED

Run: flutter test test/services/ui_preferences_service_test.dart

Expected: FAIL because UiThemeMode, themeMode, and saveThemeMode do not exist.

  • Step 3: Implement minimal service changes

Add UiThemeMode, UiSettings.themeMode, persisted key ui.theme_mode, and saveThemeMode.

  • Step 4: Verify GREEN

Run: flutter test test/services/ui_preferences_service_test.dart

Expected: PASS.

  • Step 5: Wire app theme mode

Make ChanoraApp load persisted theme mode and pass themeMode into MaterialApp.

  • Step 6: Run focused Flutter tests

Run: flutter test test/services/ui_preferences_service_test.dart

Expected: PASS.

Task 3: Documentation Updates

Files:

  • Modify: docs/implementation-status-2026-05-28.md

  • Modify: docs/release/dv-waiver-register.md

  • Modify: docs/verification/swe4-unit-verification-plan.md

  • Modify: docs/verification/swe6-software-verification-plan.md

  • Modify: docs/architecture/sdd.md

  • Step 1: Update implementation status

Mark chanora_state scaffold statement as superseded by reducer implementation/tests and mark UI settings persistence implemented for SharedPreferences scope.

  • Step 2: Update waiver and verification docs

Record reducer evidence and leave event replay as the remaining P1 state-sync gap.

  • Step 3: Verify docs

Run sentinel-language scan over edited docs.


Self-Review

  • Spec coverage: covers reducer evidence, UI settings persistence, and document updates.
  • Placeholder scan: plan contains no incomplete implementation instructions.
  • Type consistency: UiThemeMode, themeMode, and saveThemeMode names are used consistently.