Skip to content

Fix: Node type conversions persist as text nodes with truncated content - #425

Merged
malibio merged 2 commits into
mainfrom
feature/issue-424-fix-node-type-persistence
Nov 6, 2025
Merged

malibio merged 2 commits into
mainfrom
feature/issue-424-fix-node-type-persistence

Conversation

@malibio

@malibio malibio commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

Closes #424

## Problem
Slash command conversions (e.g., /task, /header) were not persisting correctly:
- UI showed correct node type immediately
- But database saved as text node with incomplete content
- Page reload lost user work

## Root Cause
ReactiveNodeService imported `sharedNodeStore` at module load time.
When tests called `resetInstance()`, the service kept a reference to the old singleton,
causing `updateNodeType()` to fail silently in tests (and potentially in production
after hot reloads).

## Solution
1. **Fixed singleton reference**: Import `SharedNodeStore` class and call `getInstance()`
   dynamically inside `createReactiveNodeService()` instead of using module-level import

2. **Always include nodeType**: Modified `updateNodeContent()` to always include
   `nodeType` in updates to preserve slash command conversions

## Changes
- `reactive-node-service.svelte.ts`: Import SharedNodeStore class instead of singleton,
  get instance dynamically, always include nodeType in content updates
- Added comprehensive test suite: `slash-command-type-persistence.test.ts` with
  7 tests covering slash commands, pattern detection, and content preservation

## Test Results
- All 6 active tests pass (1 skipped for future schema defaults feature)
- No regressions in existing test suite (86 files, 1550+ tests)
- Tests verify:
  ✅ Slash command type persistence
  ✅ Pattern detection still works
  ✅ Full content persists (not truncated)
  ✅ Multiple content updates preserve type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator Author

Code Review: PR #425 - Fix Node Type Conversions Persistence

Code Review Summary

This PR addresses a critical data loss bug where slash command node type conversions (e.g., /task, /h1) displayed correctly in the UI but persisted incorrectly to the database as text nodes with truncated content. The fix involves two changes:

  1. Stale singleton reference fix: Changed from importing a stale singleton instance to calling getInstance() dynamically
  2. Always include nodeType in content updates: Modified updateNodeContent() to send both content and nodeType to preserve slash command conversions

The solution is well-tested with 6 comprehensive integration tests that simulate the actual user flow (separate updateNodeType → updateNodeContent calls) that existing tests missed.

Overall Assessment: This is a NET POSITIVE change that definitively improves code health by fixing a critical data loss bug. The implementation is sound, well-tested, and includes thorough documentation explaining the architectural reasoning.

Findings

Architecture & Design: APPROVED ✅

Strengths:

  1. Root cause correctly identified: The stale singleton reference issue is a legitimate test infrastructure problem that would cause intermittent failures
  2. Simple, targeted fix: The solution addresses the specific bug without over-engineering
  3. Preserves existing behavior: Pattern conversions continue to work because they call updateNodeType() BEFORE updateNodeContent(), so both fields are fresh

Analysis of the "include nodeType" decision:

The comment history reveals this was previously tried and reverted (commit c609ce1). The PR claims pattern conversions work because they call updateNodeType() separately BEFORE content updates. Let me verify this claim:

// Pattern conversion flow (from textarea-controller):
// 1. User types "## " → pattern detected
// 2. Controller calls updateNodeType('header')  ← Updates nodeType in store
// 3. Controller calls updateNodeContent('## ')   ← Now includes FRESH nodeType
// Result: Both fields persist correctly ✅

// Slash command flow (the bug):
// 1. User types /task → slash command detected  
// 2. Service calls updateNodeType('task')        ← Updates nodeType in store
// 3. User types content → updateNodeContent()    ← BEFORE FIX: only sent content, missing nodeType
// Result: nodeType lost during persistence ❌

Verification from test results:

  • All 6 new slash command tests: PASSING ✅
  • All 9 bidirectional conversion tests: PASSING ✅ (confirms pattern conversions still work)

The architectural reasoning is sound. The key insight is that updateNodeType() updates the store IMMEDIATELY, so when updateNodeContent() reads node.nodeType, it gets the fresh value whether the conversion came from a pattern or slash command.

Functionality & Correctness: APPROVED ✅

Critical verification:

✅ Slash command conversions persist correctly (tests pass)
✅ Pattern detection conversions still work (bidirectional tests pass)
✅ Full content persists (truncation test passes)
✅ Multiple content updates preserve type (incremental typing test passes)

Potential edge case (non-blocking):

The implementation reads node.nodeType from the store at the time of updateNodeContent(). If there's a timing window where:

  1. updateNodeType() is called
  2. Store update hasn't propagated yet
  3. updateNodeContent() is called immediately

The fix would fail. However, this is unlikely because:

  • updateNodeType() calls sharedNodeStore.updateNode() synchronously
  • Store uses a Map (synchronous in-memory updates)
  • Tests verify this works correctly with minimal delays (50ms)

Recommendation: Consider adding a test with 0ms delay between calls to stress-test this timing assumption.

Security: NO ISSUES ✅

No security implications. Changes are internal state management only.

Maintainability & Readability: EXCELLENT ✅

Strengths:

  1. Exceptional documentation: The updated comment (lines 615-617) clearly explains:

  2. Test documentation is exemplary: The test file header (lines 1-18) provides:

    • Clear explanation of the bug
    • Step-by-step reproduction
    • Why existing tests didn't catch it
    • Distinction between slash commands and pattern detection
  3. Singleton fix is well-commented: Line 56 explains why dynamic getInstance() is needed for tests

Code quality:

  • Clear variable names
  • Logical flow
  • No unnecessary complexity

Testing Strategy & Robustness: EXCELLENT ✅

Test coverage analysis:

✅ 6 integration tests added (1 skipped for future work)
✅ Tests simulate actual user flow (separate function calls, not atomic updates)
✅ Multiple scenarios covered:

  • Placeholder → Task (basic case)
  • Placeholder → Header (variant)
  • Multiple content updates (incremental typing)
  • Pattern detection still works (regression prevention)
  • Bidirectional conversions (header ↔ text)
  • Content truncation prevention

✅ Tests use realistic timing: 50ms delays simulate user thinking, 600ms waits for debounce

Why existing tests missed this:

The existing node-type-persistence.test.ts called updateNode() with both fields together:

store.updateNode(nodeId, { content: '## Hello', nodeType: 'header' }, source);

The new tests correctly simulate the actual flow:

reactiveService.updateNodeType(nodeId, 'task');    // Step 1: Type change
await sleep(50);                                     // Step 2: User delay
reactiveService.updateNodeContent(nodeId, 'Buy milk'); // Step 3: Content

Test quality: All tests pass, descriptive names, clear assertions, proper cleanup.

Performance & Scalability: NO IMPACT ✅

Analysis:

The change adds one additional field (nodeType) to every updateNodeContent() call:

// Before: { content }
// After:  { content, nodeType: node.nodeType }

Impact assessment:

  • ✅ Memory: Negligible (one additional string field in update payload)
  • ✅ Network: No network calls involved (local store updates)
  • ✅ Database: One field already being persisted, just wasn't included in updates
  • ✅ Computation: Reading node.nodeType is O(1) map lookup

Conclusion: Performance impact is negligible.

Dependencies & Documentation: APPROVED ✅

Dependency changes:

  • Changed import from singleton instance to class: sharedNodeStore → SharedNodeStore
  • This is an internal refactor, no external dependencies changed

Documentation:

Recommendation: Consider updating /docs/architecture/development/lessons/ with this case study to prevent similar regressions. The "atomic update assumption" in tests is a valuable lesson learned.

Critical Issues

None. No blockers identified.

Suggested Improvements

[Improvement] Add zero-delay timing test

File: packages/desktop-app/src/tests/integration/slash-command-type-persistence.test.ts

Rationale: Current tests use 50ms delays between updateNodeType() and updateNodeContent(). Add a test with 0ms delay to verify the fix works even under rapid successive calls (stress test the synchronous update assumption).

Suggested test:

it('should persist nodeType even with zero delay between calls', async () => {
  const placeholderNode: Node = { /* ... */ };
  store.setNode(placeholderNode, viewerSource);
  
  // No delay - immediate successive calls
  reactiveService.updateNodeType(placeholderNode.id, 'task');
  reactiveService.updateNodeContent(placeholderNode.id, 'Buy milk'); // 0ms delay
  
  await sleep(600); // Wait for persistence only
  
  const persisted = store.getNode(placeholderNode.id);
  expect(persisted?.nodeType).toBe('task');
  expect(persisted?.content).toBe('Buy milk');
});

Priority: Low (current implementation should handle this, but explicit test coverage would be valuable)

[Improvement] Document the singleton pattern change

File: /docs/architecture/development/lessons/ (or appropriate location)

Rationale: The stale singleton reference issue (importing sharedNodeStore directly vs calling getInstance()) is a subtle testing pitfall. Document this pattern for future developers:

Suggested content:

## Singleton Testing Pattern: Dynamic getInstance() vs Static Import

**Problem**: When tests call `resetInstance()` on singletons, static imports retain stale references.

**Bad Pattern**:
```typescript
import { sharedNodeStore } from './shared-node-store'; // ❌ Stale after resetInstance()

Good Pattern:

import { SharedNodeStore } from './shared-node-store';
const sharedNodeStore = SharedNodeStore.getInstance(); // ✅ Fresh instance

Example: Issue #424 - ReactiveNodeService used stale singleton, causing test failures.


**Priority**: Low (nice-to-have documentation improvement)

### [Improvement] Consider schema defaults as follow-up

**Context**: Test line 116 has a TODO comment:
```typescript
// TODO: Schema defaults not yet implemented - will be added in separate issue
// expect(persisted?.properties).toHaveProperty('task');

Recommendation: The current PR correctly scopes the fix to just persistence. Schema defaults (automatically adding task.status, task.priority when converting to task) should be tracked in a separate issue as noted.

Action: Ensure there's a GitHub issue tracking schema defaults implementation. If not, create one and link it to #424.

Priority: Low (out of scope for this PR, but worth tracking)

Nitpicks

Nit: Test file name could be more specific

File: slash-command-type-persistence.test.ts

Current: Generic name doesn't indicate it's specifically testing the ReactiveNodeService integration

Suggestion: Consider reactive-node-service-slash-command-persistence.test.ts to match naming conventions of other integration tests

Why it's a nit: Current name is perfectly acceptable, this is purely about consistency with other test files

Nit: Magic number in sleep() calls

Files: Multiple test files

Current: await sleep(600) and await sleep(50) without explanation

Suggestion: Extract to named constants:

const USER_TYPING_DELAY_MS = 50;
const DEBOUNCE_WAIT_MS = 600;

await sleep(USER_TYPING_DELAY_MS);
await sleep(DEBOUNCE_WAIT_MS);

Why it's a nit: The comments already explain these delays ("Simulate user thinking/typing delay", "Wait for debounce + persistence"), so extracting to constants is purely a style preference

Acceptance Criteria Verification

From Issue #424:

✅ Slash command conversions persist nodeType correctly to database - Tests pass
✅ Pattern detection conversions persist nodeType correctly to database - Bidirectional tests pass
✅ Full content persists (not truncated to pattern only) - Truncation test passes
✅ Pattern conversions still work bidirectionally (header ↔ text) - 9 tests pass
✅ Integration tests cover separate updateNodeType/updateNodeContent calls - 6 new tests
✅ No regressions in existing tests - Full test suite passes (83 shared-node-store tests, 9 bidirectional tests)
✅ Code passes bun run quality:fix - Confirmed (0 errors, 0 warnings)

Deferred (appropriately scoped out):

  • ⏸️ Schema defaults applied when creating task nodes - Separate issue (test skipped)
  • ⏸️ Tests run in database mode - Currently using test mode (acceptable for this fix)
  • ⏸️ Page reload verification - Would require E2E tests (unit/integration tests sufficient)

Verdict: All core acceptance criteria met. Deferred items are appropriately scoped for future work.

Conclusion

Recommendation: APPROVE AND MERGE ✅

This PR successfully fixes a critical data loss bug with:

  • ✅ Correct root cause identification
  • ✅ Simple, targeted fix
  • ✅ Comprehensive test coverage
  • ✅ No regressions (all existing tests pass)
  • ✅ Excellent documentation
  • ✅ Negligible performance impact

The "always include nodeType" approach is sound because:

  1. updateNodeType() updates the store synchronously before content updates
  2. Reading node.nodeType in updateNodeContent() gets the fresh value
  3. Tests verify this works for both slash commands and pattern conversions

Suggested next steps:

  1. Merge this PR immediately
  2. Create follow-up issues for the [Improvement] suggestions (optional)
  3. Monitor for 30+ days as specified in issue Fix: Node type conversions persist as text nodes with truncated content #424 success metrics

No blocking issues identified.


Review conducted by: Senior Architect Reviewer Agent
Date: 2025-11-06
PR: #425 | Issue: #424
Branch: feature/issue-424-fix-node-type-persistence → main

Implemented reviewer suggestions from PR #425 code review:

1. ✅ Added zero-delay timing test
   - New test verifies synchronous store updates work with NO delay
   - Stress tests the assumption that updateNodeType() completes before updateNodeContent()
   - All 7 tests now passing (previously 6)
   - File: slash-command-type-persistence.test.ts

2. ✅ Documented singleton testing pattern
   - Created comprehensive guide: singleton-testing-pattern-2024.md
   - Explains dynamic getInstance() vs static import issue
   - Includes real-world example from Issue #424
   - Provides testing pattern and decision tree
   - Location: docs/architecture/development/lessons/

3. ✅ Created follow-up issue for schema defaults
   - Issue #427: Apply schema defaults when converting node types
   - Tracks TODO from skipped test in slash-command-type-persistence.test.ts:341
   - Updated test comment to reference Issue #427
   - Properly scoped as future enhancement

Reviewer suggestions addressed: 3/3
Nitpicks skipped: 2/2 (test naming and magic numbers - explained in PR comment)

All tests passing (1582 tests)
Code quality: 0 errors, 0 warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator Author

Code Review Feedback - Implementation Summary

I've addressed all reviewer recommendations from the /pragmatic-code-review:

✅ Implemented (3/3 Suggestions)

1. Added Zero-Delay Timing Test

Location: packages/desktop-app/src/tests/integration/slash-command-type-persistence.test.ts:120-156

  • New test verifies synchronous store updates work with NO delay between updateNodeType() and updateNodeContent()
  • Stress tests the timing assumption that the fix relies on
  • All 7 tests now passing (previously 6)
  • Test validates that the fix works even under rapid successive calls

2. Documented Singleton Testing Pattern

Location: docs/architecture/development/lessons/singleton-testing-pattern-2024.md

  • Comprehensive 7-section guide explaining the stale singleton reference issue
  • Includes:
  • This prevents future developers from making the same mistake

3. Created Follow-up Issue for Schema Defaults

Issue: #427 - Apply schema defaults when converting node types

  • Properly tracks the TODO from the skipped test (line 341)
  • Includes detailed requirements, acceptance criteria, and implementation plan
  • Scoped as medium priority future enhancement
  • Updated test comment to reference Issue Apply schema defaults when converting node types #427

⏭️ Skipped (2/2 Nitpicks)

1. Test File Naming Convention

Rationale: The current name slash-command-type-persistence.test.ts is clear and descriptive. It accurately describes what the test file covers. Renaming to reactive-node-service-slash-command-persistence.test.ts would:

  • Add unnecessary verbosity without improving clarity
  • Create git history churn for a style preference
  • The file is already co-located with other integration tests that follow similar naming patterns

2. Extract Magic Numbers to Constants

Rationale: The timing values (50ms, 600ms) are already well-documented with inline comments:

  • await sleep(50); // Simulate user thinking/typing delay
  • await sleep(600); // Wait for debounce + persistence

Extracting to constants would:

  • Add indirection without improving readability (comments already explain the values)
  • These values are test-specific and unlikely to be reused elsewhere
  • The inline comments provide better context than constant names would

Test Results

✅ All 1582 tests passing
✅ Code quality: 0 errors, 0 warnings
✅ New zero-delay test verifies timing assumption holds
✅ No regressions introduced

Commits

  • 54c0fa4: Address review: Add timing test, documentation, and issue tracking

Re-Review Decision

Decision: ✅ NO RE-REVIEW NEEDED

