Skip to content

fix(vscode): auto-update imports when files are moved (#112) - #279

Open
mini0n-ai wants to merge 1 commit into
flydelabs:mainfrom
mini0n-ai:fix/broken-imports-moved-files-112
Open

mini0n-ai wants to merge 1 commit into
flydelabs:mainfrom
mini0n-ai:fix/broken-imports-moved-files-112

Conversation

@mini0n-ai

Copy link
Copy Markdown

Summary

Resolves #112 by handling broken imports when imported flows or code nodes are moved or reorganized.

/claim #112
Resolves #112

Root Cause

Previously, when a referenced .flyde flow or .flyde.ts code node was moved to another folder or renamed in the workspace, relative import paths inside .flyde files broke and required manual path fixing.

Key Changes

  1. vscode/src/fileMoveHandler.ts:
    • Registers vscode.workspace.onDidRenameFiles listener in vscode/src/extension.ts.
    • Automatically detects when imported .flyde or .flyde.ts files or directories are renamed/moved.
    • Updates all affected .flyde flow files across the workspace using yaml.parseDocument to preserve structure and comments.
    • Also re-anchors relative imports if a .flyde flow itself is moved to a different directory.
    • Uses vscode.workspace.applyEdit so changes integrate cleanly with the editor's undo stack.
  2. loader/src/resolver/server/findReferencedNodeServer.ts:
    • Graceful fallback in getLocalOrPackagePaths: if an import path does not exist directly, checks common extensions (.flyde, .flyde.ts, .ts, .js) and searches the workspace project hierarchy for moved files, preventing hard crashes.
  3. Automated Unit Tests:
    • Added vscode/src/test/fileMoveHandler.test.ts covering file movement, code node movement, folder renaming, self-movement re-anchoring, and no-op safety. All tests pass 100% green.

Testing

  • @flyde/loader: mocha src/**/*.spec.ts (18 passing)
  • flyde-vscode: tsc -p ./ (0 errors)
  • fileMoveHandler: mocha vscode/src/test/fileMoveHandler.test.ts (5 passing)

Bounty Payout Address (USDC on Base L2):
0x46D5318E4397cFcBED06a235c1604E473682Ea1F

This branch has not been deployed

No deployments
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.

Broken imports after moving files

1 participant