feat(recently-viewed-widget): Recently-Viewed Widget für Dashboard (last 5 customers + pro [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 09:19:02 +02:00
parent 2fe907da4e
commit eb65bea128
5 changed files with 215 additions and 1 deletions

View File

@ -5,6 +5,7 @@
"attempted_features": [ "attempted_features": [
"customer-contact-info", "customer-contact-info",
"project-billing-rate", "project-billing-rate",
"time-entry-clone" "time-entry-clone",
"breadcrumbs-everywhere"
] ]
} }

5
.phase29-state.json Normal file
View File

@ -0,0 +1,5 @@
{
"completed_features": [],
"current_feature": "recently-viewed-widget",
"started_at": "2026-05-23T09:18:37.298269"
}

View File

@ -3275,3 +3275,28 @@ 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. 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>'. 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>, Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>,
- `09:15:44` **INFO** Committed feature breadcrumbs-everywhere
- `09:15:45` **INFO** Pushed: rc=0
## Phase-28 Run beendet (2026-05-23 09:15:45)
- `09:15:45` **INFO** OK: 0, Attempted: 4, Total: 4
## 🚀 Phase-29 Codegen-Run gestartet (2026-05-23 09:18:37)
## Phase-3 Feature: recently-viewed-widget (2026-05-23 09:18:37)
- `09:18:37` **INFO** Description: Recently-Viewed Widget für Dashboard (last 5 customers + projects)
- `09:18:37` **INFO** Generating apps/web/src/components/RecentlyViewed.tsx (RecentlyViewed-Widget. localStorage 'recently_viewed' array {type:'cus…)
- `09:19:00` **INFO** wrote 2774 chars in 23.3s (attempt 1)
- `09:19:00` **INFO** Running tsc --noEmit on api…
- `09:19:02` **WARN** tsc errors:
src/db/schema.ts(37,14): error TS7022: 'customers' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
src/db/schema.ts(45,59): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
src/db/schema.ts(49,14): error TS7022: 'projects' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
src/db/schema.ts(53,56): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
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>,

View File

@ -0,0 +1,75 @@
import React, { useEffect, useState } from 'react';
import { Link, useLocation } from '@tanstack/react-router';
type ViewedItem = {
type: 'customer' | 'project';
id: string;
name: string;
viewedAt: number;
};
export default function RecentlyViewed() {
const location = useLocation();
const [items, setItems] = useState<ViewedItem[]>([]);
useEffect(() => {
// 1. Track current route
const path = location.pathname;
const customerMatch = path.match(/\/customers\/([^/]+)/);
const projectMatch = path.match(/\/projects\/([^/]+)/);
if (customerMatch || projectMatch) {
const type = customerMatch ? 'customer' : 'project';
const id = customerMatch ? customerMatch[1] : projectMatch![1];
// In a real app, we'd fetch the name from a store/cache.
// For the widget, we'll use a placeholder or try to extract from state if available.
// Here we use a generic label since we don't have the full entity object in the URL.
const name = `View ${id}`;
const stored = localStorage.getItem('recently_viewed');
const parsed: ViewedItem[] = stored ? JSON.parse(stored) : [];
// Remove existing entry of same item to move it to top
const filtered = parsed.filter(i => !(i.type === type && i.id === id));
const updated = [{ type, id, name, viewedAt: Date.now() }, ...filtered].slice(0, 5);
localStorage.setItem('recently_viewed', JSON.stringify(updated));
setItems(updated);
}
}, [location.pathname]);
// Initial load
useEffect(() => {
const stored = localStorage.getItem('recently_viewed');
if (stored) setItems(JSON.parse(stored));
}, []);
if (items.length === 0) return null;
return (
<div className="p-4 bg-white border border-slate-200 rounded-lg shadow-sm">
<h3 className="text-sm font-semibold text-slate-500 uppercase tracking-wider mb-3">
Recently Viewed
</h3>
<ul className="space-y-2">
{items.map((item) => (
<li key={`${item.type}-${item.id}`}>
<Link
to={`/${item.type}s/${item.id}`}
className="flex items-center justify-between p-2 text-sm text-slate-700 hover:bg-slate-50 rounded-md transition-colors group"
>
<div className="flex items-center gap-2">
<span className={`w-2 h-2 rounded-full ${item.type === 'customer' ? 'bg-blue-400' : 'bg-emerald-400'}`} />
<span className="truncate max-w-[150px]">{item.name}</span>
</div>
<span className="text-xs text-slate-400 opacity-0 group-hover:opacity-100 transition-opacity">
</span>
</Link>
</li>
))}
</ul>
</div>
);
}

108
scripts/phase29_features.py Normal file
View File

@ -0,0 +1,108 @@
#!/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()))