Skip to content

Conform thread message types to the registry (location + battery) - #46

Open
ikidnapmyself wants to merge 6 commits into
feature/expo-sdk-upgradefrom
feature/thread-message-types
Open

Conform thread message types to the registry (location + battery)#46
ikidnapmyself wants to merge 6 commits into
feature/expo-sdk-upgradefrom
feature/thread-message-types

Conversation

@ikidnapmyself

Copy link
Copy Markdown
Collaborator

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 builders buildLocation(lat, lng) and buildBatteryMetric(value) returning the exact canonical bodies, validating only what the registry schema/constraints require (lat/lng ranges; battery_level → percent).
  • LocationComponent → posts { type: 'location', version: '1.0', payload: { lat, lng } } (was the raw expo-location object).
  • BatteryComponent → posts { type: 'metric', version: '1.0', payload: { quantity: 'battery_level', value, unit: 'percent' } } (was { battery }).
  • MessageScreen — removed the non-conforming "Random Numbers" test button and its now-dead imports.

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.md

Test Plan

  • node services/messageTypes.test.cjs — valid location/metric deep-equal the canonical objects; out-of-range/non-number inputs throw
  • All touched files parse under babel-preset-expo
  • Drive the thread screen: tap Location + Battery, confirm POST bodies are canonical {type,version,payload} and the Random Numbers button is gone

Stacked on #45 (base: feature/expo-sdk-upgrade).

🤖 Generated with Claude Code

ikidnapmyself and others added 6 commits July 17, 2026 22:52
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>
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