You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nodes created via Enter key display in correct order during the session, but after page refresh they appear in a different order. This indicates the sibling ordering information is not being persisted to the database during node creation.
Problem Statement
User Experience:
User creates nodes A, B, C, D via Enter key (as children of node A)
During session: Nodes display as A > B, C, D (correct order)
After refresh: Nodes display as A > C, D, B (B moved to end)
Database State:
Nodes are created with parentId but missing insertAfterNodeId
Backend doesn't know where to insert new nodes in sibling order
Database stores incorrect order values
Root Cause
Location: packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts (createNode function, line 242-267)
The createNode function creates a Node object with parentId but does NOT include insertAfterNodeId. When the node is persisted via sharedNodeStore.setNode() (line 267), the backend receives only the parent but no sibling positioning information.
Why it happens:
Frontend calculates correct order for ReactiveStructureTree (lines 274-301) for immediate UI display
But this order is NOT sent to backend during persistence
Backend has no insertAfterNodeId to determine where to insert the node among siblings
Result: Backend appends to end or uses default ordering
Evidence
Commit 3241e710 on old fix/multiple-bugs branch had the fix:
Added insertAfterNodeId field to CreateNodeInput interface
ReactiveNodeService.createNode() calculated and passed insertAfterNodeId
Backend received correct positioning information
This fix was NOT included in PR #655 merge (commit dbe232ef), causing a regression.
Proposed Solution
Add insertAfterNodeId to the Node object created in ReactiveNodeService.createNode() and ensure it's passed to the backend during persistence.
Hypothesis:
PR #655 was based on commit 3eda1bf2 from main branch, which had the Enter key UI fix but not the backend ordering fix. Commit 3241e710 was on the old experimental branch and didn't make it into the final PR.
Overview
Nodes created via Enter key display in correct order during the session, but after page refresh they appear in a different order. This indicates the sibling ordering information is not being persisted to the database during node creation.
Problem Statement
User Experience:
Database State:
Root Cause
Location:
packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts(createNode function, line 242-267)The createNode function creates a Node object with
parentIdbut does NOT includeinsertAfterNodeId. When the node is persisted viasharedNodeStore.setNode()(line 267), the backend receives only the parent but no sibling positioning information.Why it happens:
insertAfterNodeIdto determine where to insert the node among siblingsEvidence
Commit
3241e710on oldfix/multiple-bugsbranch had the fix:insertAfterNodeIdfield to CreateNodeInput interfaceThis fix was NOT included in PR #655 merge (commit
dbe232ef), causing a regression.Proposed Solution
Add
insertAfterNodeIdto the Node object created in ReactiveNodeService.createNode() and ensure it's passed to the backend during persistence.Changes Required
1. Modify ReactiveNodeService.createNode() (
reactive-node-service.svelte.ts):2. Update backend adapter (
backend-adapter.ts):insertAfterNodeIdfield3. Verify backend handling (
dev-proxy.rs,commands/nodes.rs):Acceptance Criteria
Technical Specifications
Reference Files
ReactiveNodeService:
packages/desktop-app/src/lib/services/reactive-node-service.svelte.tsBackendAdapter:
packages/desktop-app/src/lib/services/backend-adapter.tsReference Commit
3241e710onfix/multiple-bugsbranch: "Fix: Node ordering after refresh (remove before_sibling_id legacy code)"Testing Requirements
Related Issues
Investigation Notes
Troubleshooting performed:
Hypothesis:
PR #655 was based on commit
3eda1bf2from main branch, which had the Enter key UI fix but not the backend ordering fix. Commit3241e710was on the old experimental branch and didn't make it into the final PR.