Merged
Conversation
Store recipes in source units, tag with unitSystem, convert on frontend. - Add UnitSystem field to RecipeDef (us_customary/metric) - Fix extractFromURL: preserve source units instead of hardcoding US - Add detectUnitSystem() for JSON-LD ingredient scanning - Tag UnitSystem on all creation paths (chat, regen, fork, import) - Remove NormalizeMeasurements (replaced by frontend conversion) - Remove NormalizedAmount/NormalizedUnit/IsEstimated from Ingredient - Remove unitSystem param from PreviewFromURL (now auto-detected) - Add unit_system to AI tool schema and recipe response Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42c3958b6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Fix 1: Set fallback UnitSystem on ai.RecipeResult before recipeResultToRecipeDef, not after. The previous approach set it on the local recipeDef, but populateRecipeCoreFields rebuilds recipe.RecipeDef from the raw result, dropping the fallback when the AI omits unit_system. Fix 2: Replace string-contains metric detection with regex patterns that match compact tokens (250g, 100ml) in addition to spaced forms (250 g, 100 mL). Real-world JSON-LD frequently omits the space between quantity and unit, causing systematic misclassification of metric URLs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
unitSystem(us_customary/metric), convert on frontendextractFromURLto preserve source units instead of hardcoding US customarydetectUnitSystem()for JSON-LD ingredient scanningUnitSystemon all creation paths (chat, regen, fork, all import types)NormalizeMeasurementsinterface/implementation (replaced by frontend conversion)NormalizedAmount/NormalizedUnit/IsEstimatedfrom Ingredient modelunit_systemto AI tool schema and recipe API responseCompanion PR
Flutter app changes: https://github.com/windoze95/saltybytes-app/pull/new/feat/unit-system-strategy
Test plan
go test ./... -count=1— all tests passunit_system: "us_customary"in responseunit_system: "metric"in responseunitSystemset from user preferenceunitSystempreserved from cached dataunit_systemdefault to"us_customary"🤖 Generated with Claude Code