Repository navigation
Refactor BaseNodeViewer to be fully type-agnostic (closes #698) - #705
Conversation
Remove all hardcoded node-type-specific logic from BaseNodeViewer and delegate to plugin system. ## Changes ### Plugin Interface Extension (types.ts) - Add `extractMetadata?: (node) => Record<string, unknown>` - Type-specific property transformations - Add `mapStateToSchema?: (state, fieldName) => unknown` - UI state to schema value mapping - Add `acceptsContentMerge?: boolean` - Control content merge behavior (default: true) ### Plugin Implementations (core-plugins.ts) - **taskNodePlugin**: Implement `extractMetadata` and `mapStateToSchema` for task state handling - **codeBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content - **quoteBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content ### Plugin Registry Helpers (plugin-registry.ts) - Add `extractNodeMetadata(node)` - Delegate to plugin's extractMetadata or return properties as-is - Add `mapStateToSchema(nodeType, state, fieldName)` - Delegate to plugin's mapStateToSchema or return state as-is - Add `acceptsContentMerge(nodeType)` - Check plugin's acceptsContentMerge flag (default: true) ### BaseNodeViewer Refactoring (base-node-viewer.svelte) - Remove hardcoded `STRUCTURED_NODE_TYPES` array - Remove `isStructuredNode()` function - replaced with `pluginRegistry.acceptsContentMerge()` - Remove `extractNodeMetadata()` task-specific logic - replaced with `pluginRegistry.extractNodeMetadata()` - Remove `mapNodeStateToSchemaStatus()` function - replaced with `pluginRegistry.mapStateToSchema()` - Remove unused `CoreTaskStatus` import ## Testing - All 728 frontend tests passing - All Rust tests passing - No lint or type errors - Verified task state cycling still works - Verified backspace protection for code-block and quote-block still works 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis PR successfully refactors BaseNodeViewer to eliminate all hardcoded node-type-specific logic, delegating type-specific behaviors to the plugin system. The implementation follows clean architecture principles and maintains backward compatibility while significantly improving extensibility. Overall Assessment: ✅ APPROVE The refactoring is well-executed with proper separation of concerns, comprehensive testing, and no regressions. All acceptance criteria are met. Requirements CheckBased on Issue #698 acceptance criteria: ✅ No hardcoded
✅ No hardcoded
✅ Plugin interface extended with optional type-specific methods
✅ TaskNode plugin implements
✅ Code-block and quote-block plugins implement
✅
✅ All existing task state cycling functionality works
✅ All existing backspace/merge protection works for structured nodes
✅ All tests pass
✅ Code passes
Code Review FindingsArchitecture & Design Excellence[Exemplary] Plugin Registry Pattern
[Exemplary] Plugin Registry Pattern
[Exemplary] Plugin Registry Pattern
[Exemplary] Plugin Isolation
Maintainability & Readability[Strength] Code Deletion
[Strength] Clear Documentation
[Strength] Consistent Naming
Testing & Robustness[Verified] Test Coverage
[Verified] Backward Compatibility
Performance[Good] Efficient Lookups
Potential Improvements (Optional - Not Blockers)[Nit] Documentation Consistency
[Nit] Type Safety Enhancement
RecommendationAPPROVE - This PR successfully achieves all stated objectives with high code quality:
The optional improvements noted above are minor polish items that don't warrant blocking this PR. The implementation is production-ready and follows all project standards. |
Review Complete✅ RECOMMENDATION: APPROVE This PR is ready to merge. All acceptance criteria verified, all tests passing, no regressions detected. Key Achievements:
The two optional improvements (JSDoc example, generic type) are minor enhancements that don't warrant blocking this PR. |
Enhanced plugin interface documentation and type safety based on code review feedback: 1. Added JSDoc @example to extractMetadata (types.ts) - Concrete usage example showing task node transformation - Clarifies expected input/output format 2. Added generic type parameter to mapStateToSchema (plugin-registry.ts) - Enables compile-time type checking for return values - Includes usage examples in JSDoc - Default fallback to 'unknown' maintains backward compatibility Both improvements are additive with no breaking changes or behavioral modifications. All 1477 tests passing. Addresses optional recommendations from pragmatic code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Review Feedback Addressed ✅I've implemented both optional improvements from the code review: Changes Made1. Enhanced JSDoc for
2. Added Generic Type Parameter to
Verification✅ All 1477 tests passing (no regressions) Implementation DecisionBoth suggestions were implemented because:
No recommendations were skipped - all feedback addressed. Commit: a3987a2 |
* Refactor BaseNodeViewer to be fully type-agnostic (closes #698) Remove all hardcoded node-type-specific logic from BaseNodeViewer and delegate to plugin system. ## Changes ### Plugin Interface Extension (types.ts) - Add `extractMetadata?: (node) => Record<string, unknown>` - Type-specific property transformations - Add `mapStateToSchema?: (state, fieldName) => unknown` - UI state to schema value mapping - Add `acceptsContentMerge?: boolean` - Control content merge behavior (default: true) ### Plugin Implementations (core-plugins.ts) - **taskNodePlugin**: Implement `extractMetadata` and `mapStateToSchema` for task state handling - **codeBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content - **quoteBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content ### Plugin Registry Helpers (plugin-registry.ts) - Add `extractNodeMetadata(node)` - Delegate to plugin's extractMetadata or return properties as-is - Add `mapStateToSchema(nodeType, state, fieldName)` - Delegate to plugin's mapStateToSchema or return state as-is - Add `acceptsContentMerge(nodeType)` - Check plugin's acceptsContentMerge flag (default: true) ### BaseNodeViewer Refactoring (base-node-viewer.svelte) - Remove hardcoded `STRUCTURED_NODE_TYPES` array - Remove `isStructuredNode()` function - replaced with `pluginRegistry.acceptsContentMerge()` - Remove `extractNodeMetadata()` task-specific logic - replaced with `pluginRegistry.extractNodeMetadata()` - Remove `mapNodeStateToSchemaStatus()` function - replaced with `pluginRegistry.mapStateToSchema()` - Remove unused `CoreTaskStatus` import ## Testing - All 728 frontend tests passing - All Rust tests passing - No lint or type errors - Verified task state cycling still works - Verified backspace protection for code-block and quote-block still works 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Improve documentation and type safety Enhanced plugin interface documentation and type safety based on code review feedback: 1. Added JSDoc @example to extractMetadata (types.ts) - Concrete usage example showing task node transformation - Clarifies expected input/output format 2. Added generic type parameter to mapStateToSchema (plugin-registry.ts) - Enables compile-time type checking for return values - Includes usage examples in JSDoc - Default fallback to 'unknown' maintains backward compatibility Both improvements are additive with no breaking changes or behavioral modifications. All 1477 tests passing. Addresses optional recommendations from pragmatic code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
* Refactor BaseNodeViewer to be fully type-agnostic (closes #698) Remove all hardcoded node-type-specific logic from BaseNodeViewer and delegate to plugin system. ## Changes ### Plugin Interface Extension (types.ts) - Add `extractMetadata?: (node) => Record<string, unknown>` - Type-specific property transformations - Add `mapStateToSchema?: (state, fieldName) => unknown` - UI state to schema value mapping - Add `acceptsContentMerge?: boolean` - Control content merge behavior (default: true) ### Plugin Implementations (core-plugins.ts) - **taskNodePlugin**: Implement `extractMetadata` and `mapStateToSchema` for task state handling - **codeBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content - **quoteBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content ### Plugin Registry Helpers (plugin-registry.ts) - Add `extractNodeMetadata(node)` - Delegate to plugin's extractMetadata or return properties as-is - Add `mapStateToSchema(nodeType, state, fieldName)` - Delegate to plugin's mapStateToSchema or return state as-is - Add `acceptsContentMerge(nodeType)` - Check plugin's acceptsContentMerge flag (default: true) ### BaseNodeViewer Refactoring (base-node-viewer.svelte) - Remove hardcoded `STRUCTURED_NODE_TYPES` array - Remove `isStructuredNode()` function - replaced with `pluginRegistry.acceptsContentMerge()` - Remove `extractNodeMetadata()` task-specific logic - replaced with `pluginRegistry.extractNodeMetadata()` - Remove `mapNodeStateToSchemaStatus()` function - replaced with `pluginRegistry.mapStateToSchema()` - Remove unused `CoreTaskStatus` import ## Testing - All 728 frontend tests passing - All Rust tests passing - No lint or type errors - Verified task state cycling still works - Verified backspace protection for code-block and quote-block still works 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Improve documentation and type safety Enhanced plugin interface documentation and type safety based on code review feedback: 1. Added JSDoc @example to extractMetadata (types.ts) - Concrete usage example showing task node transformation - Clarifies expected input/output format 2. Added generic type parameter to mapStateToSchema (plugin-registry.ts) - Enables compile-time type checking for return values - Includes usage examples in JSDoc - Default fallback to 'unknown' maintains backward compatibility Both improvements are additive with no breaking changes or behavioral modifications. All 1477 tests passing. Addresses optional recommendations from pragmatic code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
* Refactor BaseNodeViewer to be fully type-agnostic (closes #698) Remove all hardcoded node-type-specific logic from BaseNodeViewer and delegate to plugin system. ## Changes ### Plugin Interface Extension (types.ts) - Add `extractMetadata?: (node) => Record<string, unknown>` - Type-specific property transformations - Add `mapStateToSchema?: (state, fieldName) => unknown` - UI state to schema value mapping - Add `acceptsContentMerge?: boolean` - Control content merge behavior (default: true) ### Plugin Implementations (core-plugins.ts) - **taskNodePlugin**: Implement `extractMetadata` and `mapStateToSchema` for task state handling - **codeBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content - **quoteBlockNodePlugin**: Set `acceptsContentMerge: false` to protect structured content ### Plugin Registry Helpers (plugin-registry.ts) - Add `extractNodeMetadata(node)` - Delegate to plugin's extractMetadata or return properties as-is - Add `mapStateToSchema(nodeType, state, fieldName)` - Delegate to plugin's mapStateToSchema or return state as-is - Add `acceptsContentMerge(nodeType)` - Check plugin's acceptsContentMerge flag (default: true) ### BaseNodeViewer Refactoring (base-node-viewer.svelte) - Remove hardcoded `STRUCTURED_NODE_TYPES` array - Remove `isStructuredNode()` function - replaced with `pluginRegistry.acceptsContentMerge()` - Remove `extractNodeMetadata()` task-specific logic - replaced with `pluginRegistry.extractNodeMetadata()` - Remove `mapNodeStateToSchemaStatus()` function - replaced with `pluginRegistry.mapStateToSchema()` - Remove unused `CoreTaskStatus` import ## Testing - All 728 frontend tests passing - All Rust tests passing - No lint or type errors - Verified task state cycling still works - Verified backspace protection for code-block and quote-block still works 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Improve documentation and type safety Enhanced plugin interface documentation and type safety based on code review feedback: 1. Added JSDoc @example to extractMetadata (types.ts) - Concrete usage example showing task node transformation - Clarifies expected input/output format 2. Added generic type parameter to mapStateToSchema (plugin-registry.ts) - Enables compile-time type checking for return values - Includes usage examples in JSDoc - Default fallback to 'unknown' maintains backward compatibility Both improvements are additive with no breaking changes or behavioral modifications. All 1477 tests passing. Addresses optional recommendations from pragmatic code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
Summary
Refactored BaseNodeViewer to remove all hardcoded node-type-specific logic and delegate to the plugin system. This makes BaseNodeViewer fully type-agnostic and follows the established plugin architecture pattern.
Changes
1. Plugin Interface Extension (
src/lib/plugins/types.ts)extractMetadata?: (node) => Record<string, unknown>- Type-specific property transformationsmapStateToSchema?: (state, fieldName) => unknown- UI state to schema value mappingacceptsContentMerge?: boolean- Control content merge behavior (default: true)2. Plugin Implementations (
src/lib/plugins/core-plugins.ts)extractMetadataandmapStateToSchemafor task state handlingacceptsContentMerge: falseto protect structured contentacceptsContentMerge: falseto protect structured content3. Plugin Registry Helpers (
src/lib/plugins/plugin-registry.ts)extractNodeMetadata(node)- Delegate to plugin or return properties as-ismapStateToSchema(nodeType, state, fieldName)- Delegate to plugin or return state as-isacceptsContentMerge(nodeType)- Check plugin flag (default: true)4. BaseNodeViewer Refactoring (
src/lib/design/components/base-node-viewer.svelte)STRUCTURED_NODE_TYPESarrayisStructuredNode()function →pluginRegistry.acceptsContentMerge()extractNodeMetadata()logic →pluginRegistry.extractNodeMetadata()mapNodeStateToSchemaStatus()function →pluginRegistry.mapStateToSchema()CoreTaskStatusimportTesting
✅ All 728 frontend tests passing
✅ All Rust tests passing
✅ No lint or type errors
✅ Verified task state cycling still works
✅ Verified backspace protection for code-block and quote-block still works
Test Results
Frontend Tests: 728 passed (same as baseline)
Rust Tests: All passing (same as baseline)
Acceptance Criteria
nodeType === 'task'checks in BaseNodeViewerSTRUCTURED_NODE_TYPESarray in BaseNodeViewerextractMetadataandmapStateToSchemaacceptsContentMerge: falseisStructuredNode()replaced with plugin registry lookupbun run quality:fix🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]