BUG: Daily activity completions are not saved to Supabase, progress resets on navigation
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Riproduci il flusso di navigazione, quindi segui toggleTaskCompletion() in task_provider.dart e le relative chiamate a updateActivityCompletion(). Leggi daily_activities_screen.dart, in particolare il fallback commentato e il comportamento all’uscita dalla schermata. È completato quando le modifiche alle caselle di controllo raggiungono la tabella daily_activity_logs e rimangono selezionate dopo la navigazione, il cambio di data o il riavvio dell’app.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Dart
- Stelle
- 30
- Fork
- 49
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AOSSIE-Org/NeuroTrack
-
fix(therapist): Method marked @override does not override any inherited methodForse già presa @Muneerali199 l’ha presa 252 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AOSSIE-Org/NeuroTrack#198 ·
-
fix: Don't use BuildContext across async gaps (use_build_context_synchronously)Forse già presa @Muneerali199 l’ha presa 252 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AOSSIE-Org/NeuroTrack#197 ·
-
fix(patient): Remove unused and duplicate imports across patient appForse già presa @Muneerali199 l’ha presa 252 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AOSSIE-Org/NeuroTrack#195 ·
-
BUG: Therapy details save button has no loading guard, allowing duplicate submissions that inflate patient regression reportsForse già presa @Varadraj75 l’ha presa 215 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
AOSSIE-Org/NeuroTrack#221 ·
-
BUG: Appointment booking ignores selected time slot, every appointment saved at midnight to SupabaseForse già presa @Varadraj75 l’ha presa 220 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
AOSSIE-Org/NeuroTrack#219 ·
Tutte le issue di AOSSIE-Org/NeuroTrack
Issue simili
-
Drop the decision-issue rule from ARCHITECTURE.mdForse già presa @abianche l’ha presa oggi. Apertachore
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 61/100
I maintainer di solito rispondono entro 1 giorno
-
duration: tiny priority: low type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
duobaseio/forui#1249 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Off-by-one error in CharacterRange.length excludes end characters ('z', 'Z', '9', 'ÿ')Forse già presa @TimelordLeo l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug] Missing Simplified Chinese translation for 'balance' and 'lowest' balancer outbound namesApertabug from-telegram platform:android version:v5.9.15
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
hiddify/hiddify-app#2655 ·
I maintainer di solito rispondono entro 1 giorno