Repository navigation
Fix Backspace/Delete Operations (Issue #229) - #254
Merged
Merged
Conversation
This fixes all 9 failing tests in backspace-operations.test.ts by ensuring proper persistence sequencing and dependency management through PersistenceCoordinator. ## Changes Made: ### 1. Content Update Persistence (reactive-node-service.svelte.ts:756-761) - Changed content update source from 'viewer' to 'external' to ensure persistence - Using 'viewer' source skipped content-only updates (shared-node-store.ts:254) - Now content merges persist to database before deletion ### 2. Fixed Child Promotion Logic (reactive-node-service.svelte.ts:1092-1115) - Root-level node deletions now promote children to root (parentId=null) - Previous logic incorrectly made children siblings of previous node - Fixes "should promote children" test failure ### 3. Added Root Node Tracking (reactive-node-service.svelte.ts:1155-1158) - Promoted children now added to _rootNodeIds array - Ensures promoted nodes appear in visibleNodes list - Fixes visual order test expectations ### 4. Fixed Container ID Updates (reactive-node-service.svelte.ts:1128-1136) - Update containerNodeId when promoting children to prevent FOREIGN KEY violations - Container inherits from new parent's container (or null for root-level) ### 5. Recursive Descendant Fix (reactive-node-service.svelte.ts:1167-1195) - Added fixDescendantContainerIds() to recursively update nested descendants - Grandchildren and deeper descendants now get updated containerNodeIds - Prevents FOREIGN KEY violations when deleting nodes with nested children - Fixes "should handle combining nodes with nested children" test ### 6. Proper Wait Dependencies (reactive-node-service.svelte.ts:765) - Added previousNodeId to nodesToWaitFor for content update - Ensures all structural changes complete before deletion - Prevents race conditions and 500 errors ## Test Results: - All 10 tests in backspace-operations.test.ts now pass - No database errors or FOREIGN KEY violations - Content properly persisted and merged - Children correctly promoted with proper hierarchy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…wait Replace manual `await waitForNodeSaves()` logic with declarative dependency mechanism in PersistenceCoordinator. This is the architecturally correct approach. ## Changes: ### 1. Enhanced SharedNodeStore.deleteNode() (shared-node-store.ts:469-522) - Added optional `dependencies` parameter - Pass dependencies to PersistenceCoordinator.persist() - Documents that dependencies prevent FOREIGN KEY violations ### 2. Simplified combineNodes() (reactive-node-service.svelte.ts:744-785) - Removed async/await and manual wait logic - Changed from `async function` to `function` (synchronous) - Collect dependencies and pass to deleteNode() directly - PersistenceCoordinator handles sequencing automatically ## Benefits: ✅ **More Declarative**: Dependencies are explicit, not implicit in wait logic ✅ **Better Encapsulation**: Coordination logic stays in PersistenceCoordinator ✅ **Simpler Code**: Removed 15 lines of manual wait/error handling ✅ **Architecturally Correct**: Uses the dependency system as designed ✅ **Same Behavior**: All 10 tests still pass ## Before (Manual Await): ```typescript const nodesToWaitFor = [node1, node2, node3]; await sharedNodeStore.waitForNodeSaves(nodesToWaitFor); // Check for failures, log errors... sharedNodeStore.deleteNode(nodeId, source); ``` ## After (Declarative Dependencies): ```typescript const dependencies = [node1, node2, node3]; sharedNodeStore.deleteNode(nodeId, source, false, dependencies); ``` PersistenceCoordinator ensures the dependencies complete before deletion executes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add comprehensive documentation for PersistenceCoordinator usage patterns, including the declarative dependency approach used in Issue #229. ## Contents: ### Core Patterns: 1. Simple Immediate Persistence - Single node operations 2. Deletion with Dependencies - Recommended pattern from #229 3. Ancestor Chain Dependencies - Automatic handling 4. Structural vs Content Updates - Different persistence modes ### Anti-Patterns: - Manual await logic (replaced in #229) - Direct database calls - Ignoring containerNodeId updates ### Testing: - Test pattern using waitForDatabaseWrites() - Database state verification ### Examples: - combineNodes() from #229 as canonical reference - Code snippets for each pattern - When to use each approach This documentation will help future developers implement similar operations correctly (move, bulk delete, etc.) using the dependency system as designed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
* Fix backspace/delete operations to use PersistenceCoordinator properly This fixes all 9 failing tests in backspace-operations.test.ts by ensuring proper persistence sequencing and dependency management through PersistenceCoordinator. ## Changes Made: ### 1. Content Update Persistence (reactive-node-service.svelte.ts:756-761) - Changed content update source from 'viewer' to 'external' to ensure persistence - Using 'viewer' source skipped content-only updates (shared-node-store.ts:254) - Now content merges persist to database before deletion ### 2. Fixed Child Promotion Logic (reactive-node-service.svelte.ts:1092-1115) - Root-level node deletions now promote children to root (parentId=null) - Previous logic incorrectly made children siblings of previous node - Fixes "should promote children" test failure ### 3. Added Root Node Tracking (reactive-node-service.svelte.ts:1155-1158) - Promoted children now added to _rootNodeIds array - Ensures promoted nodes appear in visibleNodes list - Fixes visual order test expectations ### 4. Fixed Container ID Updates (reactive-node-service.svelte.ts:1128-1136) - Update containerNodeId when promoting children to prevent FOREIGN KEY violations - Container inherits from new parent's container (or null for root-level) ### 5. Recursive Descendant Fix (reactive-node-service.svelte.ts:1167-1195) - Added fixDescendantContainerIds() to recursively update nested descendants - Grandchildren and deeper descendants now get updated containerNodeIds - Prevents FOREIGN KEY violations when deleting nodes with nested children - Fixes "should handle combining nodes with nested children" test ### 6. Proper Wait Dependencies (reactive-node-service.svelte.ts:765) - Added previousNodeId to nodesToWaitFor for content update - Ensures all structural changes complete before deletion - Prevents race conditions and 500 errors ## Test Results: - All 10 tests in backspace-operations.test.ts now pass - No database errors or FOREIGN KEY violations - Content properly persisted and merged - Children correctly promoted with proper hierarchy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Refactor: Use PersistenceCoordinator dependencies instead of manual await Replace manual `await waitForNodeSaves()` logic with declarative dependency mechanism in PersistenceCoordinator. This is the architecturally correct approach. ## Changes: ### 1. Enhanced SharedNodeStore.deleteNode() (shared-node-store.ts:469-522) - Added optional `dependencies` parameter - Pass dependencies to PersistenceCoordinator.persist() - Documents that dependencies prevent FOREIGN KEY violations ### 2. Simplified combineNodes() (reactive-node-service.svelte.ts:744-785) - Removed async/await and manual wait logic - Changed from `async function` to `function` (synchronous) - Collect dependencies and pass to deleteNode() directly - PersistenceCoordinator handles sequencing automatically ## Benefits: ✅ **More Declarative**: Dependencies are explicit, not implicit in wait logic ✅ **Better Encapsulation**: Coordination logic stays in PersistenceCoordinator ✅ **Simpler Code**: Removed 15 lines of manual wait/error handling ✅ **Architecturally Correct**: Uses the dependency system as designed ✅ **Same Behavior**: All 10 tests still pass ## Before (Manual Await): ```typescript const nodesToWaitFor = [node1, node2, node3]; await sharedNodeStore.waitForNodeSaves(nodesToWaitFor); // Check for failures, log errors... sharedNodeStore.deleteNode(nodeId, source); ``` ## After (Declarative Dependencies): ```typescript const dependencies = [node1, node2, node3]; sharedNodeStore.deleteNode(nodeId, source, false, dependencies); ``` PersistenceCoordinator ensures the dependencies complete before deletion executes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: Add PersistenceCoordinator patterns and best practices guide Add comprehensive documentation for PersistenceCoordinator usage patterns, including the declarative dependency approach used in Issue #229. ## Contents: ### Core Patterns: 1. Simple Immediate Persistence - Single node operations 2. Deletion with Dependencies - Recommended pattern from #229 3. Ancestor Chain Dependencies - Automatic handling 4. Structural vs Content Updates - Different persistence modes ### Anti-Patterns: - Manual await logic (replaced in #229) - Direct database calls - Ignoring containerNodeId updates ### Testing: - Test pattern using waitForDatabaseWrites() - Database state verification ### Examples: - combineNodes() from #229 as canonical reference - Code snippets for each pattern - When to use each approach This documentation will help future developers implement similar operations correctly (move, bulk delete, etc.) using the dependency system as designed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
* Fix backspace/delete operations to use PersistenceCoordinator properly This fixes all 9 failing tests in backspace-operations.test.ts by ensuring proper persistence sequencing and dependency management through PersistenceCoordinator. ## Changes Made: ### 1. Content Update Persistence (reactive-node-service.svelte.ts:756-761) - Changed content update source from 'viewer' to 'external' to ensure persistence - Using 'viewer' source skipped content-only updates (shared-node-store.ts:254) - Now content merges persist to database before deletion ### 2. Fixed Child Promotion Logic (reactive-node-service.svelte.ts:1092-1115) - Root-level node deletions now promote children to root (parentId=null) - Previous logic incorrectly made children siblings of previous node - Fixes "should promote children" test failure ### 3. Added Root Node Tracking (reactive-node-service.svelte.ts:1155-1158) - Promoted children now added to _rootNodeIds array - Ensures promoted nodes appear in visibleNodes list - Fixes visual order test expectations ### 4. Fixed Container ID Updates (reactive-node-service.svelte.ts:1128-1136) - Update containerNodeId when promoting children to prevent FOREIGN KEY violations - Container inherits from new parent's container (or null for root-level) ### 5. Recursive Descendant Fix (reactive-node-service.svelte.ts:1167-1195) - Added fixDescendantContainerIds() to recursively update nested descendants - Grandchildren and deeper descendants now get updated containerNodeIds - Prevents FOREIGN KEY violations when deleting nodes with nested children - Fixes "should handle combining nodes with nested children" test ### 6. Proper Wait Dependencies (reactive-node-service.svelte.ts:765) - Added previousNodeId to nodesToWaitFor for content update - Ensures all structural changes complete before deletion - Prevents race conditions and 500 errors ## Test Results: - All 10 tests in backspace-operations.test.ts now pass - No database errors or FOREIGN KEY violations - Content properly persisted and merged - Children correctly promoted with proper hierarchy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Refactor: Use PersistenceCoordinator dependencies instead of manual await Replace manual `await waitForNodeSaves()` logic with declarative dependency mechanism in PersistenceCoordinator. This is the architecturally correct approach. ## Changes: ### 1. Enhanced SharedNodeStore.deleteNode() (shared-node-store.ts:469-522) - Added optional `dependencies` parameter - Pass dependencies to PersistenceCoordinator.persist() - Documents that dependencies prevent FOREIGN KEY violations ### 2. Simplified combineNodes() (reactive-node-service.svelte.ts:744-785) - Removed async/await and manual wait logic - Changed from `async function` to `function` (synchronous) - Collect dependencies and pass to deleteNode() directly - PersistenceCoordinator handles sequencing automatically ## Benefits: ✅ **More Declarative**: Dependencies are explicit, not implicit in wait logic ✅ **Better Encapsulation**: Coordination logic stays in PersistenceCoordinator ✅ **Simpler Code**: Removed 15 lines of manual wait/error handling ✅ **Architecturally Correct**: Uses the dependency system as designed ✅ **Same Behavior**: All 10 tests still pass ## Before (Manual Await): ```typescript const nodesToWaitFor = [node1, node2, node3]; await sharedNodeStore.waitForNodeSaves(nodesToWaitFor); // Check for failures, log errors... sharedNodeStore.deleteNode(nodeId, source); ``` ## After (Declarative Dependencies): ```typescript const dependencies = [node1, node2, node3]; sharedNodeStore.deleteNode(nodeId, source, false, dependencies); ``` PersistenceCoordinator ensures the dependencies complete before deletion executes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: Add PersistenceCoordinator patterns and best practices guide Add comprehensive documentation for PersistenceCoordinator usage patterns, including the declarative dependency approach used in Issue #229. ## Contents: ### Core Patterns: 1. Simple Immediate Persistence - Single node operations 2. Deletion with Dependencies - Recommended pattern from #229 3. Ancestor Chain Dependencies - Automatic handling 4. Structural vs Content Updates - Different persistence modes ### Anti-Patterns: - Manual await logic (replaced in #229) - Direct database calls - Ignoring containerNodeId updates ### Testing: - Test pattern using waitForDatabaseWrites() - Database state verification ### Examples: - combineNodes() from #229 as canonical reference - Code snippets for each pattern - When to use each approach This documentation will help future developers implement similar operations correctly (move, bulk delete, etc.) using the dependency system as designed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
* Fix backspace/delete operations to use PersistenceCoordinator properly This fixes all 9 failing tests in backspace-operations.test.ts by ensuring proper persistence sequencing and dependency management through PersistenceCoordinator. ## Changes Made: ### 1. Content Update Persistence (reactive-node-service.svelte.ts:756-761) - Changed content update source from 'viewer' to 'external' to ensure persistence - Using 'viewer' source skipped content-only updates (shared-node-store.ts:254) - Now content merges persist to database before deletion ### 2. Fixed Child Promotion Logic (reactive-node-service.svelte.ts:1092-1115) - Root-level node deletions now promote children to root (parentId=null) - Previous logic incorrectly made children siblings of previous node - Fixes "should promote children" test failure ### 3. Added Root Node Tracking (reactive-node-service.svelte.ts:1155-1158) - Promoted children now added to _rootNodeIds array - Ensures promoted nodes appear in visibleNodes list - Fixes visual order test expectations ### 4. Fixed Container ID Updates (reactive-node-service.svelte.ts:1128-1136) - Update containerNodeId when promoting children to prevent FOREIGN KEY violations - Container inherits from new parent's container (or null for root-level) ### 5. Recursive Descendant Fix (reactive-node-service.svelte.ts:1167-1195) - Added fixDescendantContainerIds() to recursively update nested descendants - Grandchildren and deeper descendants now get updated containerNodeIds - Prevents FOREIGN KEY violations when deleting nodes with nested children - Fixes "should handle combining nodes with nested children" test ### 6. Proper Wait Dependencies (reactive-node-service.svelte.ts:765) - Added previousNodeId to nodesToWaitFor for content update - Ensures all structural changes complete before deletion - Prevents race conditions and 500 errors ## Test Results: - All 10 tests in backspace-operations.test.ts now pass - No database errors or FOREIGN KEY violations - Content properly persisted and merged - Children correctly promoted with proper hierarchy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Refactor: Use PersistenceCoordinator dependencies instead of manual await Replace manual `await waitForNodeSaves()` logic with declarative dependency mechanism in PersistenceCoordinator. This is the architecturally correct approach. ## Changes: ### 1. Enhanced SharedNodeStore.deleteNode() (shared-node-store.ts:469-522) - Added optional `dependencies` parameter - Pass dependencies to PersistenceCoordinator.persist() - Documents that dependencies prevent FOREIGN KEY violations ### 2. Simplified combineNodes() (reactive-node-service.svelte.ts:744-785) - Removed async/await and manual wait logic - Changed from `async function` to `function` (synchronous) - Collect dependencies and pass to deleteNode() directly - PersistenceCoordinator handles sequencing automatically ## Benefits: ✅ **More Declarative**: Dependencies are explicit, not implicit in wait logic ✅ **Better Encapsulation**: Coordination logic stays in PersistenceCoordinator ✅ **Simpler Code**: Removed 15 lines of manual wait/error handling ✅ **Architecturally Correct**: Uses the dependency system as designed ✅ **Same Behavior**: All 10 tests still pass ## Before (Manual Await): ```typescript const nodesToWaitFor = [node1, node2, node3]; await sharedNodeStore.waitForNodeSaves(nodesToWaitFor); // Check for failures, log errors... sharedNodeStore.deleteNode(nodeId, source); ``` ## After (Declarative Dependencies): ```typescript const dependencies = [node1, node2, node3]; sharedNodeStore.deleteNode(nodeId, source, false, dependencies); ``` PersistenceCoordinator ensures the dependencies complete before deletion executes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: Add PersistenceCoordinator patterns and best practices guide Add comprehensive documentation for PersistenceCoordinator usage patterns, including the declarative dependency approach used in Issue #229. ## Contents: ### Core Patterns: 1. Simple Immediate Persistence - Single node operations 2. Deletion with Dependencies - Recommended pattern from #229 3. Ancestor Chain Dependencies - Automatic handling 4. Structural vs Content Updates - Different persistence modes ### Anti-Patterns: - Manual await logic (replaced in #229) - Direct database calls - Ignoring containerNodeId updates ### Testing: - Test pattern using waitForDatabaseWrites() - Database state verification ### Examples: - combineNodes() from #229 as canonical reference - Code snippets for each pattern - When to use each approach This documentation will help future developers implement similar operations correctly (move, bulk delete, etc.) using the dependency system as designed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Backspace/Delete Operations (9 test failures)
Fixes #229
Summary
This PR fixes all 9 failing tests in
backspace-operations.test.tsby ensuring proper persistence sequencing and dependency management through PersistenceCoordinator.Root Causes Identified
viewerSourcefor content-only updates caused persistence to be skippedChanges Made
1. Content Update Persistence (
reactive-node-service.svelte.ts:756-761)shared-node-store.ts:2542. Fixed Child Promotion Logic (
reactive-node-service.svelte.ts:1092-1115)parentId=null)3. Added Root Node Tracking (
reactive-node-service.svelte.ts:1155-1158)_rootNodeIdsarrayvisibleNodeslist4. Fixed Container ID Updates (
reactive-node-service.svelte.ts:1128-1136)containerNodeIdwhen promoting children to prevent FOREIGN KEY violations5. Recursive Descendant Fix (
reactive-node-service.svelte.ts:1167-1195)fixDescendantContainerIds()to recursively update nested descendantscontainerNodeIds6. Proper Wait Dependencies (
reactive-node-service.svelte.ts:765)previousNodeIdtonodesToWaitForfor content updateTest Results
✅ All 10 tests in
backspace-operations.test.tsnow pass:Testing
All tests pass with no database errors or FOREIGN KEY violations.
🤖 Generated with Claude Code