Skip to content

Add Cycling/Rest/Other entry types#21

Merged
aidmax merged 5 commits intomainfrom
claude/entry-types
Apr 22, 2026
Merged

Add Cycling/Rest/Other entry types#21
aidmax merged 5 commits intomainfrom
claude/entry-types

Conversation

@aidmax
Copy link
Copy Markdown
Owner

@aidmax aidmax commented Apr 22, 2026

Summary

  • Adds an entry-type selector (Cycling/Rest/Other) below the Date field, with per-type section visibility
  • New Rest Day section (Weight + Notes) and Activity section (Activity + Notes)
  • generateMarkdown split into three type-specific generators; cycling output is unchanged
  • Schema: goal/rpe/feel required for cycling only (enforced via superRefine); old drafts without entryType are migrated to cycling on restore
  • Recovery Metrics auto-expands when switching to Rest; Expand/Collapse All is scoped to currently visible sections

Markdown output

  • cycling: unchanged
  • rest: Rest Day marker + present-only recovery metrics (HRV, rMSSD, RHR, TR-LGT) + W: <kg> + bulleted notes
  • other: optional G: <activity> + bulleted notes; no metrics

Test plan

  • npm run check clean
  • npm run test:run — 92/92 passing (includes new schema + per-type markdown tests)
  • Manual: switch types; fill a Rest entry and copy markdown; fill an Other entry and copy markdown
  • Manual: existing draft (pre-entryType) restores as Cycling with no data loss
  • Manual: Clear Form resets to Cycling defaults

🤖 Generated with Claude Code

Introduces an entry-type selector so the app supports rest-day logging
(wellness metrics + free-form journal) and non-cycling activities
(MFR, yoga, strength, mobility) alongside the existing cycling form.
Cycling output is unchanged; rest and other entries get dedicated
markdown formats. Old drafts without entryType are migrated to cycling
on restore.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR adds cycling / rest / other entry types to the workout form, with per-type section visibility, two new form sections (Rest Day, Activity), and three type-specific markdown generators. Existing cycling output is unchanged; old localStorage drafts are migrated to cycling on restore. Schema enforcement uses superRefine to keep goal/rpe/feel required only for cycling entries, and 92 tests (including new schema and markdown tests) all pass.

Confidence Score: 5/5

Safe to merge — all findings are P2 style/cleanup suggestions with no impact on correctness or data integrity.

Both remaining comments are P2: dead null-checks in superRefine (Zod rejects null before superRefine runs) and test helpers being local copies instead of imports. Neither affects runtime behaviour, the existing cycling path is unchanged, backward-compat migration is in place, and 92 tests pass.

client/src/test/utils.test.ts — local copies of markdown helpers won't catch future divergence from production implementations.

Important Files Changed

Filename Overview
client/src/pages/home.tsx Adds entry-type selector UI, splits generateMarkdown into three type-specific generators, scopes expandAllOrCollapseAll to visible sections, adds Rest Day and Activity form sections, auto-expands Recovery Metrics when switching to rest.
shared/schema-static.ts Adds entryTypeEnum + EntryType export; makes goal/rpe/feel optional at field level and enforces them for cycling via superRefine; adds weight, restNotes, activityGoal, activityNotes optional fields.
client/src/test/utils.test.ts Local copies of the three markdown generators are maintained in the test file rather than importing the real implementations; divergence risk if home.tsx changes.
client/src/test/schema.test.ts New test suites cover entryType validation, rest-only fields (weight), other-only fields, and superRefine cycling enforcement; comprehensive coverage.
client/src/hooks/use-form-persistence.ts Adds migration shim: old drafts without entryType are patched to 'cycling' before restoring. Logic is correct and guarded by typeof check.
client/src/hooks/use-section-state.ts Adds 'rest-day' and 'activity' to the SectionId union and ALL_SECTION_IDS array; no logic changes.
CLAUDE.md Documentation updated to reflect new entry types, section IDs, schema fields, and markdown output formats.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects Entry Type] --> B{entryType}
    B -->|cycling| C[Core Metrics\nFueling\nPerformance\nRecovery\nReflection]
    B -->|rest| D[Recovery Metrics\nauto-expanded\nRest Day]
    B -->|other| E[Activity Section]

    C --> F[generateCyclingMarkdown\nG/R/F + metrics + WWW/WCBI/Planned]
    D --> G[generateRestMarkdown\nRest Day + HRV/rMSSD/RHR/TR-LGT/W + bullets]
    E --> H[generateOtherMarkdown\nG: activity + bullets]

    F --> I[generateMarkdown\n--- date header ---]
    G --> I
    H --> I

    I --> J[Clipboard copy]

    K[Draft restored from localStorage] --> L{has entryType?}
    L -->|no - old draft| M[Migrate: set entryType=cycling]
    L -->|yes| N[Use stored entryType]
    M --> O[form.reset]
    N --> O
Loading

Comments Outside Diff (2)

  1. client/src/test/utils.test.ts, line 854-932 (link)

    P2 Test helpers duplicate production implementations

    generateCyclingMarkdown, generateRestMarkdown, generateOtherMarkdown, and formatWorkoutDate are copy-pasted into this file instead of being imported from home.tsx. If the production implementations change (e.g. a new field is added to the rest markdown), these tests will silently keep passing while the real output differs.

    Consider exporting the helpers from home.tsx (or extracting them to a shared module like lib/markdown.ts) so the tests exercise the actual code path rather than a parallel copy.

  2. shared/schema-static.ts, line 1134-1156 (link)

    P2 Unreachable null branches in superRefine

    z.string().optional() and z.number().min(1).max(10).optional() both reject null during Zod's own field validation — by the time superRefine runs, data.goal and data.rpe can only be a valid value or undefined. The === null arms are therefore dead code.

    Consider simplifying to === undefined checks only (matching the !data.feel style used for the feel field).

Reviews (1): Last reviewed commit: "Add Cycling/Rest/Other entry types" | Re-trigger Greptile

aidmax and others added 4 commits April 22, 2026 10:59
The two tests that asserted exact date strings in markdown output
(startsWith '24.03.2026' and exact-match '13.04.2026') depended on
the machine's timezone because new Date('YYYY-MM-DD') parses as UTC
midnight. Switch to regex matches on the shape of the date header
so the tests pass regardless of local timezone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
With Rest and Other entry types the old label reads as misleading —
a rest day isn't a workout.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aidmax aidmax merged commit f792393 into main Apr 22, 2026
1 check passed
@aidmax aidmax deleted the claude/entry-types branch April 22, 2026 11:31
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