When the server-provided powersync URL is not reachable, try using $server-url/ps/.
This should help with self-hosted instances where SITE_URL points to localhost
or other similar misconfigurations
See https://github.com/wger-project/wger/issues/2432
Not copying an exercise that isn't there keeps the crash away, but gym
mode then holds a log with no exercise, which would bite the next reader.
The past logs widget already knows the exercise from the set config, so
pass it down to setLog, which assigns it through the exercise setter so
that exerciseId stays consistent.
The notifier test worked around the old behaviour by setting exerciseObj
on every fixture, with a comment explaining that copyWith needs it. That
was the bug, written down, so it's gone.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XzxNFoPMxsFPxHD3P2Ma3w
Log.exerciseObj was declared late and is only ever assigned when
hydrating the logs of a routine's sessions. Logs read from the database
are built through drift's row class and only carry exerciseId, so
copyWith threw a LateInitializationError when it unconditionally read
the field. Copying a past log in gym mode does exactly that.
Make the field nullable behind a getter that throws a descriptive error,
add exerciseObjOrNull for callers that legitimately handle logs straight
from the database, and only carry the exercise over when there is one.
Hydrating the exercise in watchLogsByExerciseDrift instead would mean
joining its translations, images, muscles and equipment for every log,
which most callers don't need.
The log page tests mocked the query with the test routine's logs, which
are hydrated, which is why this was never caught. They now return logs
without an exercise, like the real query does.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XzxNFoPMxsFPxHD3P2Ma3w
Server allows workout logs without a routine (free/ad-hoc logging),
but the app's Drift table declared routineId as non-nullable.
This caused a null check operator crash when PowerSync delivered
a row with routine_id = NULL.
Changes:
- WorkoutLogTable.routineId: integer() → integer().nullable()
- Log.routineId: late int → int?
- Log constructor: required this.routineId → this.routineId
- Log.toCompanion: handle null routineId with Value.absent()
Fixes#1250
- implement persistence for log scope and distinct settings
- refactor(logs): update pastExerciseLogsProvider to support custom scope and deduplication
- feat(ui): add log scope controls to StartPage and LogPage