Repository navigation
Store the units preference on the account, and tell the coach - #12
Merged
Merged
Conversation
Metric / imperial lived in the dashboard's localStorage, so the phone and the coach could not see it: the app kept its own copy, and the coach kept authoring kilometers for a runner who reads miles. `users.units` holds it now, behind `GET/PUT /api/me/units`. NULL means never chosen, which is deliberately not the same as metric: the phone defaults from the device's region and needs to tell the two apart. The coach reads it from `get_plan_context`, the call it already makes first in every conversation, as `units` plus a `units_hint` saying how to talk and how to author distance goals. It can't go in the MCP's instructions: those are fixed per server, not per athlete. Display only. Everything stored and sent stays metric.
The Settings toggle wrote to localStorage only. It now saves to /api/me/units as well, and the dashboard reads the account's choice whenever a session appears, so it is the same in every browser and the same one the phone and the coach see. localStorage stays as a cache so the first paint is in the right units. A choice made in a browser before this change is handed to the server once, if the account has none yet. The cache is cleared on sign-out so it isn't handed to the next person who signs in on the same browser.
The coach reads the preference but has no tool to set it. Say so, and say where the athlete can, so a request to switch units gets a useful answer and not a promise the coach can't keep.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Metric / imperial lived in the dashboard's localStorage (#9), so the phone and the coach could not see it. The app kept its own copy, and the coach kept authoring kilometers for a runner who reads miles.
What changes
users.units(migrationc9d0e1f2a3b4) behindGET/PUT /api/me/units. The value ismetric,imperialornull.nullmeans never chosen and is deliberately not the same as metric: the iOS app defaults from the phone's region and has to be able to tell the two apart. Unknown values are a 422.get_plan_context, the call the coach makes first in every conversation, returnsunitsand aunits_hint. For an imperial athlete the hint says to talk in miles, author distance goals in miles with round figures, keep track reps in meters and keep speed alerts in m/s. It lives there and not in the MCP instructions because those are fixed per server, not per athlete.Display only, as before: everything stored and sent stays metric.
Rules worth reviewing
Checked
tests/test_units.py); the migration applies on a fresh database.Follow-ups, not in this PR