mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-27 18:49:17 +01:00
A finished workout's record now lands in a local crdt log (workout_log.json) before any network call. Every sync tick pushes that log, so a failed or unconfigured push goes out with the next tick (home open, app resume, a 5-minute WorkoutResync retry). The re-push carries the same record and clock; the PC credits once per type:date anyway. Every tick and every live history read merges what it pulled into the same log, so PC records stay readable offline and after a restart. History shows local rows plus cached synced rows at once, then refreshes from the live read in the background. Ticks run one at a time, each cut off after 2 min so a hung request cannot block the queue. Bug-class-check: stronglift_replacement/workout_app/test/services/workout_sync_offline_test.dart, test/screens/workout_finish_keeps_record_test.dart, test/screens/history_offline_test.dart Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.5 KiB
3.5 KiB
Workout App Context
Current Task
Implementing design_v2.md improvements.
Key Decisions
- Active session persisted to SQLite on every tap so force-kill is safe
- Back button: PopScope is still present and pins the route in lock mode (workout_screen.dart) — the older "PopScope removed" note here was wrong
- Auto-resume: HomeScreen auto-navigates to workout on first load if session exists
- Break timing is wall-clock (
BreakClock), never a tick counter: Android throttles and Doze suspends timers in a backgrounded isolate - A
flutter_foreground_taskservice owns the deadline for the whole workout and shows the status-bar notification; notification presses go through a durable prefs queue, never straight into sqflite (the CRDT sync layer owns that database's ordering) - Workout sync is offline-first:
pushwrites its record to the local log (workout_log_store.dart,workout_log.jsonbesidesync_state.json) before any network call; every tick pushes that log (so a failed push goes out with the next one: home open, resume,WorkoutResynctimer) and keeps what it pulled. History shows local + cached rows at once, then the live read.
GPS runs (foundation, 2026-11-10)
- The app records one mode: every GPS activity is a run (25 km/h jump cap,
Sport="Running",_Running.tcx); the PC credits all with one rule. No run/walk toggle.decodeTcxstill reads old_Walking.tcximports. Optional pace target (pace_band.dart, pickerrun_pace_picker.dart); idle map follows the user's fix (idle_location.dart, display-only); location refused = no map and no start, only the red icon. The app uploads a TCX the PC credits unchanged. Contract = the PC parser, pinned byscreen_locker/tests/fixtures/run_tcx/(Darttest/services/tcx_golden_fixture_test.dart<-> pytestscreen_locker/tests/test_run_tcx_golden.py). Regenerate after a deliberate codec change:UPDATE_GOLDEN=1 flutter test test/services/tcx_golden_fixture_test.dart. - File name
RunnerUp_YYYY-MM-DD-HH-MM-SS_<Running>.tcx(historic:Walking), stamp in LOCAL time;<Id>/<Time>UTCZ; source tagkuhy workout_appinAuthor/Name+Creator/Name. - Trackpoints must be <= 30 s apart with cumulative
DistanceMeters, or the PC credits no moving time (lib/services/run_math.dartmirrors that rule). - Thresholds that decide credit live on the PC only, one rule for runs and
walks alike: a day's summed distance >= 3.5 km OR summed moving time >= 25 min (pairs
faster than 25 km/h count neither)
(
screen_locker/_walk_tcx.py); sport and file-name suffix never matter. - GPS sits behind
PositionSource(position_source*.dart); imported RunnerUp runs are stored withupload_state='never'(table CHECK). - RunnerUp history import (
runnerup_importer.dart): once, on app start, on the phone only (never the sandbox). PROPFINDs/RunnerUp/processed/, stores every.tcxasrunnerup_import/never, then PUTs the dotfile marker/RunnerUp/.workout_app_import.json={"completed_at": ISO-UTC, "count": N, "tcx_names": [...]}. The importer never PUTs a.tcx(a top-level one would be credited byrunnerup_watch.sh). A reinstall re-imports and rewrites the marker with a newcompleted_at: the PC must not use it as a clock. runs/run_pointstravel in backup.json (app-made runs only; the RunnerUp history comes back from the PC) and in the user export (version 3, all runs). Points are one compact JSON string per run.- dufs login:
dufs_credentials.dart(dufs_url,dufs_user,dufs_passwordin secure storage).