Skip to content

workout: treadmill ruck, with the distance typed off the belt - #1061

Draft
infrabill wants to merge 19 commits into
OpenStrap:mainfrom
infrabill:bt-rucking-indoor
Draft

infrabill wants to merge 19 commits into
OpenStrap:mainfrom
infrabill:bt-rucking-indoor

Conversation

@infrabill

@infrabill infrabill commented Dec 4, 2026 •

Copy link
Copy Markdown

Stacked on #1060. This branch contains that PR's commits plus its own, so until #1060 merges the diff here shows both. Only "add a treadmill ruck, with the distance typed off the belt", a one-line guard in the merge that brought #1060's follow-ups in, and one fix for a distance typed on a live session are new. I'll merge main in and mark this ready once #1060 lands. Draft until then.

Adds Treadmill ruck: a ruck with no GPS, the same pack weight row as Rucking, and a distance the user types off the belt.

In this PR, on top of #1060
Schema v63 → v64: one nullable REAL column on sessions
kAlgoVersion no bump, no analytics output changes
Network none, so nothing for PRIVACY.md
Strings one new key in all eight languages, and a catalogue case in the six that translate activity names
Freeze goldens not regenerated
Devices used on my own iPhone with a WHOOP band; not run on Android

Why

A ruck on a treadmill has no route. Logged as Rucking it arms GPS indoors, where a fix wanders and the distance it adds up is not one anybody walked.

What

  • Treadmill ruck is its own entry, the way Treadmill sits beside Running and Indoor bike beside Cycling: no GPS, tracked by time and heart rate, with the same pack weight row as Rucking.
  • Distance is typed, not measured. The belt shows a distance and nothing in the app can measure one indoors, so the summary takes what the user reads off the machine.
  • It is stored in its own column (sessions.entered_distance_m, schema v63 → v64, nullable REAL, added with _addColumnIfMissing from the rung and from the open-time repair) and carried on the result as its own field, never as the measured route distance. It does not feed the hero, the splits, the share card or the VO2max estimate.
  • The card that shows it says where it came from ("Read off the treadmill, entered by you") and prints the pace it gives over the session's clock. It is empty until typed, and clearing it stores NULL.
  • A retime carries the column.
  • A typed distance is only put on screen for the session it was saved on.
  • A distance typed on the summary of a treadmill ruck that is still running (it is in the history list) is carried through the stop.
  • A treadmill ruck is exported to Apple Health and Health Connect as a walk, and counts steps on Treadmill's footing.

The freeze golden test drops the new column while it is NULL, with the pack weight columns from #1060; the goldens are untouched.

No network calls, so nothing for PRIVACY.md. No analytics output changes, so no kAlgoVersion bump.

Screenshots

Before: an indoor ruck had to be logged as Rucking (GPS armed indoors, a wandering route and a made-up distance) or as Treadmill (no pack weight). Tap an image for full size.

Activity list: Treadmill ruck under Cardio
Activity list: Treadmill ruck under Cardio
Setup: the same Pack weight row, and no Route row
Setup: the same Pack weight row, and no Route row
Summary before a distance is typed: a dash and no pace
Summary before a distance is typed: a dash and no pace
Typing what the belt showed
Typing what the belt showed
The typed distance and the pace it gives
The typed distance and the pace it gives
The same screens in the light theme
Activity list: Treadmill ruck under Cardio
Activity list: Treadmill ruck under Cardio
Setup: the same Pack weight row, and no Route row
Setup: the same Pack weight row, and no Route row
Summary before a distance is typed: a dash and no pace
Summary before a distance is typed: a dash and no pace
Typing what the belt showed
Typing what the belt showed
The typed distance and the pace it gives
The typed distance and the pace it gives

The images are drawn from the app's own screens by a widget driver, the way tool/guides/ does it (412×915 at 2.625, real fonts). They are not device captures. The data is synthetic: a 35 lb pack, a 180 lb body weight and a made-up 45-minute session with 2.5 mi typed in.

Change size

This PR's own part: git diff --numstat c87045a9...768ef976, against the head of #1060.

Area Files Added Removed
Screens, lib/ui2/ 3 177 1
Tests, test/ 6 164 6
Translations, lib/l10n/ 8 24 13
Storage and schema, lib/data/ 1 21 1
Activity-type lists in lib/ble, lib/compute, lib/health 3 5 0
Workout state, lib/state/ 1 2 0
Total 22 393 21

With #1060 included, the diff GitHub shows against main is 34 files, +1,329 / −26.

Risk and rollback

What it can touch outside a treadmill ruck

  • The migration runs once for every install when the database opens: one ALTER TABLE … ADD COLUMN, no backfill and no index.
  • stopWorkout copies entered_distance_m from the stored row into the row it writes, for every activity. It is NULL on every session that is not a treadmill ruck with a typed distance.
  • The typed distance is a separate field on the result and never stands in for the measured one, so no existing figure (hero, splits, share card, VO2max) can change.
  • The rest is additive: a catalogue entry, a gait step type, a health export case.

Rollback

Run locally, both ways this PR can be reverted. A v64 database written by this branch (a ruck, a treadmill ruck with a typed distance, and a run as a control) was opened and used by older code, then opened again by this branch. In both cases the older build opens it and loses nothing outside the new columns.

What the two runs showed

This PR reverted alone, #1060 kept (v64 opened by v63 code)

  • No error and no rebuild. user_version goes from 64 back to 63, and entered_distance_m and its value stay on disk.
  • The outdoor ruck draws in full, pack weight included. The treadmill ruck draws as a plain timed session titled "Treadmill Ruck" with the generic activity icon, with no pack weight row and no typed distance.
  • A retime replaces the row and drops entered_distance_m; the two weights survive it. Rating, the private flag and a type change leave all three alone.

Both PRs reverted (v64 opened by main at 9fa55d92)

Either way

  • LocalDb.exportDaysDb throws on the older build for any day holding a session, because it copies SELECT * rows into a file built with the older schema. Nothing in lib/ calls it outside its AppState wrapper.
  • Applying this PR again opens the file, runs the rung again without error and returns the version to 64, with the values intact except where a retime dropped them.
  • Not run: a device, a session still live at the moment of the revert, and the writes to Apple Health and Health Connect.

This PR can be reverted without #1060; the reverse is not true.

Strings

One new key (activityMachineDistanceHint) in all eight app_<code>.arb files, plus a ktreadmillruck case in each translated activityCatalogueName. That is six files: English and Thai translate none of the catalogue names. The non-English values are my best effort and have not been checked by native speakers.

Tests

Whole suite, flutter test --concurrency=1 under TZ=UTC, head against base:

Run Test files Passed Skipped Failed
This head, 768ef976 883 10,812 29 0
#1060 alone, c87045a9 883 10,806 29 0
Base: main at 9e8b816e, the commit merged into both 882 10,784 29 0

This PR adds 6 passing tests on top of #1060's 22, with the same number skipped and none failing in any of the three runs.

  • flutter analyze: no issues.
  • test/whoop_freeze_golden_test.dart and test/adapters/miscale_test.dart pass under TZ=UTC, Asia/Kolkata and America/New_York.
  • The workflows on this PR are still waiting for a maintainer's approval, so the numbers here are from my machine (macOS).
What the new tests cover, file by file
  • test/ui2_activity_test.dart: a treadmill ruck is a ruck with no route; a typed distance is its own figure, never the measured one; the distance field takes a distance, an empty field, and no more; a treadmill ruck offers its distance and pace appears with it.
  • test/manual_workout_repo_test.dart: retiming keeps the distance typed off the treadmill.
  • test/db_migration_ladder_test.dart: the v64 rung.
  • test/gait_step_types_test.dart.
  • test/app_state_workout_lifecycle_test.dart: a distance typed on the row while a treadmill ruck is live survives the stop.

On a device. A build with the treadmill ruck commit has been on my own iPhone with a WHOOP band for several days. The follow-ups merged in from #1060 are on the same phone and were checked there by hand (listed in #1060). The guard that shows a typed distance only for the session it was saved on has not been exercised on a device, and neither have the backpack icon or the fixes for a weight or distance entered on a live session. Not run on Android.

Summary by Sourcery

Add outdoor and treadmill rucking activities with per-session pack weights and a separately entered treadmill distance.

New Features:

  • Add Rucking and Treadmill ruck activity types, with pack-weight tracking and treadmill distance entry on session summaries.
  • Allow users to edit and clear treadmill-entered distance, with pace calculated from the session duration.

Bug Fixes:

  • Preserve entered pack weight and treadmill distance when stopping, reconciling, or retiming sessions.
  • Keep VO₂ max estimates from being calculated or shown for sessions recorded under a carried load.
  • Prevent a failed session read during stop from overwriting the live workout.

Enhancements:

  • Include rucking activities in gait-step counting and map rucking activities to supported health-export categories.

Tests:

  • Add coverage for the new activity types, session fields, migrations, workout lifecycle, distance entry, and load-aware VO₂ max behavior.

Chores:

  • Add localized strings and activity catalogue translations for the new treadmill distance hint and activity name.

