feat(keyboard-undo-stack): Ctrl+Z für letzte delete-Action (in-memory undo-stack) [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 08:10:01 +02:00
parent 3cfe79a523
commit fb67391eb8
5 changed files with 237 additions and 1 deletions

View File

@ -7,6 +7,7 @@
"recurring-time-entries", "recurring-time-entries",
"slack-integration-stub", "slack-integration-stub",
"github-link-on-entries", "github-link-on-entries",
"budget-alerts" "budget-alerts",
"api-client-phase20"
] ]
} }

5
.phase21-state.json Normal file
View File

@ -0,0 +1,5 @@
{
"completed_features": [],
"current_feature": "keyboard-undo-stack",
"started_at": "2026-05-23T08:09:40.135892"
}

View File

@ -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. 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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, 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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, 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<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy

View File

@ -0,0 +1,80 @@
import React, { createContext, useContext, useState, useCallback, useEffect } from 'react';
type UndoAction = {
description: string;
undoFn: () => void | Promise<void>;
};
type UndoStackContextType = {
pushUndo: (action: UndoAction) => void;
undo: () => void;
stack: UndoAction[];
};
const UndoStackContext = createContext<UndoStackContextType | undefined>(undefined);
export function UndoStackProvider({ children }: { children: React.ReactNode }) {
const [stack, setStack] = useState<UndoAction[]>([]);
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 (
<UndoStackContext.Provider value={{ pushUndo, undo, stack }}>
{children}
</UndoStackContext.Provider>
);
}
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 (
<div className="fixed bottom-4 right-4 z-50 flex flex-col gap-2">
<div className="bg-slate-800 text-white px-3 py-2 rounded-lg shadow-lg text-xs flex items-center gap-3 animate-in fade-in slide-in-from-bottom-2">
<span>Last action: <strong>{stack[stack.length - 1].description}</strong></span>
<button
onClick={undo}
className="bg-blue-600 hover:bg-blue-500 px-2 py-1 rounded transition-colors"
>
Undo (Ctrl+Z)
</button>
</div>
</div>
);
};

126
scripts/phase21_features.py Normal file
View File

@ -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 <UndoStack /> 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()))