Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xranx OpenContext Move Service

From Leeroopedia
Knowledge Sources
Domains Move_Rename, Caching
Last Updated 2026-10-24 00:00 GMT

Overview

Move and rename cache rewriting service that updates folder docs cache, expanded folders state, and selected document paths after folder or document moves.

Description

The move.js module in src/ui/src/services/ provides cache-rewriting utilities for move operations. rewriteFolderDocsCache remaps folder doc cache keys from old to new paths. rewriteExpandedFolders rewrites expanded folder set entries. rewriteSelectedDocAfterFolderMove updates a selected doc's rel_path. moveDocFlow and moveFolderFlow orchestrate full move workflows: calling the API, refreshing the folder list, and computing the new path. It also re-exports path utilities (basename, dirname, isDescendantPath, rewritePrefix).

Usage

Import these functions in SidebarTree or App.jsx when handling drag-and-drop moves or rename operations.

Code Reference

Source Location

Signature

export function rewriteFolderDocsCache(prev, sourcePath, newPath)
export function rewriteExpandedFolders(prevSet, sourcePath, newPath, targetFolderPath)
export function rewriteSelectedDocAfterFolderMove(prevSelectedDoc, sourcePath, newPath)
export async function moveDocFlow({ api, docRelPath, targetFolderPath })
export async function moveFolderFlow({ api, sourcePath, targetFolderPath })

Import

import { rewriteFolderDocsCache, moveDocFlow, moveFolderFlow } from './services/move';

I/O Contract

Inputs

Name Type Required Description
api object Yes API abstraction (moveDoc, moveFolder, listFolders)
docRelPath string Yes (moveDoc) Document relative path
sourcePath string Yes (moveFolder) Source folder path
targetFolderPath string Yes Destination folder

Outputs

Name Type Description
moveDocFlow object { folders, oldParentPath, targetFolderPath, newRelPath }
moveFolderFlow object { folders, newPath, targetFolderPath }

Usage Examples

Moving a Document

import { moveDocFlow, rewriteFolderDocsCache } from './services/move';

const { folders, newRelPath } = await moveDocFlow({
  api,
  docRelPath: 'old-folder/doc.md',
  targetFolderPath: 'new-folder'
});

// Update cache
const newFolderDocs = rewriteFolderDocsCache(folderDocs, 'old-folder', 'new-folder');

Moving a Folder

import { moveFolderFlow, rewriteExpandedFolders } from './services/move';

const { folders, newPath } = await moveFolderFlow({
  api,
  sourcePath: 'old-folder',
  targetFolderPath: 'parent'
});

const newExpanded = rewriteExpandedFolders(expandedFolders, 'old-folder', 'parent/old-folder', 'parent');

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment