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>
This commit is contained in:
@@ -5,33 +5,33 @@
|
|||||||
See: .planning/PROJECT.md (updated 2026-03-07)
|
See: .planning/PROJECT.md (updated 2026-03-07)
|
||||||
|
|
||||||
**Core value:** Generare un calendario di 13 caroselli Instagram strategicamente orchestrati, pronti per Canva Bulk Create, con un click dalla Web UI.
|
**Core value:** Generare un calendario di 13 caroselli Instagram strategicamente orchestrati, pronti per Canva Bulk Create, con un click dalla Web UI.
|
||||||
**Current focus:** Phase 2 in corso — Prompt Control + Output Review
|
**Current focus:** Phase 2 COMPLETA — Prompt Control + Output Review
|
||||||
|
|
||||||
## Current Position
|
## Current Position
|
||||||
|
|
||||||
Phase: 2 of 4 (Prompt Control + Output Review)
|
Phase: 2 of 4 (Prompt Control + Output Review)
|
||||||
Plan: 1 of 2 in current phase
|
Plan: 2 of 2 in current phase — PHASE COMPLETE
|
||||||
Status: In progress — 02-01 completato, 02-02 da eseguire
|
Status: Phase 2 complete — ready for Phase 3 or deploy
|
||||||
Last activity: 2026-03-08 — Completed 02-01-PLAN.md (Prompt CRUD + Prompt Editor UI)
|
Last activity: 2026-03-08 — Completed 02-02-PLAN.md (Per-item Regeneration + Summary Counter)
|
||||||
|
|
||||||
Progress: [█████░░░░░] 55% (5/9 piani totali)
|
Progress: [██████░░░░] 66% (6/9 piani totali)
|
||||||
|
|
||||||
## Performance Metrics
|
## Performance Metrics
|
||||||
|
|
||||||
**Velocity:**
|
**Velocity:**
|
||||||
- Total plans completed: 5
|
- Total plans completed: 6
|
||||||
- Average duration: ~7 min
|
- Average duration: ~7 min
|
||||||
- Total execution time: 38 min
|
- Total execution time: 42 min
|
||||||
|
|
||||||
**By Phase:**
|
**By Phase:**
|
||||||
|
|
||||||
| Phase | Plans | Total | Avg/Plan |
|
| Phase | Plans | Total | Avg/Plan |
|
||||||
|-------|-------|-------|----------|
|
|-------|-------|-------|----------|
|
||||||
| 01-core-generation-pipeline | 4/4 COMPLETA | 33 min | 8 min |
|
| 01-core-generation-pipeline | 4/4 COMPLETA | 33 min | 8 min |
|
||||||
| 02-prompt-control-output-review | 1/2 | 5 min | 5 min |
|
| 02-prompt-control-output-review | 2/2 COMPLETA | 9 min | 4.5 min |
|
||||||
|
|
||||||
**Recent Trend:**
|
**Recent Trend:**
|
||||||
- Last 5 plans: 6 min, 9 min, 8 min, 10 min, 5 min
|
- Last 5 plans: 9 min, 8 min, 10 min, 5 min, 4 min
|
||||||
- Trend: velocita' in aumento
|
- Trend: velocita' in aumento
|
||||||
|
|
||||||
*Updated after each plan completion*
|
*Updated after each plan completion*
|
||||||
@@ -60,21 +60,23 @@ Recent decisions affecting current work:
|
|||||||
- [01-04]: localResults separato in OutputReview per edit inline senza mutare cache TanStack Query
|
- [01-04]: localResults separato in OutputReview per edit inline senza mutare cache TanStack Query
|
||||||
- [verification-fix]: GenerateResponse include calendar per badge PN/Schwartz nel frontend
|
- [verification-fix]: GenerateResponse include calendar per badge PN/Schwartz nel frontend
|
||||||
- [02-01]: PromptService init lazy via _get_prompt_service() per sincronizzazione con lifespan directory
|
- [02-01]: PromptService init lazy via _get_prompt_service() per sincronizzazione con lifespan directory
|
||||||
|
- [02-02]: Regen notes passate via campo tono in GenerateRequest (pragmatico, no backend changes)
|
||||||
|
- [02-02]: Edit detection manuale via JSON.stringify comparison (trascurabile con 13 post)
|
||||||
|
|
||||||
### Blockers/Concerns
|
### Blockers/Concerns
|
||||||
|
|
||||||
- [Phase 1]: Validare token usage reale per batch 13 post con claude-sonnet-4-5 — inter_request_delay=2.0s configurato, da validare in produzione
|
- [Phase 1]: Validare token usage reale per batch 13 post con claude-sonnet-4-5 — inter_request_delay=2.0s configurato, da validare in produzione
|
||||||
- [Phase 1]: Baseline qualita' prompt italiani da validare dopo prima generazione reale
|
- [Phase 1]: Baseline qualita' prompt italiani da validare dopo prima generazione reale
|
||||||
- [Deploy]: Phase 1 completa — serve vps-lab-deploy per testare end-to-end il sistema
|
- [Deploy]: Phase 2 completa — serve vps-lab-deploy per testare end-to-end il sistema
|
||||||
|
|
||||||
## Session Continuity
|
## Session Continuity
|
||||||
|
|
||||||
Last session: 2026-03-08
|
Last session: 2026-03-08
|
||||||
Stopped at: Completed 02-01-PLAN.md (Prompt CRUD + Prompt Editor UI)
|
Stopped at: Completed 02-02-PLAN.md (Per-item Regeneration + Summary Counter) — Phase 2 COMPLETE
|
||||||
Resume file: None
|
Resume file: None
|
||||||
|
|
||||||
## Next Actions
|
## Next Actions
|
||||||
|
|
||||||
1. Eseguire 02-02-PLAN.md (Output Review enhancements)
|
1. `vps-lab-deploy` per deployare su VPS e testare end-to-end
|
||||||
2. Completare Phase 2
|
2. Pianificare Phase 3 (Canva-ready CSV polish + advanced export)
|
||||||
3. `vps-lab-deploy` per deployare su VPS e testare end-to-end
|
3. Eseguire Phase 3
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
---
|
||||||
|
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 `<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` state** — `Set<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
|
||||||
|
|
||||||
|
- [x] PostCard success shows a Regen button (RefreshCw icon) in the header
|
||||||
|
- [x] Click on Regen opens inline form with topic and notes fields (both optional)
|
||||||
|
- [x] Regeneration calls POST /api/generate/single with topic/tono override and updates the card
|
||||||
|
- [x] Regenerated posts show an amber RefreshCw badge next to the slot number
|
||||||
|
- [x] Summary counter in OutputReview header shows counts for generati/falliti/rigenerati/modificati
|
||||||
|
- [x] Summary counter updates in real-time after regeneration or edit
|
||||||
|
- [x] CSV download contains latest versions (localResults updated by both regen and edit)
|
||||||
|
- [x] 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)
|
||||||
Reference in New Issue
Block a user