---
phase: 13-setup-impact-preview
plan: 02
type: execute
wave: 2
depends_on: ["13-01"]
files_modified:
- src/client/components/SetupImpactSelector.tsx
- src/client/components/ImpactDeltaBadge.tsx
- src/client/routes/threads/$threadId.tsx
- src/client/components/CandidateListItem.tsx
- src/client/components/CandidateCard.tsx
- src/client/components/ComparisonTable.tsx
autonomous: true
requirements: [IMPC-01, IMPC-02, IMPC-03, IMPC-04]
must_haves:
truths:
- "User can select a setup from a dropdown in the thread header"
- "Each candidate displays weight and cost delta badges when a setup is selected"
- "Replace mode shows signed delta with replaced item name context"
- "Add mode shows positive delta labeled as '(add)'"
- "Candidate with no weight shows '-- (no weight data)' instead of a zero"
- "Candidate with no price shows '-- (no price data)' instead of a zero"
- "Deselecting setup ('None') clears all delta indicators"
- "Deltas appear in list view, grid view, and comparison table"
artifacts:
- path: "src/client/components/SetupImpactSelector.tsx"
provides: "Setup dropdown for thread header"
exports: ["SetupImpactSelector"]
- path: "src/client/components/ImpactDeltaBadge.tsx"
provides: "Inline delta indicator component"
exports: ["ImpactDeltaBadge"]
- path: "src/client/routes/threads/$threadId.tsx"
provides: "Thread detail page wired with impact preview"
- path: "src/client/components/CandidateListItem.tsx"
provides: "List item with delta badges"
- path: "src/client/components/CandidateCard.tsx"
provides: "Card with delta badges"
- path: "src/client/components/ComparisonTable.tsx"
provides: "Comparison table with impact delta rows"
key_links:
- from: "src/client/routes/threads/$threadId.tsx"
to: "src/client/hooks/useImpactDeltas.ts"
via: "useImpactDeltas hook call at page level"
pattern: "useImpactDeltas"
- from: "src/client/routes/threads/$threadId.tsx"
to: "src/client/hooks/useSetups.ts"
via: "useSetup(selectedSetupId) for setup item data"
pattern: "useSetup\\(selectedSetupId"
- from: "src/client/routes/threads/$threadId.tsx"
to: "src/client/stores/uiStore.ts"
via: "selectedSetupId state read"
pattern: "useUIStore.*selectedSetupId"
- from: "src/client/components/SetupImpactSelector.tsx"
to: "src/client/stores/uiStore.ts"
via: "setSelectedSetupId state write"
pattern: "setSelectedSetupId"
- from: "src/client/components/ImpactDeltaBadge.tsx"
to: "src/client/lib/impactDeltas.ts"
via: "CandidateDelta type import"
pattern: "import.*CandidateDelta"
- from: "src/client/components/ComparisonTable.tsx"
to: "src/client/lib/impactDeltas.ts"
via: "ImpactDeltas type for deltas prop"
pattern: "import.*ImpactDeltas"
---
Build the UI components (setup dropdown + delta badges) and wire them into the thread detail page across all three view modes (list, grid, compare).
Purpose: This is the user-facing delivery of the impact preview feature. Plan 01 built the logic; this plan renders it.
Output: SetupImpactSelector component, ImpactDeltaBadge component, updated CandidateListItem/CandidateCard/ComparisonTable with delta rendering, wired thread detail page.
@/home/jlmak/.claude/get-shit-done/workflows/execute-plan.md
@/home/jlmak/.claude/get-shit-done/templates/summary.md
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/13-setup-impact-preview/13-RESEARCH.md
@.planning/phases/13-setup-impact-preview/13-01-SUMMARY.md
From src/client/lib/impactDeltas.ts (created in Plan 01):
```typescript
export interface CandidateInput {
id: number;
weightGrams: number | null;
priceCents: number | null;
}
export type DeltaMode = "replace" | "add" | "none";
export interface CandidateDelta {
candidateId: number;
mode: DeltaMode;
weightDelta: number | null;
priceDelta: number | null;
replacedItemName: string | null;
}
export interface ImpactDeltas {
mode: DeltaMode;
deltas: Record;
}
```
From src/client/hooks/useImpactDeltas.ts (created in Plan 01):
```typescript
export function useImpactDeltas(
candidates: CandidateInput[],
setupItems: SetupItemWithCategory[] | undefined,
threadCategoryId: number,
): ImpactDeltas;
```
From src/client/hooks/useSetups.ts:
```typescript
export function useSetups(): UseQueryResult;
export function useSetup(setupId: number | null): UseQueryResult;
```
From src/client/stores/uiStore.ts (updated in Plan 01):
```typescript
selectedSetupId: number | null;
setSelectedSetupId: (id: number | null) => void;
```
From src/client/hooks/useThreads.ts (updated in Plan 01):
```typescript
interface ThreadWithCandidates {
id: number;
name: string;
status: "active" | "resolved";
resolvedCandidateId: number | null;
categoryId: number; // <-- Added in Plan 01
createdAt: string;
updatedAt: string;
candidates: CandidateWithCategory[];
}
```
From src/client/lib/formatters.ts:
```typescript
export function formatWeight(grams: number | null | undefined, unit: WeightUnit = "g"): string;
export function formatPrice(cents: number | null | undefined, currency: Currency = "USD"): string;
```
Existing component props that need delta additions:
CandidateListItem props:
```typescript
interface CandidateListItemProps {
candidate: CandidateWithCategory;
rank: number;
isActive: boolean;
onStatusChange: (status: "researching" | "ordered" | "arrived") => void;
// Will add: delta?: CandidateDelta;
}
```
CandidateCard props:
```typescript
interface CandidateCardProps {
id: number;
name: string;
weightGrams: number | null;
priceCents: number | null;
// ... other props
// Will add: delta?: CandidateDelta;
}
```
ComparisonTable props:
```typescript
interface ComparisonTableProps {
candidates: CandidateWithCategory[];
resolvedCandidateId: number | null;
// Will add: deltas?: Record;
}
```
Task 1: Create SetupImpactSelector and ImpactDeltaBadge componentssrc/client/components/SetupImpactSelector.tsx, src/client/components/ImpactDeltaBadge.tsx
1. Create src/client/components/SetupImpactSelector.tsx:
- Import useSetups from hooks/useSetups
- Import useUIStore from stores/uiStore
- Export function SetupImpactSelector()
- Read selectedSetupId and setSelectedSetupId from uiStore
- Fetch setups via useSetups()
- If no setups or loading, return null
- Render: a flex row with label "Impact on setup:" (text-xs text-gray-500) and a native `cd /home/jlmak/Projects/jlmak/GearBox && bun run lint 2>&1 | head -20SetupImpactSelector renders a setup dropdown reading from uiStore. ImpactDeltaBadge renders signed, colored delta indicators with null-data handling. Both components lint-clean.Task 2: Wire impact preview into thread detail page and all candidate viewssrc/client/routes/threads/$threadId.tsx, src/client/components/CandidateListItem.tsx, src/client/components/CandidateCard.tsx, src/client/components/ComparisonTable.tsx
1. In src/client/routes/threads/$threadId.tsx:
- Add imports: useSetup from hooks/useSetups, useImpactDeltas from hooks/useImpactDeltas, SetupImpactSelector from components/SetupImpactSelector, type CandidateDelta from lib/impactDeltas
- Read selectedSetupId from useUIStore: `const selectedSetupId = useUIStore((s) => s.selectedSetupId);`
- Fetch setup data: `const { data: setupData } = useSetup(selectedSetupId ?? null);`
- Compute deltas: `const impactDeltas = useImpactDeltas(thread.candidates, setupData?.items, thread.categoryId);` (place after thread is loaded, inside the render body after the isLoading/isError guards)
- Place `` in the header section, after the thread name/status row and before the toolbar. Wrap it in a div for spacing if needed.
- Pass delta to CandidateListItem: add prop `delta={impactDeltas.deltas[candidate.id]}` to each CandidateListItem (both Reorder.Group and static div renderings)
- Pass delta to CandidateCard: add prop `delta={impactDeltas.deltas[candidate.id]}` (the CandidateCard receives individual props, so pass it as `delta={impactDeltas.deltas[candidate.id]}`)
- Pass deltas to ComparisonTable: add prop `deltas={impactDeltas.deltas}` alongside existing candidates and resolvedCandidateId
2. In src/client/components/CandidateListItem.tsx:
- Import type CandidateDelta from lib/impactDeltas
- Import ImpactDeltaBadge from ./ImpactDeltaBadge
- Add `delta?: CandidateDelta;` to CandidateListItemProps
- Add `delta` to destructured props
- Render two ImpactDeltaBadge components inside the badges flex-wrap div (after the existing weight and price badges):
- `{delta && }`
- `{delta && }`
- Place these AFTER the existing weight/price badges so they appear as secondary indicators
3. In src/client/components/CandidateCard.tsx:
- Import type CandidateDelta from lib/impactDeltas
- Import ImpactDeltaBadge from ./ImpactDeltaBadge
- Add `delta?: CandidateDelta;` to CandidateCardProps
- Add `delta` to destructured props
- Render two ImpactDeltaBadge components inside the badges flex-wrap div (after weight/price badges):
- `{delta && }`
- `{delta && }`
4. In src/client/components/ComparisonTable.tsx:
- Import type CandidateDelta from lib/impactDeltas
- Import ImpactDeltaBadge from ./ImpactDeltaBadge
- Add `deltas?: Record;` to ComparisonTableProps
- Add `deltas` to destructured props
- Add two new rows to ATTRIBUTE_ROWS array, placed right after the "weight" row and "price" row respectively:
a. After "weight" row, add:
```
{
key: "impact-weight",
label: "Impact (wt)",
render: (c) => deltas?.[c.id] ? : --,
}
```
b. After "price" row, add:
```
{
key: "impact-price",
label: "Impact ($)",
render: (c) => deltas?.[c.id] ? : --,
}
```
- These are separate rows (per research recommendation) to avoid conflating candidate-relative deltas with setup impact deltas.
- The impact rows show "--" when no setup is selected (deltas undefined or no entry for candidate).
cd /home/jlmak/Projects/jlmak/GearBox && bun test && bun run lint 2>&1 | head -20
- SetupImpactSelector dropdown visible in thread header
- Selecting a setup shows weight/cost delta badges on each candidate in list, grid, and compare views
- Replace mode: signed delta with green (lighter/cheaper) or red (heavier/pricier) coloring
- Add mode: positive delta with "(add)" label
- Null weight/price: shows "-- (no weight data)" / "-- (no price data)" indicator
- Deselecting setup clears all delta indicators
- ComparisonTable has dedicated "Impact (wt)" and "Impact ($)" rows
- All tests pass, lint clean
- `bun test` full suite passes
- `bun run lint` clean
- SetupImpactSelector renders in thread header with all setups as options
- Selecting a setup triggers useSetup fetch and delta computation
- CandidateListItem, CandidateCard, ComparisonTable all render delta badges
- Replace mode detected when setup has item in same category as thread
- Add mode used otherwise
- Null weight/price shows clear indicator
- Deselecting shows no deltas (clean state)
- All four IMPC requirements visible in the UI
- Delta rendering works across list, grid, and compare views
- No regressions in existing functionality
- Clean lint output