there was no rucking activity. a ruck had to be logged as a hike or a walk,
and the one number that defines it, the weight carried, had nowhere to go.

rucking is a route activity with gps, listed beside hiking and priced at the
compendium backpacking rate (17010, 7.0 met). that rate is flat, so it reads
the same for a light pack and a heavy one. no load-aware estimate is added
here; that is a metric and belongs in analytics.

the pack weight is asked for on the setup screen and stored on the session
(sessions.load_kg, schema v63), because it changes from one outing to the
next. the screen opens on the weight used last time, shown before start;
someone who has never entered one sees a dash, and a dash stores null. the
profile body weight the session started with is banked beside it (body_kg),
so the share of body weight on the summary describes that day and not
today's profile. the summary shows the pack weight where it can still be
corrected, since a forgotten or wrong one is only noticed afterwards.

putSession replaces the whole row, so stopWorkout carries both columns in the
row it writes, whichever way the session was ended, and a retime carries them
too.

two things follow from adding the type. rucking joins the gait step types on
hiking's footing: the same walk, arms free to swing. and a session that
carried weight is left out of the per-session vo2max estimate: that estimate
reads the split's speed as unloaded, so the same split under a pack would
bank a lower figure than the person has.

apple health and health connect have no rucking type, so a ruck is exported
as a hike. a whoop "hiking/rucking" import still lands as hiking.

the icon is a rucksack drawn for it on lucide's grid and stroke rules,
since lucide's only backpack is a school bag. it ships as a one-glyph
font (assets/fonts/EdgeIcons.ttf, built from the svg beside it by
tool/gen_edge_icons.py), because an activity's icon is an IconData
everywhere it is drawn, so no call site changes.

the whoop freeze golden snapshots every sessions column, so its test drops
the two new ones while they are null, the way it already drops
day_result.imported. a value there would be one the derive made up, and it
still fails. the goldens themselves are untouched.

Authored by : BT
a ruck on a treadmill has no route. logged as rucking it arms gps indoors,
where a fix wanders and the distance it adds up is not one anybody walked.
this adds the indoor ruck as its own entry, the way treadmill sits beside
running and indoor bike beside cycling: no gps, tracked by time and heart
rate, and the same pack weight.

the belt shows a distance and nothing in the app can measure one indoors, so
the summary takes what the user reads off the machine. it is stored in its own
column (sessions.entered_distance_m, schema v64) and carried on the result as
its own field, never as the measured route distance: it does not feed the
hero, the splits, the share card or the vo2max estimate. the card that shows
it says where it came from, and prints the pace it gives over the session's
clock. empty until typed; clearing it stores null.

a retime carries the column. a treadmill ruck is exported to apple health and
health connect as a walk, and counts steps on treadmill's footing.

the whoop freeze golden test drops the new column while it is null, with the
pack weight columns; the goldens are untouched.

Authored by : BT
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Add the nullable session column for machine-entered distance, include it in schema migration and open-time repair, and provide the narrow session update used to save or clear it.

  • lib/data/db.dart L1618-1625, L6366-6386, L17147-17165 (+2 small edits)

Data structures

Define the new activity categories and result fields that keep pack weight and machine-entered distance separate from measured route data.

  • lib/ble/live_step_runs.dart L68-71, L78-81
  • lib/gps/route_types.dart L23
  • lib/ui2/activity/catalogue.dart L104-114, L150-154, L167-171
  • lib/ui2/activity/summary.dart L321-370, L719-729, L957-978 (+4 small edits)

API

Expose the treadmill-ruck activity as walking and outdoor rucking as hiking to health platforms that lack a rucking activity type.

  • lib/health/health_export.dart L2197-2198, L2231-2232

Uses of the API

Load the saved pack weight and typed distance into past-session results so the summary can display the values belonging to that session.

  • lib/ui2/screens/workout_screen.dart L1855-1863

Implementation

Preserve the new session values through manual-row reconstruction, workout stop and stale-session reconciliation, while excluding carried-load sessions from unloaded VO₂max estimates.

  • lib/compute/manual_session.dart L640-642
  • lib/data/local_repository_impl.dart L2452-2458, L2487-2492, L3599-3608 (+1 small edits)
  • lib/state/workout_controller.dart L923-933, L976-993, L1067-1091 (+2 small edits)

UI

Add setup and summary controls for carried weight and treadmill distance, including validation, unit conversion, pace display, and session-scoped saves.

  • lib/ui2/activity/setup.dart L104-108, L160-165, L319-331 (+3 small edits)
  • lib/ui2/activity/summary.dart L1400-1587, L2000-2007

Configuration

Register the remembered pack-weight preference and add the new activity and distance-hint strings across the supported locales.

  • lib/data/backup_extras.dart L230
  • lib/l10n/app_de.arb L2844, L4189-4192
  • lib/l10n/app_en.arb L18982-18999
  • lib/l10n/app_es.arb L3370, L4189-4192
  • lib/l10n/app_fr.arb L3243, L4189-4192
  • lib/l10n/app_hi.arb L3373, L4189-4192
  • lib/l10n/app_ru.arb L6116, L9532-9542
  • lib/l10n/app_th.arb L17697-17700
  • lib/l10n/app_zh.arb L3371, L4189-4192
  • lib/state/prefs.dart L159-161

Tests

Cover migration, activity classification, live-session persistence, typed-distance and pack-weight UI behavior, and the carried-load VO₂max exclusion.

  • test/app_state_workout_lifecycle_test.dart L73-81, L486-576, L631-665 (+1 small edits)
  • test/app_state_workout_reconcile_test.dart L14-15, L198-244
  • test/backup/settings_audit_guard_test.dart L31
  • test/db_migration_ladder_test.dart L1590-1639
  • test/ed2a_input_revision_test.dart L159
  • test/ed2b_checkpoints_test.dart L115-118, L155
  • test/gait_step_types_test.dart L110-113
  • test/manual_workout_repo_test.dart L281-320
  • test/ruck_pack_stepper_saving_test.dart L1-83
  • test/ui2_activity_test.dart L674-965
  • test/vo2max_session_test.dart L7, L120-221
  • test/whoop_freeze_golden_test.dart L181-183, L240-247

Other changes

Files not grouped.

  • lib/ui2/activity/live.dart L1197-1199

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…d live, remember only a real pack weight

a session recorded as a hike or a run banks a vo2max estimate. retyped to
a ruck, or given a pack weight afterwards, it kept showing that figure,
which was worked out as if nothing was carried. the estimate is now served
empty for a session that is a ruck or holds a weight, by the same check
the rescore uses to decide whether to bank one. the stored value stays, so
retyping it back serves it again. the rescore asks that check of the row
it re-read, not of the snapshot it started from.

stopWorkout swallowed a failed read of the session row and went on to
write without it, which could store an empty device family or drop a
weight the row already held. a failed read now gets the same handling as
a failed write: logged, the session kept live, the error rethrown, so the
stop can be retried. the existing "a stop whose write fails" test hides
the table, so it fails on this read first and covers the path. there is no
seam to fail the read alone and let the write through.

starting a ruck with the pack weight on the dash stored 0 as the weight
used last, so the next ruck opened on a dash. only a weight above zero is
remembered now.

the summary's pack weight stepper ignored a press that landed while the
last one was still saving, with no sign of it. it is dimmed and takes no
press until the save returns, a failed save hands it back, and the saved
weight is only put on screen for the session it was saved on.

Authored by : BT
…hown for the session it was saved on

Authored by : BT
…he write failing alone and the stepper mid-save

the read stopWorkout makes of the session row now rethrows. if a reset
wiped the store under that read, the session is already discarded and
there is nothing to keep live, so the catch checks for that first, the
way the code below the read always did.

the existing "a stop whose write fails" test hides the whole table, so
since the read became unconditional it fails on the read and no test
reached the write's own catch. a second test refuses inserts with a
trigger while the table still reads: the write alone keeps the session
live and the retry finishes it. there is still no seam to fail the read
and let the write through.

the pack weight stepper on the summary gets a test off a real database
with the write held open: dimmed, a second press not taken, then one
step on screen and in the row.

Authored by : BT
Authored by : BT
The app keeps to one icon family. The rucksack glyph, its font, the source drawing and the script that built it are gone, and pubspec.yaml is back to main's.

Authored by : BT
…mill ruck takes the same icon

Authored by : BT
It read the EdgeIcons entry from pubspec.yaml and looked the codepoint up in the .ttf. Every activity icon is Lucide again, so there is nothing left for it to check.

Authored by : BT
…stop

The row of a ruck still running is in the history list and its summary has the stepper, so the weight can be put right on the row before the session ends. The stop and the stale-row reconcile then wrote the setup draft's weight over it. The row is never older than the draft, so what the row holds stays and the draft only fills what it lacks.

Authored by : BT
… stop

The stop replaces the whole row and did not carry entered_distance_m, so a distance typed on the summary of a session still running (it is in the history list) was dropped when the session ended. The stop now carries what the row holds. The stale-row reconcile already spreads the row.

Authored by : BT
It is the profile weight the setup screen opened with, not one read when
the session ends.

Authored by : BT

This branch has not been deployed

No deployments
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