Conform thread message types to the registry (location + battery) - #46
Open
ikidnapmyself wants to merge 6 commits into
Open
Conform thread message types to the registry (location + battery)#46ikidnapmyself wants to merge 6 commits into
ikidnapmyself wants to merge 6 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <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
Makes the thread screen's message bodies conform to the Swinn message-type registry (
{ type, version, payload }, payload validated against the type schema), replacing ad-hoc shapes. Minimal scope: location and battery; other types are out of scope.services/messageTypes.js— new pure buildersbuildLocation(lat, lng)andbuildBatteryMetric(value)returning the exact canonical bodies, validating only what the registry schema/constraints require (lat/lng ranges;battery_level → percent).{ type: 'location', version: '1.0', payload: { lat, lng } }(was the raw expo-location object).{ type: 'metric', version: '1.0', payload: { quantity: 'battery_level', value, unit: 'percent' } }(was{ battery }).Builders are the single choke point; both composers route through them under a
try/catch, so a malformed reading never reaches the API. Renderer is intentionally untouched (still shows the canonical JSON) — renderer cards for all 7 types are a follow-up.Design:
docs/plans/2026-07-17-thread-message-types-design.mdTest Plan
node services/messageTypes.test.cjs— valid location/metric deep-equal the canonical objects; out-of-range/non-number inputs throwbabel-preset-expo{type,version,payload}and the Random Numbers button is gone🤖 Generated with Claude Code