Canvas UI code editor
Use this workflow for code editor changes in
web/modules/contrib/canvas/ui/src/features/code-editor/**.
Quick triage
- •Classify the change as one of:
- •State shape or actions in
codeEditorSlice.ts. - •Lifecycle orchestration in
hooks/useCodeEditor.ts. - •Debounced save logic in
hooks/useAutoSave.tsx. - •Compilation behavior in
hooks/useSourceCode.ts. - •Serialization or derivation utilities in code editor utils files.
- •Determine whether changes affect component source, global assets, or both.
- •Enumerate side effects on compilation status, save status, and unsaved-change flags.
Invariants to preserve
- •Keep
needsAutoSaveandhasUnsavedChangestransitions consistent with user edits. - •Avoid save loops by preserving debounced and ref-guarded auto-save behavior.
- •Keep compilation error reporting explicit and user-visible.
- •Keep component props and slots serialization backward compatible unless migration is planned.
Read references/lifecycle.md for detailed lifecycle and state guidance.
High-risk touchpoints
- •
initializeCodeEditorandresetCodeEditorflow. - •
setCodeComponentPropertyand related state updates. - •
serializeProps()anddeserializeProps(). - •
derivedPropTypesmappings. - •Import and dependency tracking from component source.
Change checklist
- •Update TypeScript types first when prop or slot schema changes.
- •Update derivation and serialization together in the same patch.
- •Confirm state flags for compile/save transitions are still coherent.
- •Verify preview behavior when source code, CSS, or global CSS changes.
- •Ensure cleanup on unmount still prevents stale state.
Testing checklist
- •Run targeted Vitest tests for updated hooks, reducers, and utilities.
- •Run impacted Cypress component specs in
ui/tests/unit. - •If behavior affects end-to-end editor flow, run targeted Playwright specs.
- •Finish with full UI Vitest suite once targeted tests pass.
Read references/tests.md for command templates and file-to-test mapping hints.