Commit Graph

331 Commits

Author SHA1 Message Date
87464ff138 fix: Phase 1 - Goal System Quick Fixes + Abstraction Layer
All checks were successful
Deploy Development / deploy (push) Successful in 53s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Behebt 4 kritische Bugs in Phase 0a und schafft Basis für Phase 0b
ohne spätere Doppelarbeit.

Backend:
- NEW: goal_utils.py mit get_focus_weights() Abstraction Layer
  → V1: Mappt goal_mode zu Gewichten
  → V2 (später): Liest aus focus_areas Tabelle
  → Phase 0b Platzhalter (120+) müssen NICHT umgeschrieben werden
- FIX: Primary goal toggle in goals.py (is_primary im GoalUpdate Model)
  → Beim Update auf primary werden andere Goals korrekt auf false gesetzt
- FIX: lean_mass current_value Berechnung implementiert
  → weight - (weight * body_fat_pct / 100)
- FIX: VO2Max Spaltenname vo2_max (statt vo2max)
  → Internal Server Error behoben

CLAUDE.md:
- Version Update: Phase 1 Fixes (27.03.2026)

Keine Doppelarbeit:
- Alle zukünftigen Phase 0b Platzhalter nutzen get_focus_weights()
- v2.0 Redesign = nur eine Funktion ändern, nicht 120+ Platzhalter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 06:13:47 +01:00
e3f1e399c2 docs: Goal System Redesign v2.0 - comprehensive concept
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Created comprehensive redesign document addressing all identified issues:

Problems addressed:
1. Primary goal too simplistic → Weight system (0-100%)
2. Single goal mode too simple → Multi-mode with weights
3. Missing current values → All goal types with data sources
4. Abstract goal types → Concrete, measurable goals
5. Blood pressure single value → Compound goals (systolic/diastolic)
6. No user guidance → Norms, examples, age-specific values

New Concept:
- Focus Areas: Weighted distribution (30% weight loss + 25% endurance + ...)
- Goal Weights: Each goal has individual weight (not binary primary/not)
- Concrete Goal Types: cooper_test, pushups_max, squat_1rm, etc.
- Compound Goals: Support for multi-value targets (BP: 120/80)
- Guidance System: Age/gender-specific norms and examples

Schema Changes:
- New table: focus_areas (replaces single goal_mode)
- goals: Add goal_weight, target_value_secondary, current_value_secondary
- goals: Remove is_primary (replaced by weight)

UI/UX Redesign:
- Slider interface for focus areas (must sum to 100%)
- Goal editor with guidance and norms
- Weight indicators on all goals
- Special UI for compound goals

Implementation Phases: 16-21h total
- Phase 2: Backend Redesign (6-8h)
- Phase 3: Frontend Redesign (8-10h)
- Phase 4: Testing & Refinement (2-3h)

Status: WAITING FOR USER FEEDBACK & APPROVAL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 22:05:05 +01:00
3dd10d3dc7 docs: Phase 0a completion - comprehensive documentation
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
CLAUDE.md:
- Version updated to v9e+ (Phase 0a Goal System Complete)
- Added Phase 0a feature section with full details
- Updated 'Letzte Updates' with Phase 0a completion
- Links to new documentation files

docs/issues/issue-50-phase-0a-goal-system.md (NEW):
- Complete Phase 0a implementation documentation
- Technical details: Migration 022, goals.py, GoalsPage
- 4 commits documented (337667f to 5be52bc)
- Lessons learned section
- Basis for Phase 0b documented
- Testing checklist + acceptance criteria

docs/NEXT_STEPS_2026-03-26.md (NEW):
- Comprehensive planning document
- Option A: Issue #49 - Prompt Page Assignment (6-8h)
- Option B: Phase 0b - Goal-Aware Placeholders (16-20h)
- Option C: Issue #47 - Value Table Refinement (4-6h)
- Recommendation: Szenario 1 (Quick Wins first)
- Detailed technical breakdown for both options
- Timeline estimates (4h/day vs 8h/day)
- 120+ placeholder categorization for Phase 0b

All documentation reflects current state post Phase 0a.
Next decision: Choose between Issue #49 or Phase 0b.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 21:49:07 +01:00
5be52bcfeb feat: goals navigation + UX improvements
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Analysis Page:
- Add 'Ziele' button next to page title
- Direct navigation to /goals from analysis page
- Thematic link: goals influence AI analysis weighting

Goals Page:
- Fix text-align for text inputs (name, date, description)
- Text fields now left-aligned (numbers remain right-aligned)
- Better UX for non-numeric inputs

Navigation strategy: Goals accessible from Analysis page where
goal_mode directly impacts score calculation and interpretation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:50:22 +01:00
75f0a5dd6e refactor: mobile-friendly goal form design
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Full-width inputs throughout the form
- Labels above inputs (mobile best practice)
- Section headers with emoji (🎯 Zielwert)
- Consistent spacing (marginBottom: 16)
- Read-only unit display as styled badge
- Primary goal checkbox in highlighted section
- Full-width buttons (btn-full class)
- Scrollable modal with top padding
- Error display above form

Matches VitalsPage design pattern for consistency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:32:37 +01:00
906a3b7cdd fix: Migration 022 - remove invalid schema_migrations tracking
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
The migration system tracks migrations via filename automatically.
Removed manual DO block that used wrong column name (version vs filename).

Also removed unused json import from goals.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:26:48 +01:00
337667fc07 feat: Phase 0a - Minimal Goal System (Strategic + Tactical)
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
- Strategic Layer: Goal modes (weight_loss, strength, endurance, recomposition, health)
- Tactical Layer: Concrete goal targets with progress tracking
- Training phases (manual + auto-detection framework)
- Fitness tests (standardized performance tracking)

Backend:
- Migration 022: goal_mode in profiles, goals, training_phases, fitness_tests tables
- New router: routers/goals.py with full CRUD for goals, phases, tests
- API endpoints: /api/goals/* (mode, list, create, update, delete)

Frontend:
- GoalsPage: Goal mode selector + goal management UI
- Dashboard: Goals preview card with link
- API integration: goal mode, CRUD operations, progress calculation

Basis for 120+ placeholders and goal-aware analyses (Phase 0b)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:20:35 +01:00
ae93b9d428 docs: goal system priority analysis - hybrid approach
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Key Decision: Minimal Goal System BEFORE Placeholders

Critical Finding:
- Same data = different interpretation per goal
- Example: -5kg FM, -2kg LBM
  - weight_loss: 78/100 (good!)
  - strength: 32/100 (LBM loss critical!)
  - Without goal: 50/100 (generic, wrong for both)

Recommended Approach (Hybrid):
1. Phase 0a (2-3h): Minimal Goal System
   - DB: goal_mode field
   - API: Get/Set Goal
   - UI: Goal Selector
   - Default: health

2. Phase 0b (16-20h): Goal-Aware Placeholders
   - 84 placeholders with goal-dependent calculations
   - Scores use goal_mode from day 1
   - No rework needed later

3. Phase 2+ (6-8h): Full Goal System
   - Goal recognition from patterns
   - Secondary goals
   - Goal progression tracking

Why Hybrid Works:
 Charts show correct interpretations immediately
 No rework of 84 placeholders later
 Goal recognition can come later (needs placeholders anyway)
 System is "smart coach" from day 1

File: docs/GOAL_SYSTEM_PRIORITY_ANALYSIS.md (650 lines)
2026-03-26 16:08:00 +01:00
8398368ed7 docs: comprehensive functional concept analysis
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
Analysis Results:
- 84 new placeholders needed from Fachkonzept
- Issues #26 & #27 too narrow (complementary, not conflicting)
- Recommend 4-phase approach: Placeholders → Charts → Rules → KI
- Transform: Data Collector → Active Coach

Key Findings:
- Fachkonzept defines 3 levels (Deskriptiv, Diagnostisch, Präskriptiv)
- 18 dedicated charts (K1-K5, E1-E5, A1-A8, C1-C6)
- Goal-mode dependent interpretation
- Lag-based correlations mandatory
- Confidence & data quality essential

Recommended Actions:
- Create Issues #52-55 (Baseline, Scores, Correlations, Metrics)
- Expand #26 & #27 based on Fachkonzept
- Start Phase 0: Implement 84 placeholders

File: docs/KONZEPT_ANALYSE_2026-03-26.md (385 lines)
2026-03-26 15:26:12 +01:00
cd2609da7c feat: Feature Request #49 - Prompt-Zuordnung zu Verlaufsseiten
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
UX Enhancement: Kontextbezogene KI-Analysen

Features:
- Prompts auf Verlaufsseiten verfügbar machen
- Mehrfachauswahl: Prompt auf mehreren Seiten
- Inline-Analyse via Modal
- Wiederverwendbare PagePrompts Komponente

Technisch:
- DB: available_on JSONB column
- API: GET /api/prompts/for-page/{page_slug}
- UI: Page-Auswahl im Prompt-Editor

Aufwand: 6-8h, Priority: Medium
Gitea: Issue #49
2026-03-26 15:12:39 +01:00
39db23d417 docs: comprehensive status report 26.03.2026
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Audit Results:
- 2 Issues closed: #28 (AI-Prompts), #44 (Delete bug)
- 1 Issue created: #47 (Value Table Refinement)
- 12 commits today, 3 major features completed
- All documentation synchronized with Gitea

Next: Testing on dev, then Production deployment
2026-03-26 14:53:45 +01:00
582f125897 docs: comprehensive status update and Gitea sync
Some checks failed
Deploy Development / deploy (push) Successful in 57s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Has been cancelled
Updates:
- Clarify Gitea issue references (prefix with 'Gitea #')
- Mark #28 (AI-Prompts) as CLOSED
- Mark #44 (Delete insights) as CLOSED
- Update #47 reference (Wertetabelle Optimierung)
- Add 'Letzte Updates' section for 26.03.2026
- Document Issue-Management responsibility

Gitea Actions:
- Closed Issue #28 with completion comment
- Closed Issue #44 with fix details
- Created Issue #47 (Wertetabelle Optimierung)
2026-03-26 14:52:44 +01:00
21bdd9f2ba docs: add Claude Code responsibilities section
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Issue-Management via Gitea API
- Dokumentation pflegen
- Entwicklungs-Workflow
2026-03-26 14:46:20 +01:00
713f7475c9 docs: create Issue #50 - Value Table Refinement
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Normal-Modus: Nur Einzelwerte (übersichtlich)
- Experten-Modus: Zusätzlich Stage-Rohdaten
- Beschreibungen für alle Platzhalter vervollständigen
- Schema-basierte Beschreibungen für extrahierte Werte

Aufwand: 4-6h, Priority: Medium
2026-03-26 14:43:23 +01:00
6e651b5bb5 fix: include stage outputs in debug info for value table
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- stage_debug now includes 'output' dict with all stage outputs
- Fixes empty values for stage_X_outputkey in expert mode
- Stage outputs are the actual AI responses passed to next stage
2026-03-26 14:33:00 +01:00
f37936c84d feat: show all stage outputs as collapsible JSON in expert mode
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Backend:
- Add ALL stage outputs to metadata (not just referenced ones)
- Format JSON with indent for readability
- Description: 'Zwischenergebnis aus Stage X'

Frontend:
- Stage raw values shown in collapsible <details> element
- JSON formatted in <pre> tag with syntax highlighting
- 'JSON anzeigen ▼' summary for better UX

Fixes: Stage X - Rohdaten now shows intermediate results
2026-03-26 13:17:58 +01:00
159fcab17a feat: circ_summary with best-of-each strategy and age annotations
All checks were successful
Deploy Development / deploy (push) Successful in 42s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
- Each circumference point shows most recent value (even from different dates)
- Age annotations: heute, gestern, vor X Tagen/Wochen/Monaten
- Gives AI better context about measurement freshness
- Example: 'Brust 105cm (heute), Nacken 38cm (vor 2 Wochen)'
2026-03-26 13:09:38 +01:00
d06d3d84de fix: circ_summary now checks all 8 circumference points
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Previously only checked c_chest, c_waist, c_hip
- Now includes c_neck, c_belly, c_thigh, c_calf, c_arm
- Fixes 'keine Daten' when entries exist with only non-primary measurements
2026-03-26 13:06:37 +01:00
b0f80e0be7 docs: document Issue #47 completion in CLAUDE.md
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
- Added comprehensive documentation for Value Table feature
- Expert mode, category grouping, stage output extraction
- Updated version header to reflect #28 and #47 completion
2026-03-26 13:03:49 +01:00
adb5dcea88 feat: category grouping in value table (Issue #47)
All checks were successful
Deploy Development / deploy (push) Successful in 52s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
FEATURE: Gruppierung nach Kategorien
- Wertetabelle jetzt nach Modulen/Kategorien gruppiert
- Bessere Übersicht und Zuordnung der Werte

BACKEND: Category Metadata
- Für normale Platzhalter: Kategorie aus Catalog (Profil, Körper, Ernährung, etc.)
- Für extrahierte Werte: "Stage X - [Output Name]"
- Für Rohdaten: "Stage X - Rohdaten"
- Fallback: "Sonstiges"

FRONTEND: Grouped Display
- sortedCategories: Sortierung (Normal → Stage Outputs → Rohdaten)
- Section Headers: Grauer Hintergrund mit Kategorie-Name
- React.Fragment für Gruppierung

SORTIERUNG:
1. Normale Kategorien (Profil, Körper, Ernährung, Training, etc.)
2. Stage Outputs (Stage 1 - Body, Stage 1 - Nutrition, etc.)
3. Rohdaten (Stage 1 - Rohdaten, Stage 2 - Rohdaten)
4. Innerhalb: Alphabetisch

BEISPIEL:
┌────────────────────────────────────────────┐
│ PROFIL                                     │
├────────────────────────────────────────────┤
│ name       │ Lars    │ Name des Nutzers   │
│ age        │ 55      │ Alter in Jahren    │
├────────────────────────────────────────────┤
│ KÖRPER                                     │
├────────────────────────────────────────────┤
│ weight_... │ 85.2 kg │ Aktuelles Gewicht  │
│ bmi        │ 26.6    │ Body Mass Index    │
├────────────────────────────────────────────┤
│ ERNÄHRUNG                                  │
├────────────────────────────────────────────┤
│ kcal_avg   │ 1427... │ Durchschn. Kalorien│
│ protein... │ 106g... │ Durchschn. Protein │
├────────────────────────────────────────────┤
│ STAGE 1 - BODY                             │
├────────────────────────────────────────────┤
│ ↳ bmi      │ 26.6    │ Aus Stage 1 (body) │
│ ↳ trend    │ sinkend │ Aus Stage 1 (body) │
├────────────────────────────────────────────┤
│ STAGE 1 - NUTRITION                        │
├────────────────────────────────────────────┤
│ ↳ kcal_... │ 1427    │ Aus Stage 1 (nutr.)│
└────────────────────────────────────────────┘

Experten-Modus zusätzlich:
├────────────────────────────────────────────┤
│ STAGE 1 - ROHDATEN                         │
├────────────────────────────────────────────┤
│ 🔬 stage...│ {"bmi"..│ Rohdaten Stage 1   │
└────────────────────────────────────────────┘

version: 9.10.0 (feature)
module: prompts 2.5.0, insights 1.8.0
2026-03-26 12:59:52 +01:00
da803da816 feat: extract individual values from stage outputs (Issue #47)
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
FEATURE: Basis-Analysen Einzelwerte
Vorher: stage_1_body → {"bmi": 26.6, "weight": "85.2kg"} (1 Zeile)
Jetzt:  bmi → 26.6 (eigene Zeile)
        weight → 85.2kg (eigene Zeile)

BACKEND: JSON-Extraktion
- Stage outputs (JSON) → extract individual fields
- extracted_values dict sammelt alle Einzelwerte
- Deduplizierung: Gleiche Keys nur einmal
- Flags:
  - is_extracted: true → Wert aus Stage-Output extrahiert
  - is_stage_raw: true → Rohdaten (JSON) nur Experten-Modus

BEISPIEL Stage 1 Output:
{
  "stage_1_body": {
    "bmi": 26.6,
    "weight": "85.2 kg",
    "trend": "sinkend"
  }
}

→ Metadata:
{
  "bmi": {
    value: "26.6",
    description: "Aus Stage 1 (stage_1_body)",
    is_extracted: true
  },
  "weight": {
    value: "85.2 kg",
    description: "Aus Stage 1 (stage_1_body)",
    is_extracted: true
  },
  "stage_1_body": {
    value: "{\"bmi\": 26.6, ...}",
    description: "Rohdaten Stage 1 (Basis-Analyse JSON)",
    is_stage_raw: true
  }
}

FRONTEND: Smart Filtering
Normal-Modus:
- Zeigt: Einzelwerte (bmi, weight, trend)
- Versteckt: Rohdaten (stage_1_body JSON)
- Filter: is_stage_raw === false

Experten-Modus:
- Zeigt: Alles (Einzelwerte + Rohdaten)
- Rohdaten: Grauer Hintergrund + 🔬 Icon

VISUAL Indicators:
↳ bmi        → Extrahierter Wert (grün)
  weight     → Normaler Platzhalter (accent)
🔬 stage_1_* → Rohdaten JSON (grau, klein, nur Experten)

ERGEBNIS:
┌──────────────────────────────────────────┐
│ 📊 Verwendete Werte (8) (+2 ausgeblendet)│
│ ┌────────────────────────────────────────┐│
│ │ weight_aktuell │ 85.2 kg   │ Gewicht ││ ← Normal
│ │ ↳ bmi          │ 26.6      │ Aus St..││ ← Extrahiert
│ │ ↳ trend        │ sinkend   │ Aus St..││ ← Extrahiert
│ └────────────────────────────────────────┘│
└──────────────────────────────────────────┘

Experten-Modus zusätzlich:
│ 🔬 stage_1_body │ {"bmi":...│ Rohdaten││ ← JSON

version: 9.9.0 (feature)
module: prompts 2.4.0, insights 1.7.0
2026-03-26 12:55:53 +01:00
e799edbae4 feat: expert mode + stage outputs in value table (Issue #47)
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
FEATURE: Experten-Modus 🔬
- Toggle-Button in Wertetabelle
- Normal: Nur gefüllte Werte anzeigen
- Experten: Alle Platzhalter inkl. leere/technische
- Anzeige: "(+X ausgeblendet)" wenn Werte gefiltert
- Button-Style: Accent wenn aktiv

FILTER: Leere Werte ausblenden (Normal-Modus)
- Filtert: '', 'nicht verfügbar', '[Nicht verfügbar]'
- Zeigt nur relevante Nutzer-Daten
- Experten-Modus zeigt alles

FEATURE: Stage-Outputs in Wertetabelle 
ROOT CAUSE: stage_N_key Platzhalter hatten keine Werte
- Stage-Outputs (z.B. stage_1_body) sind Basis-Analysen-Ergebnisse
- Wurden nicht in cleaned_values gefunden (nur statische Platzhalter)
FIX:
- Collect stage outputs aus result.debug.stages[].output
- Store als stage_N_key dict
- Lookup: erst stage_outputs, dann cleaned_values
- Description: "Output aus Stage X (Basis-Analyse)"
- JSON-Werte automatisch serialisiert

BEISPIEL Pipeline-Wertetabelle:
┌──────────────────────────────────────────────┐
│ 📊 Verwendete Werte (8) (+3 ausgeblendet) 🔬│
│ ┌──────────────────────────────────────────┐ │
│ │ weight_aktuell  │ 85.2 kg   │ Gewicht  │ │
│ │ stage_1_body    │ {"bmi":...│ Output...│ │ ← Stage output!
│ │ stage_1_nutr... │ {"kcal"...│ Output...│ │
│ └──────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘

AKTIVIERUNG Experten-Modus:
1. Analyse öffnen
2. "📊 Verwendete Werte" aufklappen
3. Button "🔬 Experten-Modus" klicken
4. Zeigt alle Platzhalter (auch leere stage outputs)

version: 9.8.0 (feature)
module: prompts 2.3.0, insights 1.6.0
2026-03-26 12:44:28 +01:00
15bd6cddeb feat: untruncated values + smart base prompt display (Issue #47)
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
FEATURE: Volle Werte (nicht abgeschnitten)
- Backend holt ungekürzten Werte direkt von placeholder_resolver
- get_placeholder_example_values() statt debug.resolved_placeholders
- Debug bleibt gekürzt (100 chars), Metadata ungekürzt

FEATURE: Smart Display für Basis-Prompts
- Basis-Prompts mit JSON-Output: Nur Wertetabelle anzeigen
- JSON-Output in Collapsible "Technische Daten" verschoben
- Wertetabelle auto-expanded bei Basis-Prompts
- Pipeline + Text-Prompts: Wie bisher (Content + Wertetabelle)

UI: Bessere Wertetabelle
- Werte: word-break + max-width (400px) → kein Overflow
- Alle Spalten: verticalAlign top für bessere Lesbarkeit
- Platzhalter: nowrap (keine Umbrüche)

BEISPIEL:
┌─────────────────────────────────────────┐
│ ℹ️ Basis-Prompt Rohdaten                │
│ [Technische Daten anzeigen ▼]           │
│                                          │
│ 📊 Verwendete Werte (8) ▼  ← expanded  │
│ ┌──────────────────────────────────────┐│
│ │ Platzhalter │ Vollständiger Wert... ││
│ │ kcal_avg    │ 1427 kcal/Tag (Ø 30...││ ← ungekürzt
│ └──────────────────────────────────────┘│
└─────────────────────────────────────────┘

version: 9.7.0 (feature)
module: prompts 2.2.0, insights 1.5.0
2026-03-26 12:37:52 +01:00
19414614bf fix: add metadata to newResult for immediate value table display
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
BUG: Wertetabelle wurde nicht angezeigt bei neuer Analyse
ROOT CAUSE: newResult hatte nur {scope, content}, kein metadata
FIX: Build metadata from result.debug.resolved_placeholders
- Für Base: direkt aus resolved_placeholders
- Für Pipeline: collect aus allen stages
- Metadata structure: {prompt_type, placeholders: {key: {value, description}}}

NOTE: Immediate preview hat keine descriptions (nur values)
Saved insights (nach loadAll) haben full metadata with descriptions aus DB

version: 9.6.2 (bugfix)
2026-03-26 12:29:05 +01:00
4a2bebe249 fix: value table metadata + |d modifier + cursor insertion (Issues #47, #48)
All checks were successful
Deploy Development / deploy (push) Successful in 52s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
BUG: Wertetabelle wurde nicht angezeigt
FIX: enable_debug=true wenn save=true (für metadata collection)
- metadata wird nur gespeichert wenn debug aktiv
- jetzt: debug or save → metadata immer verfügbar

BUG: {{placeholder|d}} Modifier funktionierte nicht
ROOT CAUSE: catalog wurde bei Exception nicht zu variables hinzugefügt
FIX:
- variables['_catalog'] = catalog (auch wenn None)
- Warning-Log wenn catalog nicht geladen werden kann
- Debug warning wenn |d ohne catalog verwendet

BUG: Platzhalter in Pipeline-Stages am Ende statt an Cursor
FIX:
- stageTemplateRefs Map für alle Stage-Textareas
- onClick + onKeyUp tracking für Cursor-Position
- Insert at cursor: template.slice(0, pos) + placeholder + template.slice(pos)
- Focus + Cursor restore nach Insert

TECHNICAL:
- prompt_executor.py: Besseres Exception Handling für catalog
- UnifiedPromptModal.jsx: Refs für alle Template-Felder
- prompts.py: enable_debug=debug or save

version: 9.6.1 (bugfix)
module: prompts 2.1.1
2026-03-26 12:04:20 +01:00
c0a50dedcd feat: value table + {{placeholder|d}} modifier (Issue #47)
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s
FEATURE #47: Wertetabelle nach KI-Analysen
- Migration 021: metadata JSONB column in ai_insights
- Backend sammelt resolved placeholders mit descriptions beim Speichern
- Frontend: Collapsible value table in InsightCard
  - Zeigt: Platzhalter | Wert | Beschreibung
  - Sortiert tabellarisch
  - Funktioniert für base + pipeline prompts

FEATURE #48: {{placeholder|d}} Modifier
- Syntax: {{weight_aktuell|d}} → "85.2 kg (Aktuelles Gewicht in kg)"
- resolve_placeholders() erkennt |d modifier
- Hängt description aus catalog an Wert
- Fein-granulare Kontrolle pro Platzhalter (nicht global)
- Optional: nur wo sinnvoll einsetzen

TECHNICAL:
- prompt_executor.py: catalog parameter durchgereicht
- execute_prompt_with_data() lädt catalog via get_placeholder_catalog()
- Catalog als _catalog in variables übergeben, in execute_prompt() extrahiert
- Base + Pipeline Prompts unterstützen |d modifier

EXAMPLE:
Template: "Gewicht: {{weight_aktuell|d}}, Alter: {{age}}"
Output:   "Gewicht: 85.2 kg (Aktuelles Gewicht in kg), Alter: 55"

version: 9.6.0 (feature)
module: prompts 2.1.0, insights 1.4.0
2026-03-26 11:52:26 +01:00
c56d2b2201 fix: delete insights + placeholder cursor insertion (Issue #44)
BUG #44: Analysen löschen schlug fehl (kein Auth-Token)
FIX:
- api.deleteInsight() in api.js hinzugefügt
- Analysis.jsx nutzt jetzt api.js mit Error-Handling
- Nicht mehr raw fetch() ohne Token

BUG: Platzhalter wurden am Ende eingefügt statt an Cursor-Position
FIX:
- useRef für baseTemplateRef hinzugefügt
- Cursor-Position tracking (onClick + onKeyUp)
- Insert at cursor: template.slice(0, pos) + placeholder + template.slice(pos)
- Focus + Cursor-Position nach Insert wiederhergestellt

version: 9.5.2 (bugfix)
module: prompts 2.0.2, insights 1.3.1
2026-03-26 11:40:19 +01:00
7daa2e40c7 fix: sleep quality calculation using wrong key (stage vs phase)
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
BUG: sleep_avg_quality showed 0% despite valid sleep data
ROOT CAUSE: sleep_segments use 'phase' key, not 'stage'
FIX: Changed s.get('stage') to s.get('phase') in get_sleep_avg_quality()

version: 9.5.1 (bugfix)
module: prompts 2.0.1
2026-03-26 10:31:39 +01:00
ae6bd0d865 docs: Issue #28 completion documentation (v9e)
- Marked Issue #28 as complete
- Documented all 4 original phases
- Documented debug tools added 26.03.2026
- Documented placeholder enhancements (6 new functions, 7 reconstructed)
- Documented bug fixes (PIPELINE_MASTER, SQL columns, type errors)
- Listed related Gitea issues (#43, #44, #45, #46)
- Updated version status to v9e Ready for Production

version: 9.5.0 (documentation update)
2026-03-26 10:28:42 +01:00
a43a9f129f fix: sleep_avg_quality uses lowercase stage names
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
Problem: Schlafphasen werden lowercase gespeichert (deep, rem, light, awake),
aber get_sleep_avg_quality() prüfte Titlecase (Deep, REM) → 0% Match

Fix: Ändere Prüfung zu lowercase: ['deep', 'rem']

Jetzt wird {{sleep_avg_quality}} korrekt berechnet aus JSONB segments.

Quelle: backend/routers/sleep.py → phase_map speichert lowercase

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 10:22:55 +01:00
3ad1a19dce fix: calculate_age now handles PostgreSQL date objects
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Problem: dob Spalte ist DATE (PostgreSQL) → Python bekommt datetime.date,
nicht String → strptime() schlägt fehl → age = "unbekannt"

Fix: Prüfe isinstance(dob, str) und handle beide Typen:
- String → strptime()
- date object → direkt verwenden

Jetzt funktioniert {{age}} Platzhalter korrekt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 10:19:36 +01:00
a9114bc40a feat: implement missing placeholder functions (sleep, vitals, rest)
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Implementiert 6 fehlende Platzhalter-Funktionen die im Katalog waren
aber keine Berechnung hatten.

Neue Funktionen:
- get_sleep_avg_duration(7d) → "7.5h"
- get_sleep_avg_quality(7d) → "65% (Deep+REM)"
- get_rest_days_count(30d) → "5 Ruhetage"
- get_vitals_avg_hr(7d) → "58 bpm"
- get_vitals_avg_hrv(7d) → "45 ms"
- get_vitals_vo2_max() → "42.5 ml/kg/min"

Datenquellen:
- sleep_log (JSONB segments mit Deep/REM/Light/Awake)
- rest_days (Kraft/Cardio/Entspannung)
- vitals_baseline (resting_hr, hrv, vo2_max)

Jetzt in PLACEHOLDER_MAP registriert → sofort nutzbar.

Fixes: Platzhalter-Export zeigt jetzt alle Werte (statt "nicht verfügbar")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 10:14:17 +01:00
555ff62b56 feat: global placeholder export with values (Settings page)
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Zentraler Export aller verfügbaren Platzhalter mit aktuellen Werten.

Backend:
- GET /api/prompts/placeholders/export-values
  - Returns all placeholders organized by category
  - Includes resolved values for current profile
  - Includes metadata (description, example)
  - Flat list + categorized structure

Frontend SettingsPage:
- Button "📊 Platzhalter exportieren"
- Downloads: placeholders-{profile}-{date}.json
- Shows all 38+ placeholders with current values
- Useful for:
  - Understanding available data
  - Debugging prompt templates
  - Verifying placeholder resolution

Frontend api.js:
- exportPlaceholderValues()

Export Format:
{
  "export_date": "2026-03-26T...",
  "profile_id": "...",
  "count": 38,
  "all_placeholders": { "name": "Lars", ... },
  "placeholders_by_category": {
    "Profil": [...],
    "Körper": [...],
    ...
  }
}

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 10:05:11 +01:00
7f94a41965 feat: batch import/export for prompts (Issue #28 Debug B)
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Dev→Prod Sync in 2 Klicks: Export → Import

Backend:
- GET /api/prompts/export-all → JSON mit allen Prompts
- POST /api/prompts/import?overwrite=true/false → Import + Create/Update
  - Returns: created, updated, skipped counts
  - Validates JSON structure
  - Handles stages JSON conversion

Frontend AdminPromptsPage:
- Button "📦 Alle exportieren" → downloads all-prompts-{date}.json
- Button "📥 Importieren" → file upload dialog
  - User-Prompt: Überschreiben? Ja/Nein
  - Success-Message mit Statistik (created/updated/skipped)

Frontend api.js:
- exportAllPrompts()
- importPrompts(data, overwrite)

Use Cases:
1. Backup: Prompts als JSON sichern
2. Dev→Prod: Auf dev.mitai entwickeln → exportieren → auf mitai.jinkendo importieren
3. Versionierung: Prompts in Git speichern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:44:08 +01:00
8b287ca6c9 feat: export all placeholders from debug viewer (Issue #28 Debug A)
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Added "📋 Platzhalter exportieren" button in debug viewer:
- Exports all resolved placeholders with values
- Includes all available_variables
- For pipelines: exports per-stage placeholder data
- JSON format with timestamp and prompt metadata
- Filename: placeholders-{slug}-{date}.json

Use case: Development aid - see exactly what data is available
for prompt templates without null values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:40:26 +01:00
97e57481f9 fix: Analysis page now uses unified prompt executor (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
BREAKING: Analysis page switched from old /insights/run to new /prompts/execute

Changes:
- Backend: Added save=true parameter to /prompts/execute
  - When enabled, saves final output to ai_insights table
  - Extracts content from pipeline output (last stage)
- Frontend api.js: Added save parameter to executeUnifiedPrompt()
- Frontend Analysis.jsx: Switched from api.runInsight() to api.executeUnifiedPrompt()
  - Transforms new result format to match InsightCard expectations
  - Pipeline outputs properly extracted and displayed

Fixes: PIPELINE_MASTER responses (old template being sent to AI)
The old /insights/run endpoint used raw template field, which for the
legacy "pipeline" prompt was literally "PIPELINE_MASTER". The new
executor properly handles stages and data processing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:38:58 +01:00
811ba8b3dc fix: convert Decimal to float before multiplication in protein targets
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- get_protein_ziel_low: float(weight) * 1.6
- get_protein_ziel_high: float(weight) * 2.2

Fixes TypeError: unsupported operand type(s) for *: 'decimal.Decimal' and 'float'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:23:50 +01:00
b90c738fbb fix: make test button always visible in prompt editor
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 22s
- Removed conditional hiding of test button (prompt?.slug)
- Button now always visible with helpful tooltip
- handleTest already has save-check logic

Improves discoverability of test functionality.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:16:59 +01:00
dfaf24d74c fix: correct SQL column names in placeholder_resolver
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- caliper_summary: use body_fat_pct (not bf_jpl)
- circ_summary: use c_chest, c_waist, c_hip (not brust, taille, huefte)
- get_latest_bf: use body_fat_pct for consistency

Fixes SQL errors when running base prompts that feed pipeline prompts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:10:55 +01:00
0f2b85c6de fix: reconstruct missing placeholders + fix SQL column names
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
Added missing placeholders:
- caliper_summary, circ_summary (body measurements)
- goal_weight, goal_bf_pct (goals from profile)
- nutrition_days (count of nutrition entries)
- protein_ziel_low/high (calculated from weight)

Fixed SQL errors:
- protein → protein_g
- fat → fat_g
- carb → carbs_g

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:03:35 +01:00
f4d1fd4de1 feat: add activity_detail placeholder for detailed activity logs
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- New placeholder: {{activity_detail}} returns formatted activity log
- Shows last 20 activities with date, type, duration, kcal, HR
- Makes activity analysis prompts work properly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 08:20:18 +01:00
ba92d66880 fix: remove {{ }} from placeholder keys before resolution
All checks were successful
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 12s
Placeholder resolver returns keys with {{ }} wrappers,
but resolve_placeholders expects clean keys.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 08:17:22 +01:00
afc70b5a95 fix: integrate placeholder resolver + JSON unwrapping (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Backend: integrate get_placeholder_example_values in execute_prompt_with_data
- Backend: now provides BOTH raw data AND processed placeholders
- Backend: unwrap Markdown-wrapped JSON (```json ... ```)
- Fixes old-style prompts that expect name, weight_trend, caliper_summary

Resolves unresolved placeholders issue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 08:14:41 +01:00
84dad07e15 fix: show debug info on errors + prompt export function
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
- Frontend: debug viewer now shows even when test fails
- Frontend: export button to download complete prompt config as JSON
- Backend: attach debug info to JSON validation errors
- Backend: include raw output and length in error details

Users can now debug failed prompts and export configs for analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 08:07:34 +01:00
7f2ba4fbad feat: debug system for prompt execution (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
- Backend: debug mode in prompt_executor with placeholder tracking
- Backend: show resolved/unresolved placeholders, final prompts, AI responses
- Frontend: test button in UnifiedPromptModal for saved prompts
- Frontend: debug output viewer with JSON preview
- Frontend: wider placeholder example fields in PlaceholderPicker

Resolves pipeline execution debugging issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 08:01:33 +01:00
4ba03c2a94 feat: Analysis page pipeline-only + wider placeholder examples (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 14s
- PlaceholderPicker: Example values in separate full-width row
- Analysis.jsx: Show only pipeline-type prompts
- Analysis.jsx: Remove base prompts and Prompts tab
- Cleanup: Remove PromptEditor component and unused imports

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 07:50:13 +01:00
8036c99883 feat: dynamic placeholder picker with categories and search (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
Major improvements:
1. PlaceholderPicker component (new)
   - Loads placeholders dynamically from backend catalog
   - Grouped by categories: Profil, Körper, Ernährung, Training, etc.
   - Search/filter functionality
   - Shows live example values from user data
   - Popup modal with expand/collapse categories

2. Replaced hardcoded placeholder chips
   - 'Platzhalter einfügen' button opens picker
   - Works in both base templates and pipeline inline templates
   - Auto-closes after selection

3. Uses existing backend system
   - GET /api/prompts/placeholders
   - placeholder_resolver.py with PLACEHOLDER_MAP
   - Dynamic, module-based placeholder system
   - No manual updates needed when modules add new placeholders

Benefits:
- Scalable: New modules can add placeholders without frontend changes
- User-friendly: Search and categorization
- Context-aware: Shows real example values
- Future-proof: Backend-driven catalog
2026-03-25 22:08:14 +01:00
b058b0fd6f feat: placeholder chips + convert to base prompt (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
New features:
1. Placeholder chips now visible in pipeline inline templates
   - Click to insert: weight_data, nutrition_data, activity_data, etc.
   - Same UX as base prompts

2. Convert to Base Prompt button
   - New icon (ArrowDownToLine) in actions column
   - Only visible for 1-stage pipeline prompts
   - Converts pipeline → base by extracting inline template
   - Validates: must be 1-stage, 1-prompt, inline source

This allows migrated prompts to be properly categorized as base prompts
for reuse in other pipelines.
2026-03-25 21:59:43 +01:00
7dda520c9b fix: UI improvements for unified prompt system (Issue #28)
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
Fixes:
1. Template field in stages now full width (was too narrow)
2. Table horizontal scrollbar for mobile (overflow-x: auto)
3. Table min-width 900px to prevent icon clipping
4. Added clickable placeholder chips below base template
   - Click to insert placeholders into template
   - Shows: weight_data, nutrition_data, activity_data, sleep_data, etc.

UI now mobile-ready and more user-friendly.
2026-03-25 21:52:58 +01:00
0a3e76128a fix: simplified JSX string to avoid escaping issues
All checks were successful
Deploy Development / deploy (push) Successful in 43s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 18s
2026-03-25 21:42:01 +01:00