Skip to content

Dashboard riverpod refactor#287

Open
dhruvi-16-me wants to merge 1 commit into
AOSSIE-Org:devfrom
dhruvi-16-me:dashboard-riverpod-refactor
Open

Dashboard riverpod refactor#287
dhruvi-16-me wants to merge 1 commit into
AOSSIE-Org:devfrom
dhruvi-16-me:dashboard-riverpod-refactor

Conversation

@dhruvi-16-me

@dhruvi-16-me dhruvi-16-me commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

This PR refactors the dashboard to use the existing Riverpod-based state management architecture by wiring DashboardScreen to DashboardController and DashboardState.

The goal of this refactor is to eliminate duplicated widget state, centralize dashboard workflow state in Riverpod, and improve consistency across the application without changing the existing user experience.

No new functionality or UI redesign is introduced in this PR. Existing dashboard behavior is preserved while reducing local state management.

Changes Made

Dashboard State Management

  • Converted DashboardScreen to a ConsumerStatefulWidget
  • Connected the dashboard to the existing dashboardControllerProvider
  • Replaced local widget state with DashboardState where appropriate

Riverpod Integration

Migrated dashboard workflow state to Riverpod:

  • Selected team
  • Selected time range

These values are now managed through the existing DashboardController, removing duplicate sources of truth.

Dashboard Behavior

  • Reused the existing DashboardController and DashboardState
  • Preserved the existing dashboard UI and interactions
  • Updated chart recomputation to use the current Riverpod time range, ensuring consistent behavior after refreshes
  • Preserved existing team switching and time range selection workflows

Responsive Improvements

  • Applied a small desktop-specific chart height adjustment for improved large-screen presentation
  • Mobile layout and behavior remain unchanged

Architecture Decisions

This PR intentionally builds on the existing Riverpod foundation instead of introducing additional abstractions.

Specifically:

  • Reused the existing DashboardController
  • Reused the existing DashboardState
  • Removed duplicated widget state
  • Kept widget-local state only for transient UI concerns (animations, derived chart data, loading state, etc.)
  • Preserved the existing dashboard architecture and visual design

Out of Scope

This PR intentionally does not include:

  • Dashboard repository abstraction
  • AsyncNotifier/DataController implementation
  • Dashboard data model extraction
  • Additional dashboard features
  • Responsive layout redesign
  • Navigation or routing changes
  • Localization or theme updates

Motivation

This refactor is part of the ongoing effort to migrate dashboard workflows to Riverpod-based state management, reducing duplicated state while making the dashboard easier to maintain and extend in future development.

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • New Features

    • Added responsive layout support with device-size breakpoints and helpers for mobile, tablet, and desktop views.
    • Introduced provider-driven state for dashboard filters, selected team, time range, and bottom navigation.
  • Bug Fixes

    • Improved dashboard state handling so charts and analytics update more consistently when switching time ranges or teams.
    • Added consistent cross-origin handling to backend endpoints, helping requests succeed more reliably from the app.
  • Refactor

    • Migrated app theme and dashboard screens to a more centralized state-management approach.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Failed to post review comments.

We encountered an issue with GitHub. Use @coderabbitai full review to retry the review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d7513cbe-9375-41de-ade6-c232a7de35a1

📥 Commits

Reviewing files that changed from the base of the PR and between 36cb2b8 and 4ef2972.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • lib/core/responsive/breakpoints.dart
  • lib/core/responsive/responsive_layout.dart
  • lib/core/responsive/responsive_utils.dart
  • lib/main.dart
  • lib/providers/dashboard/dashboard_controller.dart
  • lib/providers/dashboard/dashboard_controller.g.dart
  • lib/providers/dashboard/models/dashboard_state.dart
  • lib/providers/dashboard/models/dashboard_state.freezed.dart
  • lib/providers/dashboard/models/enums/dashboard_list_filter.dart
  • lib/providers/navigation_provider.dart
  • lib/providers/theme_provider.dart
  • lib/screens/home/dashboard_screen.dart
  • pubspec.yaml
  • supabase/functions/_shared/cors.ts
  • supabase/functions/fetch-transcript/index.ts
  • supabase/functions/generate-embeddings/index.ts
  • supabase/functions/get-embedding/index.ts
  • supabase/functions/start-bot/index.ts
  • supabase/functions/summarize-transcription/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.dart

