Files
Michele 14588eaa94 docs(02-02): complete per-item regeneration + summary counter plan
Tasks completed: 2/2
- PostCard regen button with inline form, topic override, badge
- OutputReview summary counter with regenerated/edited tracking

SUMMARY: .planning/phases/02-prompt-control-output-review/02-02-SUMMARY.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:53:43 +01:00

5.1 KiB

phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
phase plan subsystem tags dependency_graph tech_stack key_files decisions metrics
02-prompt-control-output-review 02 output-review
react
postcard
regeneration
summary-counter
inline-form
requires provides affects
02-01 (Prompt CRUD + Prompt Editor UI)
01-04 (PostCard, OutputReview, SlideViewer, localResults pattern)
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)
Future phases that enhance OutputReview or PostCard
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
created modified
frontend/src/components/PostCard.tsx
frontend/src/pages/OutputReview.tsx
id decision reason date
tono-as-notes-override Regen notes passed via tono field in GenerateRequest instead of adding a new backend field 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. 2026-03-08
id decision reason date
json-stringify-edit-detection Manual edit detection uses JSON.stringify comparison between localResults and jobData.results With only 13 posts, the performance cost is negligible. Avoids tracking a separate dirty flag per post. 2026-03-08
duration completed
~4 min 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 <button> to a <div> with separate click zones: the content area expands/collapses, the regen button opens the form, and the chevron also expands/collapses.

Task 2: OutputReview — summary counter con tracking rigenerati/modificati

Modified frontend/src/pages/OutputReview.tsx:

  • regeneratedSlots stateSet<number> tracking slot indices of regenerated posts. Updated in handleRegenerated.
  • regeneratedCount — Derived from regeneratedSlots.size.
  • manuallyEditedCount — Counts posts whose post field differs from jobData.results (original server data) via JSON.stringify comparison, minus regenerated posts to avoid double-counting.
  • Summary counter in header — Shows: N post | X generati | Y falliti | Z rigenerati | W modificati | job: ID. Regenerated and modified counts only appear when > 0. Uses amber color for regenerated (with RefreshCw icon) and blue for manually edited.
  • isRegenerated prop passed to PostCard — Each PostCard receives regeneratedSlots.has(result.slot_index).
  • Updated info box — Now mentions the regen feature with an inline RefreshCw icon.

Deviations from Plan

None - plan executed exactly as written.

Verification

  • PostCard success shows a Regen button (RefreshCw icon) in the header
  • Click on Regen opens inline form with topic and notes fields (both optional)
  • Regeneration calls POST /api/generate/single with topic/tono override and updates the card
  • Regenerated posts show an amber RefreshCw badge next to the slot number
  • Summary counter in OutputReview header shows counts for generati/falliti/rigenerati/modificati
  • Summary counter updates in real-time after regeneration or edit
  • CSV download contains latest versions (localResults updated by both regen and edit)
  • TypeScript compiles without errors (npx tsc --noEmit)

Next Phase Readiness

Phase 02 is now COMPLETE. Both plans (02-01 Prompt CRUD + Prompt Editor, 02-02 Per-item Regeneration + Summary Counter) are done. The system is ready for:

  • vps-lab-deploy to test end-to-end on VPS
  • Phase 03 (Canva-ready CSV polish + advanced export)