diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index 93dcdef..516744d 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -146,7 +146,7 @@ - [x] **TMPL-10**: When adding a document to a client, agent can choose "Start from template" and pick a saved template - [x] **TMPL-11**: Applying a template creates a document with all template fields pre-loaded (fresh field IDs, positions, types, and role assignments copied) - [x] **TMPL-12**: Template signer roles are automatically mapped to the client's contacts in order (primary contact → first role, co-buyer → second role); agent can override the mapping before sending -- [ ] **TMPL-13**: Text hints from the template appear as quick-fill suggestions in the document's PreparePanel +- [x] **TMPL-13**: Text hints from the template appear as quick-fill suggestions in the document's PreparePanel - [x] **TMPL-14**: Editing a template after documents have been created from it does NOT retroactively change those documents — each document is an independent snapshot ### Portal Navigation @@ -282,7 +282,7 @@ Which phases cover which requirements. Updated during roadmap creation. | TMPL-10 | Phase 20 | Complete | | TMPL-11 | Phase 20 | Complete | | TMPL-12 | Phase 20 | Complete | -| TMPL-13 | Phase 20 | Pending | +| TMPL-13 | Phase 20 | Complete | | TMPL-14 | Phase 20 | Complete | | TMPL-15 | Phase 20 | Complete | | TMPL-16 | Phase 20 | Complete | diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 726028c..54ea296 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -188,7 +188,7 @@ Plans: - [x] **Phase 18: Template Schema and CRUD API** - New `document_templates` table with Drizzle migration; list, create, rename, and soft-delete API routes (completed 2026-04-06) - [x] **Phase 19: Template Editor UI** - FieldPlacer `onPersist` abstraction, template editor page at `/portal/templates/[id]`, AI auto-place wired to template context, signer role label support, save template (completed 2026-04-06) -- [ ] **Phase 20: Apply Template and Portal Nav** - "Start from template" option in AddDocumentModal, apply operation with field snapshot and role-to-email mapping, text hint quick-fill, Templates portal nav section and list page +- [x] **Phase 20: Apply Template and Portal Nav** - "Start from template" option in AddDocumentModal, apply operation with field snapshot and role-to-email mapping, text hint quick-fill, Templates portal nav section and list page (completed 2026-04-06) ## Phase Details @@ -437,7 +437,7 @@ Plans: Plans: - [x] 20-01-PLAN.md — Extend POST /api/documents with template branch + Add My Templates tab to AddDocumentModal -- [ ] 20-02-PLAN.md — Template hint quick-fill chips in PreparePanel + human E2E verification +- [x] 20-02-PLAN.md — Template hint quick-fill chips in PreparePanel + human E2E verification **UI hint**: yes ## Progress @@ -468,4 +468,4 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → | 17. Docker Deployment | v1.2 | 2/2 | Complete | 2026-04-03 | | 18. Template Schema and CRUD API | v1.3 | 2/2 | Complete | 2026-04-06 | | 19. Template Editor UI | v1.3 | 3/3 | Complete | 2026-04-06 | -| 20. Apply Template and Portal Nav | v1.3 | 1/2 | In Progress| | +| 20. Apply Template and Portal Nav | v1.3 | 2/2 | Complete | 2026-04-06 | diff --git a/.planning/STATE.md b/.planning/STATE.md index 1839a39..9bff11d 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,15 +2,15 @@ gsd_state_version: 1.0 milestone: v1.1 milestone_name: Smart Document Preparation -status: executing -stopped_at: Completed 20-01-PLAN.md — apply template and portal nav -last_updated: "2026-04-06T20:52:20.693Z" +status: verifying +stopped_at: Completed 20-02 Task 1 — awaiting human verify checkpoint (Task 2) +last_updated: "2026-04-06T20:55:04.742Z" last_activity: 2026-04-06 progress: total_phases: 22 - completed_phases: 20 + completed_phases: 21 total_plans: 65 - completed_plans: 63 + completed_plans: 64 percent: 98 --- @@ -26,7 +26,7 @@ See: .planning/PROJECT.md (updated 2026-04-03) Phase: 20 (apply-template-and-portal-nav) — EXECUTING Plan: 2 of 2 -Status: Ready to execute +Status: Phase complete — ready for verification Last activity: 2026-04-06 ## Note on v1.1 @@ -109,6 +109,7 @@ Progress: [██████████████░] 98% (19/22 phases comp | Phase 19-template-editor-ui P03 | 1 | 1 tasks | 0 files | | Phase 19 P03 | <1 | 1 tasks | 0 files | | Phase 20-apply-template-and-portal-nav P01 | 2 | 2 tasks | 2 files | +| Phase 20-apply-template-and-portal-nav P02 | 2 | 1 tasks | 2 files | ## Accumulated Context @@ -205,6 +206,7 @@ Recent decisions affecting v1.1 work: - [Phase 19-03]: All five TMPL requirements (TMPL-05 through TMPL-09) verified by human in a single 9-step live browser test - [Phase 20-apply-template-and-portal-nav]: documentTemplateId branch in POST /api/documents returns early so all existing paths unchanged; fresh crypto.randomUUID per field ensures snapshot independence - [Phase 20-apply-template-and-portal-nav]: My Templates tab lazy-fetches /api/templates on first click via docTemplatesLoaded flag to avoid unnecessary network requests +- [Phase 20-apply-template-and-portal-nav]: Fields fetched on mount and aiPlacementKey change so hint stays current after AI auto-place; selectedFieldHint passed as optional prop to PreparePanel for backwards compatibility ### v1.2 Pre-decisions (from research) @@ -240,6 +242,6 @@ None yet. ## Session Continuity -Last session: 2026-04-06T20:52:20.690Z -Stopped at: Completed 20-01-PLAN.md — apply template and portal nav +Last session: 2026-04-06T20:55:04.738Z +Stopped at: Completed 20-02 Task 1 — awaiting human verify checkpoint (Task 2) Resume file: None diff --git a/.planning/phases/20-apply-template-and-portal-nav/20-02-SUMMARY.md b/.planning/phases/20-apply-template-and-portal-nav/20-02-SUMMARY.md new file mode 100644 index 0000000..30814d1 --- /dev/null +++ b/.planning/phases/20-apply-template-and-portal-nav/20-02-SUMMARY.md @@ -0,0 +1,96 @@ +--- +phase: 20-apply-template-and-portal-nav +plan: 02 +subsystem: ui +tags: [react, nextjs, typescript, templates, quick-fill] + +# Dependency graph +requires: + - phase: 20-01 + provides: "Start from template in AddDocumentModal, field snapshot with fresh UUIDs, role mapping" + - phase: 18-template-schema-and-crud-api + provides: "documentTemplates table, SignatureFieldData.hint field in schema" +provides: + - "Template Hint quick-fill chip in PreparePanel for text fields with hints" + - "DocumentPageClient fetches fields and derives hint for selected field" +affects: [future template enhancements, PreparePanel quick-fill UI] + +# Tech tracking +tech-stack: + added: [] + patterns: + - "Fields state fetched in DocumentPageClient using same /api/documents/:id/fields endpoint used by handlePrepare" + - "selectedFieldHint derived from fields array lookup — no new API endpoint needed" + - "Optional prop pattern: selectedFieldHint? — undefined means no chip, existing callers unaffected" + +key-files: + created: [] + modified: + - "teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/DocumentPageClient.tsx" + - "teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/PreparePanel.tsx" + +key-decisions: + - "Fields fetched on mount and on aiPlacementKey change so hint stays current after AI auto-place" + - "selectedFieldHint passed as optional prop to PreparePanel — undefined means chip not rendered, backwards-compatible" + - "Template Hint chip placed after Client Email chip in Quick Fill section, matching exact same markup pattern" + +patterns-established: + - "Hint chip: two-span button (label + value) matching Client Name / Property Address / Email pattern" + +requirements-completed: [TMPL-13, TMPL-15, TMPL-16] + +# Metrics +duration: 2min +completed: 2026-04-06 +--- + +# Phase 20 Plan 02: Apply Template and Portal Nav (Hint Quick-fill) Summary + +**Template Hint quick-fill chip in PreparePanel surfaces text field hints from document_templates, wired via fields fetch in DocumentPageClient** + +## Performance + +- **Duration:** ~2 min +- **Started:** 2026-04-06T20:53:00Z +- **Completed:** 2026-04-06T20:54:15Z +- **Tasks:** 1 of 2 (Task 2 is human-verify checkpoint) +- **Files modified:** 2 + +## Accomplishments +- DocumentPageClient now fetches /api/documents/:id/fields on mount and after AI auto-place, storing fields in local state +- selectedFieldHint derived from selected field's hint property — zero cost, no new API endpoint +- PreparePanel accepts selectedFieldHint? prop and renders a "Template Hint" chip in the Quick Fill section when hint exists +- Backwards-compatible: existing document consumers without template hints pass no prop, no chip rendered + +## Task Commits + +Each task was committed atomically: + +1. **Task 1: Add fields state to DocumentPageClient and pass selectedFieldHint to PreparePanel** - `eec0bd9` (feat) + +## Files Created/Modified +- `teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/DocumentPageClient.tsx` - Added fields state, useEffect to fetch fields, selectedFieldHint derivation, prop pass +- `teressa-copeland-homes/src/app/portal/(protected)/documents/[docId]/_components/PreparePanel.tsx` - Added selectedFieldHint prop to interface + destructure + Template Hint chip in Quick Fill section + +## Decisions Made +- Fields fetched on mount and aiPlacementKey change so the hint refreshes after AI auto-place replaces fields +- Optional prop threading pattern maintains backwards compatibility with existing callers + +## Deviations from Plan + +None - plan executed exactly as written. + +## Issues Encountered +None. + +## User Setup Required +None - no external service configuration required. + +## Next Phase Readiness +- Task 1 complete and committed +- Task 2 (checkpoint:human-verify) awaits human verification of full template-to-document flow +- After human approval, Phase 20 (and v1.3) will be complete + +--- +*Phase: 20-apply-template-and-portal-nav* +*Completed: 2026-04-06*