⚙️ CodeRabbit configuration file

**/*.dart: Dart/Flutter Best Practices:

  • Ensure code follows Effective Dart style guide
  • Verify proper use of const constructors where applicable
  • Check for null safety compliance (? and !)
  • Review for proper state management patterns (Provider usage)
  • Ensure widget composition is appropriate and not overly complex
  • Check for memory leaks and proper disposal of resources
  • Verify proper error handling and exception catching
  • Ensure async/await is used correctly for Future handling
  • Review for performance issues (rebuilds, expensive operations)
  • Verify proper theming and design system adherence
  • Check for proper navigation and routing patterns

Security:

  • Sensitive data should never be logged or stored insecurely
  • Use secure storage for tokens and credentials (expo-secure-store or similar)
  • Verify API calls use HTTPS
  • Check for proper input validation

Files:

  • lib/providers/dashboard/models/enums/dashboard_list_filter.dart
  • lib/providers/navigation_provider.dart
  • lib/providers/dashboard/models/dashboard_state.dart
  • lib/providers/dashboard/dashboard_controller.dart
  • lib/core/responsive/breakpoints.dart
  • lib/core/responsive/responsive_utils.dart
  • lib/core/responsive/responsive_layout.dart
  • lib/providers/theme_provider.dart
  • lib/providers/dashboard/dashboard_controller.g.dart
  • lib/main.dart
  • lib/providers/dashboard/models/dashboard_state.freezed.dart
  • lib/screens/home/dashboard_screen.dart
🧠 Learnings (2)
📚 Learning: 2026-05-26T07:21:25.705Z
Learnt from: dev-2006-prt
Repo: AOSSIE-Org/Ell-ena PR: 255
File: pubspec.yaml:100-100
Timestamp: 2026-05-26T07:21:25.705Z
Learning: In this Flutter project, treat SUPABASE_URL, SUPABASE_ANON_KEY, OAUTH_REDIRECT_URL, and GEMINI_API_KEY as build-time configuration: read them using `String.fromEnvironment('<NAME>')` in Dart and ensure builds/run commands provide them via `--dart-define=<NAME>=...`. Do not use `flutter_dotenv` (e.g., `dotenv`/`.env` loading) and do not suggest restoring `flutter_dotenv` or packaging `.env` assets in `pubspec.yaml`.

Applied to files:

  • lib/providers/dashboard/models/enums/dashboard_list_filter.dart
  • lib/providers/navigation_provider.dart
  • lib/providers/dashboard/models/dashboard_state.dart
  • lib/providers/dashboard/dashboard_controller.dart
  • lib/core/responsive/breakpoints.dart
  • lib/core/responsive/responsive_utils.dart
  • lib/core/responsive/responsive_layout.dart
  • lib/providers/theme_provider.dart
  • lib/providers/dashboard/dashboard_controller.g.dart
  • lib/main.dart
  • lib/providers/dashboard/models/dashboard_state.freezed.dart
  • lib/screens/home/dashboard_screen.dart
📚 Learning: 2026-03-08T08:56:34.450Z
Learnt from: Subham2005x
Repo: AOSSIE-Org/Ell-ena PR: 206
File: pubspec.yaml:71-75
Timestamp: 2026-03-08T08:56:34.450Z
Learning: For Ell-ena's pubspec.yaml, lock notification-related dependencies to the maximum versions compatible with the project's Dart SDK constraint (>=2.17.0 <=3.8.1): flutter_local_notifications ^18.0.1, timezone ^0.9.4, flutter_timezone ^3.0.1. Upgrading flutter_local_notifications to >=19.0.0 requires timezone ^0.10.0 and a higher Dart SDK minimum, which conflicts with the current SDK constraint. Do not propose or apply upgrades to these packages unless the Dart SDK constraint is relaxed first.

Applied to files:

  • pubspec.yaml

Walkthrough

Adds shared responsive layout helpers, Riverpod-backed app and dashboard state, and shared CORS handling across Supabase edge functions.

Changes

Responsive layout primitives

Layer / File(s) Summary
Breakpoint contract and helpers
lib/core/responsive/breakpoints.dart, lib/core/responsive/responsive_utils.dart
Defines shared breakpoint constants, DeviceSize buckets, width-based classification helpers, and BuildContext extensions.
ResponsiveLayout widget
lib/core/responsive/responsive_layout.dart
Adds ResponsiveLayout, which chooses mobile, tablet, or desktop children from available width and falls back from tablet to desktop.

Riverpod app state and dashboard wiring

Layer / File(s) Summary
Provider scaffolding
pubspec.yaml, lib/providers/theme_provider.dart, lib/providers/navigation_provider.dart
Adds Riverpod/Freezed dependencies and defines the theme and bottom-navigation providers.
Dashboard state model
lib/providers/dashboard/models/enums/dashboard_list_filter.dart, lib/providers/dashboard/models/dashboard_state.dart, lib/providers/dashboard/models/dashboard_state.freezed.dart
Defines DashboardListFilter and the immutable DashboardState shape with generated copy and equality support.
Dashboard controller
lib/providers/dashboard/dashboard_controller.dart, lib/providers/dashboard/dashboard_controller.g.dart
Adds the keep-alive DashboardController notifier and generated provider wiring for dashboard state updates.
App bootstrap
lib/main.dart
Wraps the app in ProviderScope, overrides themeControllerProvider, and reads theme mode through Riverpod in MyApp.
Dashboard screen
lib/screens/home/dashboard_screen.dart
Converts DashboardScreen to ConsumerStatefulWidget, reads dashboard state from dashboardControllerProvider, and recomputes chart data from the selected time range.

Supabase CORS handling

Layer / File(s) Summary
Shared CORS helper
supabase/functions/_shared/cors.ts
Exports shared CORS headers and a helper that short-circuits OPTIONS requests with an ok response.
Transcript handlers
supabase/functions/fetch-transcript/index.ts, supabase/functions/summarize-transcription/index.ts
Imports the shared CORS helper in the transcript and summarization functions, returns early on preflight, and adds CORS headers to their JSON responses.
Embedding handlers
supabase/functions/generate-embeddings/index.ts, supabase/functions/get-embedding/index.ts
Replaces inline preflight handling in the embedding functions with the shared helper and shared CORS headers.
Bot startup handler
supabase/functions/start-bot/index.ts
Uses the shared CORS helper in start-bot and adds CORS headers to its validation, success, and error responses.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • AOSSIE-Org/Ell-ena#271: Adds related responsive modules and Riverpod wiring that the current PR builds on.
  • AOSSIE-Org/Ell-ena#23: Also updates lib/screens/home/dashboard_screen.dart around team selection and chart/time-range behavior.
  • AOSSIE-Org/Ell-ena#24: Also touches the Supabase edge-function flow used by the current shared CORS changes.

Suggested labels

Dart/Flutter

Suggested reviewers

  • SharkyBytes
  • M4dhav

Poem

A rabbit hopped by with a joyful thump,
through breakpoints, providers, and CORS in a jump.
The dashboard blinked, the headers danced bright,
and carrots were compiled in the moonlit night. 🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: refactoring dashboard state management to Riverpod.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dhruvi-16-me dhruvi-16-me changed the base branch from main to dev June 26, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant