Successfully created and wrote to new file: /home/Messier82/.gemini/tmp/service-book/1b549615-dad6-48d4-84e2-57dc55fa166e/plans/issue-70-report-bug.md. Here is the updated code: # Implementation Plan: Phase 2 — Report a bug screen + Sentry User Feedback ## Objective Implement a user-facing "Report a bug or suggest a feature" screen that submits reports via Sentry's User Feedback API, following Material 3 Expressive guidelines, as per Issue #70. ## Key Files & Context - `app/src/main/java/com/servicebook/ui/navigation/Screen.kt` & `AppNavGraph.kt`: Navigation wiring. - `app/src/main/java/com/servicebook/ui/settings/SettingsScreen.kt`: Entry point for the screen. - `app/src/main/java/com/servicebook/ui/reportbug/ReportBugScreen.kt` & `ReportBugViewModel.kt`: New screen and viewmodel logic. - `app/src/main/java/com/servicebook/util/SentryWrapper.kt`: New seam to decouple Sentry static calls for testability. - Tests: JVM tests for ViewModel, Robolectric for Screen, Roborazzi for visual states, and Smoke tests. ## Implementation Steps ### 1. Sentry Integration Seam - Create `util/SentryWrapper.kt` containing a `SentryWrapper` interface and its default implementation. - Expose methods: `isEnabled()`, `captureFeedback(feedback: SentryFeedback, tags: Map)`, and `lazyInitSendAndClose(dsn: String, feedback: SentryFeedback, tags: Map)`. ### 2. View Model - Create `ReportBugViewModel.kt` following the MVI/event-driven pattern (`onEvent`, `StateFlow`). - Manage form fields: Bug/Suggestion type, Summary (max 80 chars), Description (max 2000 chars), Contact email, and Device info toggle. - Validate required fields to enable the Submit button. - Implement the submission flow: Construct `SentryFeedback` payload with appropriate device info tags. - Use `SentryWrapper` to submit. If telemetry is disabled, utilize lazy init with `BuildConfig.SENTRY_DSN`. - Implement retry logic (max 2 retries) and fallback to `ACTION_SENDTO` mailto intent upon exhaustion. ### 3. Screen UI - Create `ReportBugScreen.kt` adhering to Material 3 Expressive guidelines. - Wrap content in `MaterialExpressiveTheme`. - Implement `MediumFlexibleTopAppBar` with pinned scroll behavior. - Add form fields using `OutlinedTextField` and a connected `ButtonGroup` for the report type. - Display an expandable Expressive `Card` for device information. - Implement a bottom button row inside a `Surface` with Cancel (`TextButton`) and Submit (`Button` with `extraLarge` shape) actions. - Show Expressive `LoadingIndicator` during submission. ### 4. Navigation & Entry Point - Add `@Serializable object ReportBug : NavKey` in `Screen.kt`. - Add a new `ListItem` in `SettingsScreen.kt` for "Report a bug or suggest a feature" using the `BugReport` icon, routing to `ReportBug`. - Wire `ReportBug` to `ReportBugScreen` in `AppNavGraph.kt`. ## Verification & Testing - **ViewModel Tests:** Add `ReportBugViewModelTest.kt` verifying validation rules, state transitions, success/error retries, and mailto fallback, utilizing a mocked `SentryWrapper`. - **Screen Tests:** Add `ReportBugScreenTest.kt` verifying rendering of all fields, type toggle, Submit button enable/disable state, and loading state. - **Visual Tests:** Add Roborazzi screenshot tests for empty form, filled form, expanded device info, loading, and error states. - **Smoke Tests:** Append scenario S22 in `docs/plan-smoke-tests.md` and implement it in `app/src/androidTest/java/com/servicebook/SmokeTest.kt` to verify navigation to and rendering of `ReportBugScreen`.