Skip to content

feat: copy workout as Markdown from the detail view - #89

Open
wulfland wants to merge 1 commit into
mainfrom
copy-as-markdowm-demoprep
Open

wulfland wants to merge 1 commit into
mainfrom
copy-as-markdowm-demoprep

Conversation

@wulfland

Copy link
Copy Markdown
Owner

Summary

Adds a Copy as Markdown button to the workout detail modal (Progress → workout card). One click puts a GitHub-flavored Markdown version of the workout on the clipboard, ready to paste into notes, a chat or an issue.

Ships behind the copy_markdown feature flag, default off. Enable locally with ?ff=copy_markdown.

Changes

  • src/lib/workoutMarkdown.ts — pure renderer: heading with date, summary bullets (duration, sets, volume), notes as blockquote, one set table per exercise, optional feedback section. No DOM or DB access; exercise name lookup is injected.
  • src/lib/workoutMarkdown.test.ts — 12 unit tests (escaping of | and newlines, no exercises, no completed sets, actual vs target reps, unknown exercise, feedback rendering).
  • src/components/progress/WorkoutDetail.tsx — flag-gated button wired to the shared copyToClipboard helper and useToast; success and error toasts.
  • src/components/progress/WorkoutDetail.css — outlined secondary button, footer gap, visible :focus-visible ring on both footer buttons.

No new dependencies, no schema change, no network calls.

Verification

/verify on this branch:

Step Result
type-check, lint, format PASS
unit tests (199) PASS
build + preview PASS
flag off: button absent PASS
flag on: open detail → Copy as Markdown (keyboard) → toast + clipboard matches workout PASS

Clipboard output for the seeded workout:

# Workout – Sunday, October 18, 2026 at 09:00 AM

- **Duration:** 45m
- **Total sets:** 3
- **Total volume:** 2360 kg

## Notes

> Seeded by e2e/helpers/seed-workout.ts

## Exercises

### Barbell Bench Press

Volume: 1520 kg

| Set | Weight | Reps | RIR | Volume |
| --- | --- | --- | --- | --- |
| 1 | 80 kg | 10 | 2 | 800 kg |
| 2 | 80 kg | 9 | 2 | 720 kg |

### Barbell Row

Volume: 840 kg

| Set | Weight | Reps | RIR | Volume |
| --- | --- | --- | --- | --- |
| 1 | 70 kg | 12 | 2 | 840 kg |

🤖 Generated with Claude Code

Add a "Copy as Markdown" button to the workout detail modal, behind the
copy_markdown feature flag (default off, enable with ?ff=copy_markdown).

- src/lib/workoutMarkdown.ts: pure renderer producing a GFM document with
  summary, notes, per-exercise set tables and optional feedback
- 12 unit tests covering escaping, empty states, reps vs target, feedback
- Uses the shared clipboard helper and toast; button is keyboard reachable
  with a visible focus ring

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

/** Escape characters that would break a Markdown table cell. */
function escapeCell(value: string): string {
return value.replace(/\|/g, '\\|').replace(/\r?\n/g, ' ');

This branch has not been deployed

No deployments
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.

2 participants