* docs: add procedural/maintenance editor redesign design Collapsible sections, fixed-height layout, drag-to-reorder steps, maintenance schedule section, and step list UX improvements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add procedural editor redesign implementation plan 7 tasks across 7 phases: collapsible sections, fixed-height layout, step list improvements, drag-to-reorder, maintenance schedule section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: restructure procedural editor with collapsible sections and fixed-height layout Convert scrolling document layout to fixed-height editor with accordion-mode collapsible sections for Details and Intake Form. Step list now gets all remaining height with independent scrolling. Add CollapsibleEditorSection component with ARIA attributes (aria-expanded, aria-controls). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add step count with time estimate header and auto-scroll to new steps Remove outer card wrapper from StepList (now rendered in scrolling container). Header shows total estimated minutes when steps have time estimates. Auto-scrolls to newly added steps using ref + scrollIntoView. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add drag-to-reorder steps with @dnd-kit Wrap step list in DndContext + SortableContext. Each step/section header gets a SortableStepWrapper with useSortable. Drag handles have accessible labels and keyboard support. procedure_end stays non-draggable and always last. Expanded steps are disabled for dragging. Array-index reorder only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add MaintenanceScheduleSection with schedule builder and summary Schedule draft state is local UI only (not in store). Hydrates form from existing schedule on load. Includes getScheduleSummary helper for collapsed section display. Two-stage save: tree first, schedule second. Schedule failure shows actionable error without rolling back tree save. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: wire maintenance schedule section into procedural editor Add collapsible Schedule section for maintenance flows with accordion integration. Schedule summary shows frequency, time, and target count when collapsed. New maintenance flows default to schedule section expanded. Two-stage save preserved: tree saved first, schedule managed independently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve lint issues in maintenance schedule and editor page Move getScheduleSummary to scheduleUtils.ts to satisfy react-refresh only-export-components rule. Add onScheduleLoaded to useEffect deps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add design and implementation revision documents Revision docs correct original plans: schedule persistence via API endpoints (not tree_structure), array-index reorder (no display_order), store minimum-one-step invariant, accordion mode, ARIA requirements, and two-stage save orchestration with failure handling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: auto-seed PR environments with SEED_ON_DEPLOY flag Release command now runs migrations + seeds test users when SEED_ON_DEPLOY=true. Tree seeding runs as a background task on startup via HTTP API. Everything is idempotent and non-fatal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add httpx to requirements for PR environment seeding Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: seed all flow types (v2, procedural, maintenance) on deploy Runs seed_trees, seed_trees_v2, seed_procedural_flows, and seed_maintenance_flows sequentially as background tasks when SEED_ON_DEPLOY=true. Each script failure is non-fatal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: trigger redeploy for full seed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- 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.