Repository navigation
Description
Goal
Remove ephemeral-during-editing behavior. Only ONE placeholder exists: on initial viewer load when parent has no children.
Problem
Current system allows ephemeral (non-persisted) nodes during editing, causing:
- UNIQUE constraint violations
- Complex deferred update queue (~700 lines)
- Dependency tracking for ephemeral references
- Race conditions and timing bugs
Solution
Blank nodes created during editing persist immediately (with 500ms debounce).
Only exception: Initial placeholder when BaseNodeViewer loads with no children.
Implementation Steps
1. Update ReactiveNodeService.createNode()
File: packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts
Remove automatic placeholder detection. Add isInitialPlaceholder flag parameter:
createNode(
nodeData: Partial<Node>,
isInitialPlaceholder: boolean = false
): string {
// ...
// Only skip persistence for initial viewer placeholder
if (!isInitialPlaceholder) {
sharedNodeStore.setNode(newNode, viewerSource);
}
// ...
}2. Update BaseNodeViewer
File: packages/desktop-app/src/lib/design/components/base-node-viewer.svelte
Lines ~773-786: Pass true for initial placeholder only:
if (allNodes.length === 0) {
const placeholderId = globalThis.crypto.randomUUID();
viewerPlaceholder = nodeManager.createNode(
{
id: placeholderId,
nodeType: 'text',
content: '',
parentId: null, // viewer-local
// ...
},
true // isInitialPlaceholder = true
);
}All other node creation (Enter key, etc.): Pass false or omit (defaults to false).
3. Update Placeholder Detection Utility
File: packages/desktop-app/src/lib/utils/placeholder-detection.ts
Semantic change only - function stays the same, but now used for:
- UI styling (gray text, etc.)
- NOT for persistence decisions
Add comment clarifying new usage.
4. Update Tests
- Remove tests expecting ephemeral during editing
- Add tests for immediate persistence of blank nodes
- Verify initial placeholder still works
Acceptance Criteria
- Create blank node → persists after 500ms
- Indent blank node → no UNIQUE/FOREIGN KEY errors
- Initial viewer load (no children) → shows ONE placeholder
- Reload viewer (with children) → NO placeholder
- All existing tests pass
- No regressions in user experience
Duration
4-6 hours
Risk
Medium - Changes fundamental behavior
Dependencies
None
Next Phase
Phase 2: Remove Deferred Update Queue
Activity
Archive old refactoring plan documentation
malibio commentedon Nov 12, 2025
Test Baseline (before implementation)
Date: 2025-11-12 15:31:32
Branch: feature/issue-479-eliminate-ephemeral-nodes
Test Results Summary:
Detailed Status:
Test Command:
bun run test:allThis baseline will be used to verify that the ephemeral node elimination does not introduce regressions.
Phase 1: Eliminate ephemeral nodes during editing (#479)
Fix orphaned node creation and backend validation (#479)
malibio commentedon Nov 13, 2025
Phase 1 Progress Update - Orphaned Node Bug Fixed
Issue Discovered
During testing, we found that blank text nodes with
parentId: nullwere being created on page initialization, causing orphaned nodes in the database.Root Cause
BaseNodeViewerhas a reactive$effect()(line 1491-1522) that creates a placeholder when children drop to zero. This effect was:parentId: nullinstead ofparentId: nodeIdisInitialPlaceholder: trueflag, causing immediate persistenceFix Applied (Commit 2e5624b)
Frontend Changes:
parentId: null→parentId: nodeIdin reactive placeholder creationisInitialPlaceholder: trueto mark placeholder as ephemeralpackages/desktop-app/src/lib/design/components/base-node-viewer.svelte:1491-1518Backend Changes:
packages/core/src/behaviors/mod.rs:299-319Testing Results
✅ No more orphaned nodes created - verified with database queries
⚠️ UNIQUE constraint errors persist - expected, will be addressed in Phase 2
✅ Correct parentId on new nodes - network inspection shows
parentId: "2025-11-10"✅ Backend accepts blank nodes - no more 500 errors for empty content
Next Steps
The UNIQUE constraint violations are the core issue Phase 1 is meant to solve. The orphaned node bug was a separate issue we discovered and fixed along the way.
Fix: Keep initial placeholder completely viewer-local (#479)
Fix Issue #479 Phase 1: Remove all isPlaceholder checks from persiste…
Address code review feedback from PR #483
Phase 1: Eliminate ephemeral nodes during editing (#479) (#483)
malibio commentedon Nov 13, 2025
✅ Phase 1 Complete - Merged via PR #483
All acceptance criteria met:
Implementation Summary:
isPlaceholderchecks from persistence logicMerge Commit:
0cdb9e5Ready for Phase 2: Remove Deferred Update Queue
docs: Update persistence documentation to reflect Issue #479 completion
5 remaining items
Fix: Allow blank content for quote-block, header, and code-block nodes
Fix: Allow blank content for all content node types (#508)
Archive old refactoring plan documentation
Phase 1: Eliminate ephemeral nodes during editing (#479) (#483)
docs: Update persistence documentation to reflect Issue #479 completion
Backend: Allow blank text nodes in validation (#502)
Fix: Allow blank content for all content node types (#508)
Archive old refactoring plan documentation
Phase 1: Eliminate ephemeral nodes during editing (#479) (#483)
docs: Update persistence documentation to reflect Issue #479 completion
Backend: Allow blank text nodes in validation (#502)
Fix: Allow blank content for all content node types (#508)
Phase 1: Eliminate ephemeral nodes during editing (#479) (#483)
Backend: Allow blank text nodes in validation (#502)
Fix: Allow blank content for all content node types (#508)