diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index 9062fcd..da170cf 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -18,7 +18,7 @@ Requirements for this milestone. Each maps to roadmap phases. - [ ] **RANK-01**: User can drag candidates to reorder priority ranking within a thread - [ ] **RANK-02**: Top 3 ranked candidates display rank badges (gold, silver, bronze) -- [ ] **RANK-03**: User can add pros and cons text per candidate displayed as bullet lists +- [x] **RANK-03**: User can add pros and cons text per candidate displayed as bullet lists - [ ] **RANK-04**: Candidate rank order persists across sessions - [ ] **RANK-05**: Drag handles and ranking are disabled on resolved threads @@ -74,7 +74,7 @@ Which phases cover which requirements. Updated during roadmap creation. | COMP-04 | Phase 12 | Pending | | RANK-01 | Phase 11 | Pending | | RANK-02 | Phase 11 | Pending | -| RANK-03 | Phase 10 | Pending | +| RANK-03 | Phase 10 | Complete | | RANK-04 | Phase 11 | Pending | | RANK-05 | Phase 11 | Pending | | IMPC-01 | Phase 13 | Pending | diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 7e00258..d827f19 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -40,7 +40,7 @@ **Milestone Goal:** Give users the tools to actually decide between candidates — compare details side-by-side, see how a pick impacts their setup, and rank/annotate their options. -- [ ] **Phase 10: Schema Foundation + Pros/Cons Fields** — Migrate schema and deliver pros/cons annotation UI +- [x] **Phase 10: Schema Foundation + Pros/Cons Fields** — Migrate schema and deliver pros/cons annotation UI (completed 2026-03-16) - [ ] **Phase 11: Candidate Ranking** — Drag-to-reorder priority ranking with rank badges - [ ] **Phase 12: Comparison View** — Side-by-side tabular comparison with relative deltas - [ ] **Phase 13: Setup Impact Preview** — Per-candidate weight and cost delta against a selected setup @@ -56,7 +56,7 @@ 2. User can save pros and cons text; the text persists across page refreshes 3. CandidateCard shows a visual indicator when a candidate has pros or cons entered 4. All existing tests pass after the schema migration (no column drift in test helper) -**Plans:** 1 plan +**Plans:** 1/1 plans complete Plans: - [ ] 10-01-PLAN.md — Add pros/cons fields through full stack (schema, service, Zod, form, card indicator) @@ -106,7 +106,7 @@ Plans: | 7. Weight Unit Selection | v1.2 | 2/2 | Complete | 2026-03-16 | | 8. Search, Filter, and Candidate Status | v1.2 | 2/2 | Complete | 2026-03-16 | | 9. Weight Classification and Visualization | v1.2 | 2/2 | Complete | 2026-03-16 | -| 10. Schema Foundation + Pros/Cons Fields | v1.3 | 0/1 | Not started | - | +| 10. Schema Foundation + Pros/Cons Fields | 1/1 | Complete | 2026-03-16 | - | | 11. Candidate Ranking | v1.3 | 0/TBD | Not started | - | | 12. Comparison View | v1.3 | 0/TBD | Not started | - | | 13. Setup Impact Preview | v1.3 | 0/TBD | Not started | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index f765fda..af8e96f 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,15 +2,15 @@ gsd_state_version: 1.0 milestone: v1.3 milestone_name: Research & Decision Tools -status: roadmap -stopped_at: Roadmap created — ready to plan Phase 10 -last_updated: "2026-03-16T19:00:00.000Z" -last_activity: 2026-03-16 -- Roadmap created for v1.3 (4 phases, 13 requirements) +status: planning +stopped_at: Completed 10-schema-foundation-pros-cons-fields/10-01-PLAN.md +last_updated: "2026-03-16T20:38:21.715Z" +last_activity: 2026-03-16 — Roadmap created for v1.3 milestone progress: total_phases: 4 - completed_phases: 0 - total_plans: 0 - completed_plans: 0 + completed_phases: 1 + total_plans: 1 + completed_plans: 1 percent: 0 --- @@ -50,6 +50,7 @@ Progress: [░░░░░░░░░░] 0% - Trend: — *Updated after each plan completion* +| Phase 10-schema-foundation-pros-cons-fields P01 | 6min | 2 tasks | 9 files | ## Accumulated Context @@ -61,6 +62,9 @@ Key v1.3 research findings (see research/SUMMARY.md): - framer-motion@12.37.0 (already installed) handles drag-to-reorder via Reorder component — no new deps - sort_order must use REAL (float) type, not INTEGER, to avoid bulk writes on every drag - Impact preview must distinguish add-mode vs replace-mode by category match — pure addition misleads +- [Phase 10-schema-foundation-pros-cons-fields]: Empty string for pros/cons stored as-is (not normalized to null); test accepts either empty string or null as cleared state +- [Phase 10-schema-foundation-pros-cons-fields]: Pros/Cons badge uses purple color to distinguish from weight (blue), price (green), category (gray), and status badges +- [Phase 10-schema-foundation-pros-cons-fields]: Field-addition ladder pattern: schema -> migration -> test helper -> service -> Zod -> types -> hook -> form -> card indicator ### Pending Todos @@ -72,6 +76,6 @@ None active. ## Session Continuity -Last session: 2026-03-16 -Stopped at: Roadmap created — 4 phases, 13 requirements mapped, ready to plan Phase 10 +Last session: 2026-03-16T20:38:21.713Z +Stopped at: Completed 10-schema-foundation-pros-cons-fields/10-01-PLAN.md Resume file: None diff --git a/.planning/phases/10-schema-foundation-pros-cons-fields/10-01-SUMMARY.md b/.planning/phases/10-schema-foundation-pros-cons-fields/10-01-SUMMARY.md new file mode 100644 index 0000000..680ff1e --- /dev/null +++ b/.planning/phases/10-schema-foundation-pros-cons-fields/10-01-SUMMARY.md @@ -0,0 +1,130 @@ +--- +phase: 10-schema-foundation-pros-cons-fields +plan: "01" +subsystem: database +tags: [drizzle, sqlite, react, forms, zod] + +# Dependency graph +requires: [] +provides: + - "pros/cons nullable TEXT columns on thread_candidates table (DB + migration)" + - "Zod schema fields: pros/cons optional strings in createCandidateSchema" + - "Service layer: createCandidate, updateCandidate, getThreadWithCandidates handle pros/cons" + - "Client CandidateForm: Pros and Cons textarea inputs with pre-fill and submit payload" + - "Client CandidateCard: purple +/- Notes badge when pros or cons text exists" + - "CandidateResponse type includes pros/cons fields" +affects: [thread-ranking, candidate-comparison, future-candidate-features] + +# Tech tracking +tech-stack: + added: [] + patterns: [field-addition-ladder, tdd-red-green] + +key-files: + created: + - drizzle/0004_soft_synch.sql + modified: + - src/db/schema.ts + - tests/helpers/db.ts + - src/server/services/thread.service.ts + - src/shared/schemas.ts + - src/client/hooks/useCandidates.ts + - src/client/components/CandidateForm.tsx + - src/client/components/CandidateCard.tsx + - src/client/routes/threads/$threadId.tsx + - tests/services/thread.service.test.ts + +key-decisions: + - "Empty string for pros/cons stored as-is by SQLite (not normalized to null) — updateCandidate test accepts empty string or null as cleared state" + - "Pros/Cons textareas placed after Notes and before Product Link — logical grouping for research annotation" + - "Visual indicator uses purple color scheme to distinguish from weight (blue), price (green), category (gray), and status badges" + +patterns-established: + - "Field-addition ladder: schema -> migration -> test helper -> service -> Zod -> types -> hook -> form -> card indicator" + - "Test helper CREATE TABLE must mirror schema.ts columns exactly — column drift causes silent test failures" + - "TDD: RED commit (failing tests) -> GREEN commit (implementation) per task" + +requirements-completed: [RANK-03] + +# Metrics +duration: 6min +completed: "2026-03-16" +--- + +# Phase 10 Plan 01: Schema Foundation Pros/Cons Fields Summary + +**Nullable pros/cons TEXT columns added to thread_candidates from SQLite schema through Drizzle migration, service layer, Zod validation, React form inputs, and CandidateCard visual badge** + +## Performance + +- **Duration:** 6 min +- **Started:** 2026-03-16T20:30:18Z +- **Completed:** 2026-03-16T20:36:25Z +- **Tasks:** 2 +- **Files modified:** 9 + +## Accomplishments +- Added pros/cons columns to threadCandidates schema and applied Drizzle migration (0004_soft_synch.sql) +- Wired pros/cons through all backend layers: service create/update/get + Zod schemas +- Added Pros and Cons textarea inputs to CandidateForm with pre-fill in edit mode +- Added purple "+/- Notes" badge to CandidateCard when either field has content +- 28 thread service tests passing (24 existing + 4 new) with zero regressions + +## Task Commits + +Each task was committed atomically: + +1. **TDD RED - failing tests** - `719f708` (test) +2. **Task 1: Add pros/cons columns through backend + tests** - `7a64a18` (feat) +3. **Task 2: Wire pros/cons through client hooks, form, and card indicator** - `4f2aefe` (feat) + +_Note: TDD task has separate test commit (RED) and implementation commit (GREEN)_ + +## Files Created/Modified +- `src/db/schema.ts` - Added pros/cons nullable TEXT columns to threadCandidates +- `drizzle/0004_soft_synch.sql` - Migration: ALTER TABLE thread_candidates ADD COLUMN pros/cons +- `tests/helpers/db.ts` - Mirrored pros/cons in CREATE TABLE thread_candidates +- `src/server/services/thread.service.ts` - pros/cons in createCandidate values(), updateCandidate Partial type, getThreadWithCandidates select +- `src/shared/schemas.ts` - pros/cons optional string fields in createCandidateSchema (updateCandidateSchema inherits via .partial()) +- `src/client/hooks/useCandidates.ts` - pros/cons added to CandidateResponse interface +- `src/client/components/CandidateForm.tsx` - Pros and Cons textareas, FormData fields, INITIAL_FORM, pre-fill, payload +- `src/client/components/CandidateCard.tsx` - props, destructuring, purple +/- Notes badge +- `src/client/routes/threads/$threadId.tsx` - pros={candidate.pros} cons={candidate.cons} passed to CandidateCard +- `tests/services/thread.service.test.ts` - 4 new test cases for pros/cons create/update/get + +## Decisions Made +- Empty string for pros/cons is stored as-is (not normalized to null on empty); the test accepts either empty string or null as "cleared" state since SQLite/Drizzle does not coerce empty strings. +- Visual indicator uses purple to distinguish from existing badge color scheme (blue=weight, green=price, gray=category, status has its own colors). +- Textarea placement (after Notes, before Product Link) groups annotation fields logically. + +## Deviations from Plan + +None - plan executed exactly as written. + +## Issues Encountered + +Pre-existing lint violations discovered in files outside the plan scope: +- `src/client/components/WeightSummaryCard.tsx`, `src/client/routes/collection/index.tsx`, `src/client/routes/index.tsx`, `src/client/routes/setups/$setupId.tsx` — format/organizeImports errors +- `.obsidian/workspace.json` — Biome format error (IDE file, should be excluded) + +These are logged to `deferred-items.md` and not fixed (out of scope per deviation scope boundary rule). + +## User Setup Required + +None - no external service configuration required. + +## Next Phase Readiness +- RANK-03 fully implemented: pros/cons fields on candidates, editable via form, persisted in SQLite, with visual badge indicator +- Schema foundation complete — subsequent plans in phase 10 can build ranking/sorting features on top of this data +- No blockers + +--- +*Phase: 10-schema-foundation-pros-cons-fields* +*Completed: 2026-03-16* + +## Self-Check: PASSED + +All files and commits verified: +- All 10 key files present on disk +- All 3 task commits found in git log (719f708, 7a64a18, 4f2aefe) +- Key artifact strings confirmed in each file (pros: text, pros TEXT, pros: z.string, candidate-pros, pros || cons) diff --git a/.planning/phases/10-schema-foundation-pros-cons-fields/deferred-items.md b/.planning/phases/10-schema-foundation-pros-cons-fields/deferred-items.md new file mode 100644 index 0000000..eb77b8f --- /dev/null +++ b/.planning/phases/10-schema-foundation-pros-cons-fields/deferred-items.md @@ -0,0 +1,13 @@ +# Deferred Items + +## Pre-existing Lint Violations (Out of Scope for 10-01) + +These Biome lint/format errors existed before phase 10-01 and are not caused by any changes in this plan. They should be addressed in a separate cleanup task. + +- `src/client/components/WeightSummaryCard.tsx` - format violation (line length) +- `src/client/routes/collection/index.tsx` - organizeImports, format violations +- `src/client/routes/index.tsx` - organizeImports, format violations +- `src/client/routes/setups/$setupId.tsx` - organizeImports violations +- `.obsidian/workspace.json` - format violations (IDE file, should be excluded from Biome) + +Discovered during: Task 2 lint verification