Repository navigation
Description
Overview
Delete the manual cache management from SharedNodeStore and ReactiveNodeService that has been replaced by ReactiveStructureTree (Issue #553, PR #566). Additionally, complete the removal of beforeSiblingId from the Node type and all usage in the codebase.
Background
- ReactiveStructureTree now handles hierarchy queries via LIVE SELECT events with fractional ordering
- SharedNodeStore's
childrenCacheandparentsCacheare redundant - These caches cause synchronization issues and add unnecessary complexity
- Per architecture review (docs/architecture/development/hierarchy-reactivity-architecture-review.md), cache management and
beforeSiblingIdshould be completely removed - Issue Complete removal of beforeSiblingId - clean up fractional ordering migration #575 was merged but
beforeSiblingIdstill exists on Node type and is actively used
Tasks
Phase 1: Remove beforeSiblingId from Node Type
CRITICAL: Zero beforeSiblingId references should remain in Node data model
- Remove
beforeSiblingIdfield fromNodeinterface (packages/desktop-app/src/lib/types/node.ts:35) - Remove
beforeSiblingIdfromNodeUpdateinterface (packages/desktop-app/src/lib/types/node.ts:200) - Remove
beforeSiblingIdvalidation inisValidNode()(node.ts:258) - Remove all documentation comments referencing
beforeSiblingIdinnode.ts
Phase 2: Update Services to Use Structure Store Instead
Replace all node.beforeSiblingId reads with structure store queries
Files to update:
-
reactive-node-service.svelte.ts(lines 154, 444, 836, 931, 1028, 1125, 1358)- Replace
siblings.find(n => n.beforeSiblingId === targetId)with structure-based queries - Use
structureTree.getChildren()to get ordered siblings - Calculate next sibling from ordered array instead of linked-list traversal
- Replace
-
backend-adapter.ts(line 1072)- Remove
beforeSiblingIdfrom Node serialization
- Remove
-
shared-node-store.ts(lines 725, 780)- Remove
beforeSiblingIdcomparison in change detection - Remove
beforeSiblingIddependency validation
- Remove
Phase 3: SharedNodeStore Cache Cleanup
-
Delete cache Maps:
private childrenCache: Map<string | null, string[]>private parentsCache: Map<string, string[]>
-
Delete cache methods:
updateChildrenCache()addChildToCache()removeChildFromCache()clearChildrenCache()
-
Update
getNodesForParent()to delegate to ReactiveStructureTree:
import { structureTree } from '$lib/stores/reactive-structure-tree.svelte';
getNodesForParent(parentId: string | null): Node[] {
const childIds = structureTree.getChildren(parentId ?? '__root__');
return childIds.map(id => this.nodes.get(id)).filter((n): n is Node => n !== undefined);
}- Update
getParentsForNode()to delegate to ReactiveStructureTree:
getParentsForNode(nodeId: string): Node[] {
const parentIds = structureTree.getParentsForNode(nodeId);
return parentIds.map(id => this.nodes.get(id)).filter((n): n is Node => n !== undefined);
}Phase 4: ReactiveNodeService Cleanup
- Delete
_sortedChildrenCache - Delete
invalidateSortedChildrenCache() - Remove all calls to cache invalidation methods
- Update
sortChildrenByBeforeSiblingId()to use structure store ordering instead
Phase 5: Test Updates
- Update tests that read
node.beforeSiblingId - Update tests that call removed cache methods
- Verify all hierarchy queries work via ReactiveStructureTree
- Update test utilities that create nodes with
beforeSiblingId
Key Implementation Pattern
Finding next sibling (OLD - using beforeSiblingId):
const nextSibling = siblings.find(n => n.beforeSiblingId === currentNodeId);Finding next sibling (NEW - using structure store):
const orderedSiblings = structureTree.getChildren(parentId ?? '__root__');
const currentIndex = orderedSiblings.indexOf(currentNodeId);
const nextSibling = currentIndex >= 0 && currentIndex < orderedSiblings.length - 1
? this.findNode(orderedSiblings[currentIndex + 1])
: null;Acceptance Criteria
- ZERO references to
node.beforeSiblingIdremain in source code -
beforeSiblingIdfield removed fromNodeandNodeUpdateinterfaces - All cache-related code removed from SharedNodeStore
-
getNodesForParent()andgetParentsForNode()delegate to ReactiveStructureTree - All sibling queries use structure store instead of linked-list traversal
- No calls to cache methods remain in codebase
- All tests pass
- No compilation errors
Dependencies
- Builds on Create ReactiveStructureTree store with LIVE SELECT integration #553 (ReactiveStructureTree), Create ReactiveNodeData store with debounced content updates #554 (ReactiveNodeData), Complete removal of beforeSiblingId - clean up fractional ordering migration #575 (initial beforeSiblingId cleanup)
Related Issues
- Part of Workstream E (Operations Refactor) from architecture doc
- Enables Delete 15 obsolete services replaced by LIVE SELECT #558 (Delete obsolete services)
Activity
Implement HierarchyStore with Svelte 5 runes for cleaner separation o…
WIP: Enhance ReactiveStructureTree with bulk initialization (Issue #557)
[-]Delete obsolete manual cache management code[/-][+]Delete obsolete cache management code from SharedNodeStore[/+]Remove cache management from SharedNodeStore (Issue #557)
Completely remove beforeSiblingId from codebase (Issue #557)
Delete obsolete cache management code from SharedNodeStore (#588)
Delete obsolete cache management code from SharedNodeStore (#588)
Delete obsolete cache management code from SharedNodeStore (#588)
Delete obsolete cache management code from SharedNodeStore (#588)
Delete frontend migration residue: tombstone comments + FocusManager …
Delete frontend migration residue: tombstone comments + FocusManager …