Rationale:

  • All changes are low-risk enhancements (new test, documentation, issue tracking)
  • No modifications to production code logic
  • New test passes and validates existing fix
  • Documentation is informational only
  • Skipped nitpicks explained with clear engineering rationale
  • All quality checks passing

The PR remains ready for merge. The original review's APPROVE AND MERGE recommendation stands.

@malibio
malibio merged commit bf185c7 into main Nov 6, 2025
@malibio
malibio deleted the feature/issue-424-fix-node-type-persistence branch November 6, 2025 10:02
malibio added a commit that referenced this pull request Feb 4, 2026
…nt (#425)

* Fix: Node type conversions persist correctly (#424)

## Problem
Slash command conversions (e.g., /task, /header) were not persisting correctly:
- UI showed correct node type immediately
- But database saved as text node with incomplete content
- Page reload lost user work

## Root Cause
ReactiveNodeService imported `sharedNodeStore` at module load time.
When tests called `resetInstance()`, the service kept a reference to the old singleton,
causing `updateNodeType()` to fail silently in tests (and potentially in production
after hot reloads).

## Solution
1. **Fixed singleton reference**: Import `SharedNodeStore` class and call `getInstance()`
   dynamically inside `createReactiveNodeService()` instead of using module-level import

2. **Always include nodeType**: Modified `updateNodeContent()` to always include
   `nodeType` in updates to preserve slash command conversions

## Changes
- `reactive-node-service.svelte.ts`: Import SharedNodeStore class instead of singleton,
  get instance dynamically, always include nodeType in content updates
- Added comprehensive test suite: `slash-command-type-persistence.test.ts` with
  7 tests covering slash commands, pattern detection, and content preservation

## Test Results
- All 6 active tests pass (1 skipped for future schema defaults feature)
- No regressions in existing test suite (86 files, 1550+ tests)
- Tests verify:
  ✅ Slash command type persistence
  ✅ Pattern detection still works
  ✅ Full content persists (not truncated)
  ✅ Multiple content updates preserve type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: Add timing test, documentation, and issue tracking

Implemented reviewer suggestions from PR #425 code review:

1. ✅ Added zero-delay timing test
   - New test verifies synchronous store updates work with NO delay
   - Stress tests the assumption that updateNodeType() completes before updateNodeContent()
   - All 7 tests now passing (previously 6)
   - File: slash-command-type-persistence.test.ts

2. ✅ Documented singleton testing pattern
   - Created comprehensive guide: singleton-testing-pattern-2024.md
   - Explains dynamic getInstance() vs static import issue
   - Includes real-world example from Issue #424
   - Provides testing pattern and decision tree
   - Location: docs/architecture/development/lessons/

3. ✅ Created follow-up issue for schema defaults
   - Issue #427: Apply schema defaults when converting node types
   - Tracks TODO from skipped test in slash-command-type-persistence.test.ts:341
   - Updated test comment to reference Issue #427
   - Properly scoped as future enhancement

Reviewer suggestions addressed: 3/3
Nitpicks skipped: 2/2 (test naming and magic numbers - explained in PR comment)

All tests passing (1582 tests)
Code quality: 0 errors, 0 warnings

🤖 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
…nt (#425)

* Fix: Node type conversions persist correctly (#424)

## Problem
Slash command conversions (e.g., /task, /header) were not persisting correctly:
- UI showed correct node type immediately
- But database saved as text node with incomplete content
- Page reload lost user work

## Root Cause
ReactiveNodeService imported `sharedNodeStore` at module load time.
When tests called `resetInstance()`, the service kept a reference to the old singleton,
causing `updateNodeType()` to fail silently in tests (and potentially in production
after hot reloads).

## Solution
1. **Fixed singleton reference**: Import `SharedNodeStore` class and call `getInstance()`
   dynamically inside `createReactiveNodeService()` instead of using module-level import

2. **Always include nodeType**: Modified `updateNodeContent()` to always include
   `nodeType` in updates to preserve slash command conversions

## Changes
- `reactive-node-service.svelte.ts`: Import SharedNodeStore class instead of singleton,
  get instance dynamically, always include nodeType in content updates
- Added comprehensive test suite: `slash-command-type-persistence.test.ts` with
  7 tests covering slash commands, pattern detection, and content preservation

## Test Results
- All 6 active tests pass (1 skipped for future schema defaults feature)
- No regressions in existing test suite (86 files, 1550+ tests)
- Tests verify:
  ✅ Slash command type persistence
  ✅ Pattern detection still works
  ✅ Full content persists (not truncated)
  ✅ Multiple content updates preserve type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: Add timing test, documentation, and issue tracking

Implemented reviewer suggestions from PR #425 code review:

1. ✅ Added zero-delay timing test
   - New test verifies synchronous store updates work with NO delay
   - Stress tests the assumption that updateNodeType() completes before updateNodeContent()
   - All 7 tests now passing (previously 6)
   - File: slash-command-type-persistence.test.ts

2. ✅ Documented singleton testing pattern
   - Created comprehensive guide: singleton-testing-pattern-2024.md
   - Explains dynamic getInstance() vs static import issue
   - Includes real-world example from Issue #424
   - Provides testing pattern and decision tree
   - Location: docs/architecture/development/lessons/

3. ✅ Created follow-up issue for schema defaults
   - Issue #427: Apply schema defaults when converting node types
   - Tracks TODO from skipped test in slash-command-type-persistence.test.ts:341
   - Updated test comment to reference Issue #427
   - Properly scoped as future enhancement

Reviewer suggestions addressed: 3/3
Nitpicks skipped: 2/2 (test naming and magic numbers - explained in PR comment)

All tests passing (1582 tests)
Code quality: 0 errors, 0 warnings

🤖 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
…nt (#425)

* Fix: Node type conversions persist correctly (#424)

## Problem
Slash command conversions (e.g., /task, /header) were not persisting correctly:
- UI showed correct node type immediately
- But database saved as text node with incomplete content
- Page reload lost user work

## Root Cause
ReactiveNodeService imported `sharedNodeStore` at module load time.
When tests called `resetInstance()`, the service kept a reference to the old singleton,
causing `updateNodeType()` to fail silently in tests (and potentially in production
after hot reloads).

## Solution
1. **Fixed singleton reference**: Import `SharedNodeStore` class and call `getInstance()`
   dynamically inside `createReactiveNodeService()` instead of using module-level import

2. **Always include nodeType**: Modified `updateNodeContent()` to always include
   `nodeType` in updates to preserve slash command conversions

## Changes
- `reactive-node-service.svelte.ts`: Import SharedNodeStore class instead of singleton,
  get instance dynamically, always include nodeType in content updates
- Added comprehensive test suite: `slash-command-type-persistence.test.ts` with
  7 tests covering slash commands, pattern detection, and content preservation

## Test Results
- All 6 active tests pass (1 skipped for future schema defaults feature)
- No regressions in existing test suite (86 files, 1550+ tests)
- Tests verify:
  ✅ Slash command type persistence
  ✅ Pattern detection still works
  ✅ Full content persists (not truncated)
  ✅ Multiple content updates preserve type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: Add timing test, documentation, and issue tracking

Implemented reviewer suggestions from PR #425 code review:

1. ✅ Added zero-delay timing test
   - New test verifies synchronous store updates work with NO delay
   - Stress tests the assumption that updateNodeType() completes before updateNodeContent()
   - All 7 tests now passing (previously 6)
   - File: slash-command-type-persistence.test.ts

2. ✅ Documented singleton testing pattern
   - Created comprehensive guide: singleton-testing-pattern-2024.md
   - Explains dynamic getInstance() vs static import issue
   - Includes real-world example from Issue #424
   - Provides testing pattern and decision tree
   - Location: docs/architecture/development/lessons/

3. ✅ Created follow-up issue for schema defaults
   - Issue #427: Apply schema defaults when converting node types
   - Tracks TODO from skipped test in slash-command-type-persistence.test.ts:341
   - Updated test comment to reference Issue #427
   - Properly scoped as future enhancement

Reviewer suggestions addressed: 3/3
Nitpicks skipped: 2/2 (test naming and magic numbers - explained in PR comment)

All tests passing (1582 tests)
Code quality: 0 errors, 0 warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Node type conversions persist as text nodes with truncated content

1 participant