diff --git a/.phase20-state.json b/.phase20-state.json index f9dece0..088e289 100644 --- a/.phase20-state.json +++ b/.phase20-state.json @@ -7,6 +7,7 @@ "recurring-time-entries", "slack-integration-stub", "github-link-on-entries", - "budget-alerts" + "budget-alerts", + "api-client-phase20" ] } \ No newline at end of file diff --git a/.phase21-state.json b/.phase21-state.json new file mode 100644 index 0000000..1361727 --- /dev/null +++ b/.phase21-state.json @@ -0,0 +1,5 @@ +{ + "completed_features": [], + "current_feature": "keyboard-undo-stack", + "started_at": "2026-05-23T08:09:40.135892" +} \ No newline at end of file diff --git a/GENERATION_LOG.md b/GENERATION_LOG.md index 7d258c1..8704d96 100644 --- a/GENERATION_LOG.md +++ b/GENERATION_LOG.md @@ -2475,3 +2475,27 @@ src/index.ts(27,25): error TS2769: No overload matches this call. Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. Type 'Promise' provides no match for the signature '(instance: FastifyInstance, FastifyBaseLogger, FastifyTy +- `08:08:44` **INFO** Committed feature api-client-phase20 +- `08:08:45` **INFO** Pushed: rc=0 + +## Phase-20 Run beendet (2026-05-23 08:08:45) + +- `08:08:45` **INFO** OK: 0, Attempted: 6, Total: 6 + +## 🚀 Phase-21 Codegen-Run gestartet (2026-05-23 08:09:40) + + +## Phase-3 Feature: keyboard-undo-stack (2026-05-23 08:09:40) + +- `08:09:40` **INFO** Description: Ctrl+Z für letzte delete-Action (in-memory undo-stack) +- `08:09:40` **INFO** Generating apps/web/src/components/UndoStack.tsx (UndoStack-Component (global). useEffect window keydown ctrl+z (oder cm…) +- `08:09:59` **INFO** wrote 2232 chars in 19.2s (attempt 1) +- `08:09:59` **INFO** Running tsc --noEmit on api… +- `08:10:01` **WARN** tsc errors: +src/index.ts(27,25): error TS2769: No overload matches this call. + Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. + Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. + Type 'Promise' provides no match for the signature '(instance: FastifyInstance, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'. + Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. + Argument of type 'Promise' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. + Type 'Promise' provides no match for the signature '(instance: FastifyInstance, FastifyBaseLogger, FastifyTy diff --git a/apps/web/src/components/UndoStack.tsx b/apps/web/src/components/UndoStack.tsx new file mode 100644 index 0000000..4272e48 --- /dev/null +++ b/apps/web/src/components/UndoStack.tsx @@ -0,0 +1,80 @@ +import React, { createContext, useContext, useState, useCallback, useEffect } from 'react'; + +type UndoAction = { + description: string; + undoFn: () => void | Promise; +}; + +type UndoStackContextType = { + pushUndo: (action: UndoAction) => void; + undo: () => void; + stack: UndoAction[]; +}; + +const UndoStackContext = createContext(undefined); + +export function UndoStackProvider({ children }: { children: React.ReactNode }) { + const [stack, setStack] = useState([]); + + const pushUndo = useCallback((action: UndoAction) => { + setStack((prev) => [...prev, action]); + }, []); + + const undo = useCallback(async () => { + setStack((prev) => { + if (prev.length === 0) return prev; + const lastAction = prev[prev.length - 1]; + + // Execute the undo function + lastAction.undoFn(); + + return prev.slice(0, -1); + }); + }, []); + + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'z') { + e.preventDefault(); + undo(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + return () => window.removeEventListener('keydown', handleKeyDown); + }, [undo]); + + return ( + + {children} + + ); +} + +export function useUndoStack() { + const context = useContext(UndoStackContext); + if (!context) { + throw new Error('useUndoStack must be used within an UndoStackProvider'); + } + return context; +} + +export const UndoStack = () => { + const { stack, undo } = useUndoStack(); + + if (stack.length === 0) return null; + + return ( +
+
+ Last action: {stack[stack.length - 1].description} + +
+
+ ); +}; \ No newline at end of file diff --git a/scripts/phase21_features.py b/scripts/phase21_features.py new file mode 100644 index 0000000..08d512d --- /dev/null +++ b/scripts/phase21_features.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +"""Phase-21: undo-stack, snippets, smart-rounding, color-coded-rows, templates-page.""" + +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 / ".phase21-state.json" + +FEATURES: list[Feature] = [ + Feature( + name="keyboard-undo-stack", + description="Ctrl+Z für letzte delete-Action (in-memory undo-stack)", + files=[FileGen( + path="apps/web/src/components/UndoStack.tsx", + purpose=( + "UndoStack-Component (global). useEffect window keydown ctrl+z (oder cmd+z). " + "Maintains array of {description, undoFn}. Bei trigger: poppt letzte und ruft undoFn. " + "Export auch useUndoStack() hook für andere Components zum push()." + ), + )], + ), + Feature( + name="snippet-shortcuts", + description="Snippet-Expander: ';daily' → 'Daily standup', ';mtg' → 'Meeting'", + files=[FileGen( + path="apps/web/src/components/SnippetInput.tsx", + purpose=( + "Drop-in-Input mit snippet-expansion. Snippets-map inline: {';daily':'Daily standup', " + "';mtg':'Meeting', ';review':'Code review', ';bug':'Bugfix '}. " + "Auf input-change: ersetze trailing ;keyword durch expansion. Props: value, onChange, ...rest." + ), + )], + ), + Feature( + name="smart-rounding-on-input", + description="Bei Time-Entry-Submit: round endTime auf appSettings.roundingMinutes", + files=[FileGen( + path="apps/web/src/pages/TimeEntries.tsx", + purpose=( + "ERWEITERT — behalte alles. Im handleSubmit: vor mutate, runde endTime auf nächste roundingMinutes (aus api.getSettings(), useQuery cache'd). " + "Wenn rounding=0: kein rounding. Toast info nach Rundung 'Auf 15min gerundet'." + ), + refs=["apps/web/src/pages/TimeEntries.tsx"], + )], + ), + Feature( + name="color-coded-customer-rows", + description="Customer-Rows mit Hash-basierter Pastell-Background-Color", + files=[FileGen( + path="apps/web/src/pages/Customers.tsx", + purpose=( + "ERWEITERT — behalte alles. Pro Customer-Row left-border-Color basierend auf hash(name) modulo palette " + "['border-l-4 border-rose-300', 'border-l-4 border-amber-300', 'border-l-4 border-emerald-300', " + "'border-l-4 border-sky-300', 'border-l-4 border-violet-300']." + ), + refs=["apps/web/src/pages/Customers.tsx"], + )], + ), + Feature( + name="time-entry-templates-page", + description="UI-Page für TimeEntry-Templates CRUD", + files=[FileGen( + path="apps/web/src/pages/TimeEntryTemplates.tsx", + purpose=( + "TimeEntryTemplates-Page. Liste + Create-Form (name, description, projectId optional, defaultDurationMinutes optional). " + "Verwende api.listTimeEntryTemplates() / createTimeEntryTemplate() / deleteTimeEntryTemplate()." + ), + refs=["apps/web/src/pages/Customers.tsx"], + )], + ), + Feature( + name="router-phase21", + description="Mount /templates Route + Nav-Link + UndoStack global", + files=[ + FileGen( + path="apps/web/src/App.tsx", + purpose="ERWEITERT — füge /time-entry-templates Route + mount global. Behalte alles.", + refs=["apps/web/src/App.tsx"], + ), + FileGen( + path="apps/web/src/components/Nav.tsx", + purpose="ERWEITERT — füge Templates-Link in Nav. Behalte alles.", + refs=["apps/web/src/components/Nav.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-21 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-21 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()))