Skip to content

Add shared wearable payload contracts and mark Phase 1 progress#1

Merged
c0d3rb4b4 merged 2 commits into
mainfrom
codex/implement-next-phase-of-wearable-app
Feb 21, 2026
Merged

Add shared wearable payload contracts and mark Phase 1 progress#1
c0d3rb4b4 merged 2 commits into
mainfrom
codex/implement-next-phase-of-wearable-app

Conversation

@c0d3rb4b4
Copy link
Copy Markdown
Owner

Motivation

  • Establish a single, validated contract layer for phone<->watch payloads so subsequent phases can adopt a canonical shape for live and preview render state.
  • Close gaps in the implementation plan by recording completed Phase 1 work and any remaining integration gaps to keep team alignment and reduce later rework.

Description

  • Added packages/shared/src/wearable.ts with LiveRenderPayloadV1, PreviewRenderPayloadV1, the discriminated union WearRenderPayloadV1, runtime sanitizers (sanitizeLiveRenderPayloadV1, sanitizePreviewRenderPayloadV1, sanitizeWearRenderPayloadV1), numeric clamps for normalized fields, and a createSunOnlyLivePayload helper.
  • Exported the wearable surface from the shared package entrypoint by updating packages/shared/src/index.ts to export * from "./wearable".
  • Added unit tests in packages/shared/tests/wearable.payload.test.ts that cover mode discrimination, normalized value clamping, and invalid-payload rejection.
  • Updated documents/wearable-companion-implementation-plan.md to mark Phase 1 checklist items complete, add Phase 1 implementation notes, and capture the current integration gap that phone/watch runtime adoption remains pending.

Testing

  • Ran typecheck for the shared package with pnpm --filter @eclipse-timer/shared typecheck and it succeeded.
  • Ran linter for the shared package with pnpm --filter @eclipse-timer/shared lint and it reported no issues.
  • Ran unit tests for the shared package with pnpm --filter @eclipse-timer/shared test and all tests passed (1 test file, 3 tests).

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ee9d6281e

ℹ️ 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".

Comment thread packages/shared/src/wearable.ts Outdated
Comment on lines +15 to +16
showMoon: boolean;
moon?: LiveMoonGeometryV1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require moon geometry when showMoon is true

LiveRenderPayloadV1 currently permits { showMoon: true } without a moon object, because showMoon is a plain boolean and moon is optional. That weakens the shared contract this commit is introducing: producers can pass type-checking while emitting an internally inconsistent live payload, and downstream sanitization will then drop it as invalid (or renderers may assume moon data exists and fail). Model this as a discriminated union (showMoon: false without moon vs showMoon: true with required moon) so the invariant is enforced at compile time.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex address that feedback

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex address that feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Addressed the review feedback by changing LiveRenderPayloadV1 to a discriminated union so showMoon: true now requires moon, while showMoon: false disallows it (moon?: never). This enforces the invariant at compile time in the shared contract. packages/shared/src/wearable.tsL9-L25
  • Added a regression assertion that sanitizeWearRenderPayloadV1 rejects a live payload where showMoon is true but moon is missing, keeping runtime validation aligned with the stricter type contract. packages/shared/tests/wearable.payload.test.tsL103-L112
  • Committed the change on branch work (71be26c) and created a follow-up PR message via make_pr summarizing what changed, why, and how to test.

Testing

  • pnpm --filter @eclipse-timer/shared test
  • pnpm --filter @eclipse-timer/shared typecheck
  • pnpm --filter @eclipse-timer/shared lint
  • ⚠️ python - <<'PY'\nimport urllib.request\nurl='https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions'\nwith urllib.request.urlopen(url, timeout=10) as r:\n print('fetched', r.status, 'bytes', len(r.read(2000)))\nPY (network proxy returned 403 Forbidden in this environment)

View task →

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Updated LiveRenderPayloadV1 to a discriminated union so showMoon: true now requires a moon geometry object at the type level, while showMoon: false remains the sun-only shape. This enforces the invariant at compile time as requested in review feedback. packages/shared/src/wearable.tsL9-L24
  • Added a regression test case to ensure runtime sanitization rejects a live payload that sets showMoon: true but omits moon, protecting against inconsistent external input. packages/shared/tests/wearable.payload.test.tsL79-L115

Testing

  • pnpm --filter @eclipse-timer/shared test
  • pnpm --filter @eclipse-timer/shared typecheck

Committed on the current branch with message: Tighten live wearable moon payload contract (commit 57b809a), and I also created the follow-up PR via the make_pr tool.

View task →

@c0d3rb4b4 c0d3rb4b4 merged commit b1c1ab4 into main Feb 21, 2026
1 check passed
@c0d3rb4b4 c0d3rb4b4 deleted the codex/implement-next-phase-of-wearable-app branch February 26, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant