Skip to content

Simplify indent/outdent operations with atomic moveNode #556

Closed

Description

@malibio

Overview

Refactor indent/outdent operations to use the new atomic moveNode backend API, reducing complexity from 200+ lines to ~50 lines per operation.

Self-Contained Scope

  • Refactor indentNode to use atomic backend.moveNode
  • Refactor outdentNode with sibling transfer
  • Implement optimistic UI updates with rollback
  • Remove all manual cache synchronization
  • Remove sibling chain repair logic

Implementation Approach

  1. Use backend.moveNode for atomic operations
  2. Optimistic UI update with structureTree.moveNode
  3. Rollback on failure using snapshot/restore
  4. Remove manual cache updates
  5. Test with rapid operations

Acceptance Criteria

  • Refactor indentNode() to use backend.moveNode(nodeId, prevSiblingId, null)
  • Refactor outdentNode() to use backend.moveNode(nodeId, grandparentId, parentId)
  • Implement optimistic UI update using structureTree.moveNode()
  • Implement rollback using structureTree.restore(snapshot)
  • Remove manual removeFromSiblingChain() calls
  • Remove manual cache updates (addChildToCache, removeChildFromCache)
  • Remove manual invalidateSortedChildrenCache() calls
  • All indent/outdent tests pass
  • Performance: 5x faster operations (<10ms vs 50ms)

Dependencies

Related Issues

Definition of Done

  • Operations simplified to ~50 lines each
  • Atomic backend calls working
  • Optimistic UI updates working
  • Rollback on error working
  • Performance improved 5x

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions