#!/usr/bin/env python3 """Phase-29: favorites, recently-viewed, project-grouping, keyboard-shortcuts, onboarding-improvements.""" from __future__ import annotations import asyncio, datetime, json, sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) from phase2_features import Feature, FileGen, ROOT, log, log_section from phase3_features import run_feature_v2 PHASE_STATE = ROOT / ".phase29-state.json" FEATURES: list[Feature] = [ Feature( name="recently-viewed-widget", description="Recently-Viewed Widget für Dashboard (last 5 customers + projects)", files=[FileGen( path="apps/web/src/components/RecentlyViewed.tsx", purpose=( "RecentlyViewed-Widget. localStorage 'recently_viewed' array {type:'customer'|'project',id,name,viewedAt}. " "useEffect on route-change pushed current item. Zeigt top 5 als Liste mit Link." ), )], ), Feature( name="favorites-system", description="User kann Customer/Project favoritisieren (localStorage)", files=[FileGen( path="apps/web/src/lib/favorites.ts", purpose=( "useFavorites() hook + util. Manages localStorage 'favorites' Set per entity-type. " "Methoden: isFavorite(type,id), toggle(type,id), getAll(type). Triggers re-render via custom event." ), )], ), Feature( name="more-keyboard-shortcuts", description="? für Help, G+H for home, etc — Hotkey-Registry", files=[FileGen( path="apps/web/src/components/KeyboardHelp.tsx", purpose=( "ERWEITERT — füge mehr shortcuts dokumentiert: G H = Dashboard, G T = TimeEntries, G C = Customers, G P = Projects, " "G S = Settings, N = New Entry, ? = Hilfe, Cmd+K = Palette. Behalte alles." ), refs=["apps/web/src/components/KeyboardHelp.tsx"], )], ), Feature( name="onboarding-improvements", description="Onboarding-Tour: 3 Schritte (Dashboard → Customer anlegen → TimeEntry tracken)", files=[FileGen( path="apps/web/src/components/OnboardingTour.tsx", purpose=( "ERWEITERT — behalte Trigger-Logik. Verbesserte Steps: " "1. Welcome auf Dashboard, 2. 'Kunde anlegen' → highlight /customers, 3. 'Zeit erfassen' → highlight /time-entries. " "Mit 'Skip Tour' + 'Got it' buttons." ), refs=["apps/web/src/components/OnboardingTour.tsx"], )], ), Feature( name="dashboard-favorites-section", description="Dashboard zeigt Favorites als Quick-Access", files=[FileGen( path="apps/web/src/pages/Dashboard.tsx", purpose=( "ERWEITERT — füge Favorites-Section unten: useFavorites() für customers + projects. " "Chips/Cards mit Link zur Detail-Page. Wenn leer: hide section. Behalte alles." ), refs=["apps/web/src/pages/Dashboard.tsx"], )], ), ] def load_state(): if PHASE_STATE.exists(): return json.loads(PHASE_STATE.read_text()) return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()} def save_state(state): PHASE_STATE.write_text(json.dumps(state, indent=2)) async def main(): log_section("🚀 Phase-29 Codegen-Run gestartet") state = load_state() for feature in FEATURES: if feature.name in state.get("completed_features", []): continue state["current_feature"] = feature.name; save_state(state) try: success = await run_feature_v2(feature) state.setdefault("completed_features" if success else "attempted_features", []).append(feature.name) save_state(state) except Exception as e: log(f"❌ {feature.name} crashed: {e}", level="ERROR") state.setdefault("attempted_features", []).append(feature.name); save_state(state) log_section("Phase-29 Run beendet") log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}") return 0 if __name__ == "__main__": sys.exit(asyncio.run(main()))