Move completed plan docs to docs/plans/archive/. Add survey migration 046 and reference HTML/plan files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7.3 KiB
7.3 KiB
Procedural Editor Redesign - Implementation Revisions
Date: 2026-02-19 Revises:
docs/plans/2026-02-19-procedural-editor-redesign-impl.mdRelated Design Revision:docs/plans/2026-02-19-procedural-editor-redesign-design-revisions.md
Goal
Revise the implementation plan so it matches actual architecture and APIs, with explicit handling for maintenance schedule persistence, step-list invariants, DnD constraints, and accessibility/test requirements.
Critical Corrections from Original Impl Plan
- Do not treat maintenance schedule as part of
tree_structure. - Do not use
display_orderfor procedural step reorder. - Do not assume
0 stepsstate unless store invariant is changed intentionally. - Do not list
@dnd-kit/*as new dependency (already installed). - Add explicit save orchestration for unsaved maintenance flows.
- Add explicit failure handling when tree save succeeds but schedule save fails.
Phase 0: Scope Lock
Task 0.1 - Confirm invariants and UX ownership
Decisions to lock in code before implementation:
procedure_endremains fixed, non-draggable, last.- Minimum one
procedure_stepremains enforced (recommended). - Schedule editing in editor is source-of-truth for create/edit, with detail page as display/secondary entrypoint.
Files: none (decision checkpoint)
Phase 1: Layout and Collapsible Sections
Task 1.1 - Add shared collapsible wrapper
Files:
- Create:
frontend/src/components/procedural-editor/CollapsibleEditorSection.tsx
Requirements:
- Single-row collapsed summary.
- Keyboard-accessible toggle button.
aria-expanded,aria-controls, and sectionid.- Optional
defaultExpanded.
Task 1.2 - Convert ProceduralEditorPage to fixed-height editor
Files:
- Modify:
frontend/src/pages/ProceduralEditorPage.tsx
Changes:
- Outer layout becomes
flex h-full flex-col overflow-hidden. - Toolbar becomes sticky.
- Details and Intake wrapped in
CollapsibleEditorSection. - Steps area becomes
flex-1 min-h-0 overflow-y-auto. - Accordion mode: only one section open at a time (explicit state in page component).
Summaries:
- Details:
"Name" - N tags - Public/Private. - Intake:
N fields: label1, label2...(truncate).
Phase 2: StepList Behavior and DnD
Task 2.1 - Align header/empty behavior with current store invariant
Files:
- Modify:
frontend/src/components/procedural-editor/StepList.tsx - Optional invariant change (if desired):
frontend/src/store/proceduralEditorStore.ts
Required behavior (recommended):
- Keep minimum one
procedure_step. - Remove/unset any
0 stepsUI paths. - Header shows:
Steps (N steps - ~M min)when estimates existSteps (N steps)otherwise.
Task 2.2 - Ensure new step auto-expands + scrolls into view
Files:
- Modify:
frontend/src/components/procedural-editor/StepList.tsx - Verify existing store behavior in
frontend/src/store/proceduralEditorStore.ts
Behavior:
- On add step/section, expanded editor opens immediately.
- Newly inserted row is scrolled into view via stable element refs (prefer scroll target by id over "scroll to bottom").
Task 2.3 - Implement DnD with current model constraints
Files:
- Modify:
frontend/src/components/procedural-editor/StepList.tsx - Modify:
frontend/src/store/proceduralEditorStore.ts(reusemoveStep)
Rules:
- Draggable:
procedure_step,section_header. - Non-draggable:
procedure_end. - Reorder by array index only.
- No
display_orderrecalculation for steps. - Keyboard drag support and visible insertion indicator.
Phase 3: Maintenance Schedule Section (Correct API orchestration)
Task 3.1 - Add schedule section component
Files:
- Create:
frontend/src/components/procedural-editor/MaintenanceScheduleSection.tsx - Modify:
frontend/src/pages/ProceduralEditorPage.tsx
Behavior:
- Render only for
treeType === 'maintenance'. - Capture:
- cron expression
- timezone
- target list id
- Collapsed summary:
- configured: human-readable cadence + target list status
- unconfigured:
No schedule configured.
Task 3.2 - Add schedule draft UI state and save orchestration
Files:
- Modify:
frontend/src/store/proceduralEditorStore.ts(UI draft state only) - Modify:
frontend/src/pages/ProceduralEditorPage.tsx - Use:
frontend/src/api/maintenanceSchedules.ts
Save flow:
- Save tree first (
create/update). - If maintenance and schedule draft present:
- if existing schedule id:
maintenanceSchedulesApi.update - else:
maintenanceSchedulesApi.createwith saved tree id.
- If schedule save fails:
- keep tree save success
- show actionable error toast/banner
- preserve schedule draft as dirty.
Task 3.3 - Existing flow load
Files:
- Modify:
frontend/src/pages/ProceduralEditorPage.tsx
Behavior:
- On edit maintenance flow, fetch schedule via
getForTree(treeId). - 404 = no schedule yet (valid state).
- Hydrate schedule draft state for section UI.
Phase 4: Integration polish and consistency
Task 4.1 - Clarify MaintenanceFlowDetailPage role
Files:
- Modify (if needed):
frontend/src/pages/MaintenanceFlowDetailPage.tsx
Decision implementation:
- Keep schedule read-only there, with "Edit in Flow Editor" CTA.
- Avoid split-brain schedule edits in two places unless explicitly desired.
Phase 5: Tests and verification
Task 5.1 - Automated tests
Files (new/updated):
frontend/src/components/procedural-editor/StepList.test.tsxfrontend/src/pages/ProceduralEditorPage.test.tsxfrontend/src/store/proceduralEditorStore.test.ts(if absent, add focused tests)
Minimum coverage:
- Reorder respects
procedure_endconstraints. - New steps auto-expand and scroll target call occurs.
- Accordion open/close state and summaries.
- Maintenance save orchestration:
- tree create/update then schedule create/update
- schedule failure does not revert tree success.
Task 5.2 - Manual acceptance checklist
- Steps list remains primary viewport focus in fixed-height layout.
- Details/Intake/Schedule sections collapse and summarize correctly.
- DnD works by mouse and keyboard.
- End step never drags.
- New maintenance flow:
- can save draft without schedule
- can save with schedule in one action (tree first, schedule second).
- Existing maintenance flow loads schedule and saves edits.
Task 5.3 - Build and lint gates
cd frontend && npm run buildcd frontend && npm run testcd frontend && npm run lint
File Impact (Revised)
Create
frontend/src/components/procedural-editor/CollapsibleEditorSection.tsxfrontend/src/components/procedural-editor/MaintenanceScheduleSection.tsx
Modify
frontend/src/pages/ProceduralEditorPage.tsxfrontend/src/components/procedural-editor/StepList.tsxfrontend/src/components/procedural-editor/IntakeFormBuilder.tsxfrontend/src/store/proceduralEditorStore.tsfrontend/src/pages/MaintenanceFlowDetailPage.tsx(if ownership adjusted)
Existing APIs used
frontend/src/api/maintenanceSchedules.ts- target list API module(s) if inline list selection/creation is implemented
Out of Scope (unchanged)
- Intake field DnD reorder.
- Procedural undo/redo parity.
- Step templates/presets.
- Bulk step operations.
- Backend schema/model changes for procedural steps.