BUG: Daily activity completions are not saved to Supabase, progress resets on navigation
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
Reproduce the navigation flow, then trace toggleTaskCompletion() in task_provider.dart and its updateActivityCompletion() calls. Read daily_activities_screen.dart, especially the commented fallback and screen-exit behavior. Done means checkbox changes reach the daily_activity_logs table and remain checked after navigation, date changes, or an app restart.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
📌 Issue Overview
When a patient checks off daily activities as completed, the checkbox toggles only update local in-memory state and are never written to Supabase. All progress is silently lost the moment the user navigates away, switches dates, or restarts the app.
Three interacting defects cause this:
-
toggleTaskCompletion()intask_provider.dartonly mutates_allTasksin memory and callsnotifyListeners(). It never callsupdateActivityCompletion(). The method is markedasyncbut contains noawaitand is effectively synchronous. -
The only fallback save path was explicitly commented out in
daily_activities_screen.dart:
// context.read().updateActivityInBackground(); // TODO: Uncomment this when the backend is ready
The method updateActivityInBackground does not even exist on TaskProvider, it was never implemented.
updateActivityCompletion()is only called insidesetSelectedDate(), meaning the only time data is saved is when the user switches the date picker to a different day. If the user checks activities and presses back without changing dates, nothing is saved. This also introduces a race condition sincegetTodayActivities()is called immediately
after, potentially overwriting unsaved state with a fresh DB read.
The screen has no PopScope, no WillPopScope, no AppLifecycleObserver, and no
dispose() save logic. There is zero mechanism to flush pending changes on any form of exit.
🔍 Steps to Reproduce
- Log in as a patient who has daily activities assigned
- Navigate to Home → Daily Activities
- Wait for activities to load
- Check 2 or more activity checkboxes - observe they toggle visually
- Press the back arrow to return to home
- Navigate back to Daily Activities
- All checkboxes are unchecked, all progress is lost
- Alternatively: check activities, kill and restart the app, same result
🎯 Expected Behavior
Each checkbox toggle should persist the is_completed state to the daily_activity_logs table in Supabase immediately or on a short debounce. Navigating away and back should restore the previously checked state from the database.
🚨 Actual Behavior
No Supabase call is made on checkbox toggle. The in-memory state is discarded on navigation. The daily_activity_logs table never reflects actual patient completions, which means:
- The Reports screen always shows activities as incomplete
- Therapists see 0% completion for activities the patient believes they completed
- Patient therapy progress data is silently corrupted
📷 Screenshot
Not applicable. The bug is in data not written to Supabase, not visible in the UI.
💡 Suggested Improvements
task_provider.dart:
- Add a
Timer? _debounceTimerfield - In
toggleTaskCompletion(), after mutating_allTasks, start a 1.5s debounce timer that callsupdateActivityCompletion(_allTasks) - Add a
Future<void> saveAndFlush()method that cancels the timer and immediately
awaitsupdateActivityCompletion(_allTasks)for use on screen exit
daily_activities_screen.dart:
- Wrap the
Scaffoldin aPopScopewithonPopInvokedWithResultcallingtaskProvider.saveAndFlush()before allowing pop - Add
WidgetsBindingObserverand implementdidChangeAppLifecycleStateto callsaveAndFlush()onAppLifecycleState.paused - Remove the commented-out
updateActivityInBackgroundline
supabase_patient_repository.dart:
- No changes needed.
updateActivityCompletion()is correctly implemented, it is just never called from the right place
Record
- I agree to follow this project's Code of Conduct
- I want to work on this issue
- Dominant language
- Dart
- Stars
- 30
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/NeuroTrack
-
fix(therapist): Method marked @override does not override any inherited methodPossibly taken @Muneerali199 claimed this 259 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AOSSIE-Org/NeuroTrack#198 ·
-
fix: Don't use BuildContext across async gaps (use_build_context_synchronously)Possibly taken @Muneerali199 claimed this 259 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AOSSIE-Org/NeuroTrack#197 ·
-
fix(patient): Remove unused and duplicate imports across patient appPossibly taken @Muneerali199 claimed this 259 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AOSSIE-Org/NeuroTrack#195 ·
-
BUG: Therapy details save button has no loading guard, allowing duplicate submissions that inflate patient regression reportsPossibly taken @Varadraj75 claimed this 222 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 68/100
AOSSIE-Org/NeuroTrack#221 ·
-
BUG: Appointment booking ignores selected time slot, every appointment saved at midnight to SupabasePossibly taken @Varadraj75 claimed this 227 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
AOSSIE-Org/NeuroTrack#219 ·
All issues in AOSSIE-Org/NeuroTrack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Anxcye/anx-reader#1024 ·
-
[cloud_functions]: Apple platforms ignore custom domains passed as regionPossibly taken @ragavendranbala-TSL claimed this today. OpenNeeds Attention platform: ios platform: macos plugin: functions type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/flutterfire#19015 · 2 comments ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RevenueCat/purchases-flutter#2048 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hajisensai/Fushi#4543 · 3 comments ·
Maintainers usually reply within 1 day
-
[video_player] _updatePosition sets isCompleted=true after 500ms when duration is Duration.zeroOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day