3.9 KiB
3.9 KiB
Phase 4: Database & Planning Fixes - Context
Gathered: 2026-03-15 Status: Ready for planning
## Phase BoundaryFix the missing threads/thread_candidates tables in the database, fix thread creation errors, and polish the planning tab UX including empty state, thread creation flow, and list layout. No new thread features (status tracking, comparison, etc.) — those are future phases.
## Implementation DecisionsEmpty state design
- Guided + educational tone — explain what threads are for, not just "nothing here"
- Illustrated steps showing the flow: Create thread → Add candidates → Pick winner
- CTA button opens a modal dialog (not inline form)
- Should feel inviting and help new users understand the planning workflow
Thread creation flow
- Always use a modal dialog for thread creation (both empty state and when threads exist)
- Modal collects: thread name (required) + category (required)
- Add
categoryIdcolumn to threads table schema (foreign key to categories) - Candidates created in a thread auto-inherit the thread's category by default (can be overridden per candidate)
- Remove the current inline text input + button form
Planning tab layout
- Thread cards show category (icon + name) alongside existing info (candidate count, price range, date)
- Category filter — let users filter thread list by category
- Replace "Show archived threads" checkbox with Active / Resolved pill tab selector
- Threads sorted newest first by default
Claude's Discretion
- "Create thread" button placement when threads exist (header area vs floating)
- Validation UX for thread creation modal (empty name handling, duplicate warnings)
- Loading skeleton design
- Exact spacing and typography
- Category filter UI pattern (dropdown, pills, sidebar)
<code_context>
Existing Code Insights
Reusable Assets
ThreadCardcomponent (src/client/components/ThreadCard.tsx): Existing card with name, candidate count, price range, date, status badge — needs category additionCategoryHeadercomponent: Shows category emoji + name + totals — pattern for category displayuseThreads/useCreateThreadhooks: Existing data fetching and mutation hooksuseUIStore(Zustand): Panel/dialog state management — use for create thread modal- Collection empty state (
src/client/routes/collection/index.tsxlines 59-93): Pattern for empty states with emoji, heading, description, CTA button
Established Patterns
- Drizzle ORM schema in
src/db/schema.ts— add categoryId column to threads table here @hono/zod-validatorfor request validation on server routes- Service layer with db as first param for testability
- TanStack Query for data fetching with query invalidation on mutations
- Tab navigation via URL search params (gear/planning tabs)
Integration Points
src/db/schema.ts: Add categoryId to threads tablesrc/server/routes/threads.ts: Update create/update endpoints for categoryIdsrc/server/services/thread.service.ts: Update service functionssrc/shared/schemas.ts: Update Zod schemas for thread creationsrc/client/routes/collection/index.tsxPlanningView: Replace inline form with modal trigger, add empty state, add pill tabs, add category filtersrc/client/components/ThreadCard.tsx: Add category displaytests/helpers/db.ts: Update CREATE TABLE for threads to include category_id
</code_context>
## Specific Ideas- The empty state illustrated steps should visually show the 3-step planning workflow (Create thread → Add candidates → Pick winner) — make it clear what threads are for
- Pill tabs for Active/Resolved should feel like a segment control, not full page tabs
- Category on thread cards should use the same icon + name pattern used elsewhere in the app
None — discussion stayed within phase scope
Phase: 04-database-planning-fixes Context gathered: 2026-03-15