--- phase: 02-prompt-control-output-review plan: 02 subsystem: output-review tags: [react, postcard, regeneration, summary-counter, inline-form] dependency_graph: requires: - 02-01 (Prompt CRUD + Prompt Editor UI) - 01-04 (PostCard, OutputReview, SlideViewer, localResults pattern) provides: - Per-item regeneration with topic/notes override on PostCard - Visual badge for regenerated posts (amber RefreshCw icon) - Summary counter in OutputReview header (generati/rigenerati/modificati) affects: - Future phases that enhance OutputReview or PostCard tech_stack: added: [] patterns: - Inline popover form for regen (no modal overlay) - regeneratedSlots Set for tracking regen state across session - JSON.stringify comparison for manual edit detection vs original jobData key_files: created: [] modified: - frontend/src/components/PostCard.tsx - frontend/src/pages/OutputReview.tsx decisions: - id: tono-as-notes-override decision: "Regen notes passed via tono field in GenerateRequest instead of adding a new backend field" reason: "The tono field is injected into the prompt as context — reusing it for user notes is pragmatic and avoids backend changes for a frontend-only enhancement." date: 2026-03-08 - id: json-stringify-edit-detection decision: "Manual edit detection uses JSON.stringify comparison between localResults and jobData.results" reason: "With only 13 posts, the performance cost is negligible. Avoids tracking a separate dirty flag per post." date: 2026-03-08 metrics: duration: ~4 min completed: 2026-03-08 --- # Phase 02 Plan 02: Per-item Regeneration + Summary Counter Summary **PostCard con bottone Rigenera inline, form popover per topic/note override, badge rigenerato amber, e summary counter real-time in OutputReview con tracking rigenerati/modificati.** ## What Was Done ### Task 1: PostCard — bottone Rigenera con popover inline, topic override, badge rigenerato Modified `frontend/src/components/PostCard.tsx`: - **New prop `isRegenerated`** — When true, shows an amber `RefreshCw` icon badge next to the slot number, visually distinguishing regenerated posts from originals. - **`handleRegen` function** — Calls `POST /api/generate/single` with optional topic override (via `slot.topic`) and notes override (via `tono` field). On success, calls `onRegenerated` callback and resets the form. - **Regen button in card header** — Small `RefreshCw` icon button positioned before the expand/collapse chevron. Uses `e.stopPropagation()` to not interfere with expand toggle. - **Inline popover form** — Appears below the header (above SlideViewer) when Regen button is clicked. Contains: - Optional "Topic alternativo" text input - Optional "Note aggiuntive" text input - "Rigenera" button (amber, with spinner during loading) - "Annulla" button to close and reset form - Error message display if generation fails - **Header refactored** — Changed from a single `