CallMeDaniel Claude Opus 4.6 (1M context) commited on
Commit
f5632c1
·
1 Parent(s): 8742594

docs: add editable plan card design spec

Browse files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

docs/superpowers/specs/2026-04-12-editable-plan-card-design.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Editable Plan Card Design Spec
2
+
3
+ **Date:** 2026-04-12
4
+ **Status:** Approved
5
+
6
+ ## Problem
7
+
8
+ The plan card in the planning review gate is read-only. Users can only approve or reject the entire plan. There is no way to:
9
+ - Edit individual field values before approving
10
+ - Add notes or comments about the plan
11
+ - Ask a specific agent to help fill or refine a field
12
+ - Save partial edits and continue chatting before re-triggering a plan
13
+
14
+ ## Solution
15
+
16
+ Extend the existing inline plan card with per-field editing, an "Ask Agent" button per field, a notes text area, dual score display, and a third "Save & Continue" action button.
17
+
18
+ ## Design
19
+
20
+ ### 1. Per-Field Editing
21
+
22
+ Each plan field displays two icon buttons next to its value:
23
+
24
+ **Edit icon (pencil)** — toggles the value between read-only text and an editable input:
25
+ - `part_name`, `material`, `axis_recommendation` — text input
26
+ - `dimensions` — group of number inputs (width/height/depth in mm)
27
+ - `features`, `constraints`, `machining_notes` — comma-separated text input (parsed back to list)
28
+
29
+ **Ask Agent icon** — sends a pre-formatted, mention-targeted message to the chat. The message includes current plan context for agent awareness:
30
+ - Template: `@{agent} Regarding the plan for "{part_name}": {field-specific question}`
31
+ - Example: `@engineering Regarding the plan for "mounting_bracket": What material do you recommend given the current constraints: [min wall 3mm]?`
32
+
33
+ When the user edits a field, the plan card's local state updates immediately (no API call). Edited values are sent on Approve or Save & Continue.
34
+
35
+ **Agent-to-field mapping** (configurable in `config.yaml` under `planning.field_agents`):
36
+
37
+ | Field | Agent | Question |
38
+ |-------|-------|----------|
39
+ | `part_name` | design | What should this part be called? |
40
+ | `material` | engineering | What material do you recommend? |
41
+ | `dimensions` | engineering | What dimensions are appropriate? |
42
+ | `features` | design | What features should this part have? |
43
+ | `constraints` | cnc | What manufacturing constraints should we consider? |
44
+ | `axis_recommendation` | cnc | What axis strategy do you recommend? |
45
+ | `machining_notes` | cnc | Any machining notes to consider? |
46
+
47
+ ### 2. Notes Area
48
+
49
+ A text area at the bottom of the plan card, above the action buttons.
50
+ - Placeholder text: "Add notes about this plan..."
51
+ - Stored in the plan object as a new `notes: str` field on `DesignPlan`
52
+ - Passed to agents as additional context when the plan is approved (appended to the `render_approved()` output)
53
+ - Persisted in `designState` on Save & Continue
54
+
55
+ ### 3. Dual Score Display
56
+
57
+ Replaces the current single score display with two scores side by side:
58
+ - **Original** — the score when the plan was generated (static)
59
+ - **Current** — recalculated live as fields are edited, using the existing frontend `computeScore()` logic
60
+
61
+ Display format: `Original: 8/8 → Current: 6/8`
62
+
63
+ Current score is color-coded:
64
+ - Green if >= threshold (default 8)
65
+ - Yellow/red if below threshold
66
+
67
+ ### 4. Action Buttons
68
+
69
+ Three buttons replace the current two:
70
+
71
+ - **Approve** (green) — sends the edited plan (with field changes + notes) to `POST /api/plan/approve`. Sets `phase = "approved"`. Auto-sends "Generate the approved design" to chat.
72
+ - **Save & Continue** (secondary/blue) — merges edited field values back into `designState`, saves notes, sets `phase = "exploring"`, removes the plan card from DOM. User can keep chatting; edits preserved for the next plan trigger. Frontend-only operation (no API call), updates `designState` in localStorage.
73
+ - **Reject** (secondary/red) — discards all edits made in the plan card. Sets `phase = "exploring"`, `plan = null`.
74
+
75
+ ### 5. Ask Agent Chat Integration
76
+
77
+ When the user clicks "Ask Agent" on a field:
78
+
79
+ 1. Frontend constructs a mention-targeted message using the existing `sendMessage()` function with current plan context.
80
+ 2. Chat tab activates automatically (if user is on wizard tab).
81
+ 3. User reads the agent response in chat, then scrolls up to the plan card and edits the field manually.
82
+
83
+ No new API endpoints — reuses existing `POST /api/chat` with `@mentions` routing.
84
+
85
+ ## Data Model Changes
86
+
87
+ ### `DesignPlan` (`agents/design_state.py`)
88
+
89
+ Add field:
90
+ ```python
91
+ notes: str = ""
92
+ ```
93
+
94
+ Update `render_approved()` to include notes:
95
+ ```
96
+ ## USER NOTES
97
+ {self.notes}
98
+ ```
99
+
100
+ ### `config.yaml`
101
+
102
+ Add under `planning`:
103
+ ```yaml
104
+ planning:
105
+ field_agents:
106
+ material: engineering
107
+ dimensions: engineering
108
+ features: design
109
+ constraints: cnc
110
+ axis_recommendation: cnc
111
+ machining_notes: cnc
112
+ part_name: design
113
+ ```
114
+
115
+ ### `PlanningConfig` (`config/settings.py`)
116
+
117
+ Add field:
118
+ ```python
119
+ field_agents: dict[str, str] = {
120
+ "material": "engineering",
121
+ "dimensions": "engineering",
122
+ "features": "design",
123
+ "constraints": "cnc",
124
+ "axis_recommendation": "cnc",
125
+ "machining_notes": "cnc",
126
+ "part_name": "design",
127
+ }
128
+ ```
129
+
130
+ ## Backend Changes
131
+
132
+ - `POST /api/plan/approve` — already accepts full plan object. Add `notes` field handling: merge into `DesignState`, include in `render_approved()`.
133
+ - `POST /api/plan/reject` — no change.
134
+ - No new endpoint for Save & Continue (frontend-only operation).
135
+
136
+ ## Frontend Changes (`web/index.html`)
137
+
138
+ ### `renderPlanCard(plan)`
139
+ - Each `wizard-review-field` value gets pencil icon + agent icon buttons
140
+ - Pencil toggles between `<span>` and `<input>` for the value
141
+ - Agent icon calls `askAgentForField(fieldName)`
142
+ - Notes `<textarea>` added before action buttons
143
+ - Score area shows original + current side by side
144
+ - Three action buttons: Approve, Save & Continue, Reject
145
+
146
+ ### New functions
147
+ - `toggleFieldEdit(fieldName)` — switches field between view/edit mode
148
+ - `askAgentForField(fieldName)` — constructs mention-targeted message, calls `sendMessage()`, switches to chat tab
149
+ - `savePlanAndContinue()` — merges edited values into `designState`, saves to localStorage, removes plan card, resets phase to exploring
150
+ - `recalcPlanScore()` — reads current field values from plan card inputs, runs `computeScore()`, updates current score display
151
+
152
+ ### Modified functions
153
+ - `approvePlanCard()` — reads edited field values + notes from plan card inputs before sending to API
154
+ - `computeScore()` — no logic change, just called by `recalcPlanScore()`
155
+
156
+ ## Testing
157
+
158
+ - Verify field toggling between view/edit mode for all field types
159
+ - Verify Ask Agent sends correct mention-targeted message with plan context
160
+ - Verify notes persist through Save & Continue and appear in agent context on Approve
161
+ - Verify dual score: original stays static, current recalculates on field edit
162
+ - Verify Save & Continue preserves edits in designState and resets phase
163
+ - Verify Reject discards all edits
164
+ - Verify Approve sends edited values (not original values)