Skip to content

fix(vscode): keep .flyde imports working after files are moved - #288

Closed
ntoledo319 wants to merge 1 commit into
flydelabs:mainfrom
ntoledo319:fix/112-imports-survive-file-move
Closed

ntoledo319 wants to merge 1 commit into
flydelabs:mainfrom
ntoledo319:fix/112-imports-survive-file-move

Conversation

@ntoledo319

Copy link
Copy Markdown

Summary

Fixes #112
/claim #112

Flow files reference imported nodes via workspace-relative paths in each instance's source.data. When an imported .flyde file was moved to another folder, the stored relative path no longer resolved and the import broke.

What changed

  • @flyde/loader — new updateFlydeImportsAfterMove() (loader/src/resolver/server/updateMovedFlydeImports.ts): given a flow's contents and a file move (old path → new path), it rewrites the affected source.data references. Edits go through the YAML document AST, so unrelated formatting/content is preserved. Returns null when nothing needs updating.
  • flyde-vscode — new vscode.workspace.onDidRenameFiles listener (vscode/src/update-imports-on-rename.ts) that applies the rewrite to every .flyde file in the workspace after files are moved/renamed. It handles both directions:
    • an imported file moved → references pointing at its old path are re-pointed at the new path
    • a flow file itself moved → its relative file imports are re-relativized against the new location
    • folder moves work too (VS Code reports each affected file; moves are applied sequentially)
  • The extension now also activates via workspaceContains:**/*.flyde so moves are handled even before a flow editor is opened.

Verification

  • 8 new unit tests in loader/src/resolver/server/updateMovedFlydeImports.spec.ts — all passing (imported-file move, importing-flow move, both moved together, unrelated move, package sources untouched, .flyde.ts code imports, formatting preservation, unparseable flow).
  • Full monorepo pnpm build passes (typechecks loader + extension).
  • eslint clean on changed extension files.
  • End-to-end check with the nested-flows fixtures: reproduced the breakage after moving ChildFlow.flyde, applied the rewrite (./ChildFlow.flyde → ./nested/ChildFlow.flyde), and the flow resolves again.

Demo

before move: resolves OK
after move without fix: broken as expected (issue reproduced)
updated import line: data: ./nested/ChildFlow.flyde
after fix: resolves OK

Known limitation

If a flow affected by a move is currently open in the Flyde editor with unsaved changes, a later save from the webview could overwrite the rewritten import. Handling that requires editor-state coordination beyond this focused fix.


Built with AI coding assistance (Kimi Code) under human direction; the diff was reviewed and verified locally before submitting.

Flow files reference imported nodes through workspace-relative paths in
each instance's source.data, so moving an imported .flyde file to
another folder broke the import (flydelabs#112).

The extension now listens to workspace file rename events and rewrites
the affected references in every .flyde file:

- when an imported file moves, references resolving to its old path are
  re-pointed at the new path
- when a flow file itself moves, its relative file imports are
  re-relativized against the new location

The rewriting logic lives in @flyde/loader (updateFlydeImportsAfterMove)
and edits the YAML document AST so unrelated formatting is preserved.
The extension also activates on workspaces containing .flyde files so
moves are handled even before a flow editor is opened.

Built with AI coding assistance under human direction.
@ntoledo319

Copy link
Copy Markdown
Author

Withdrawing for now to keep the review queue light — happy to reopen if the fix approach is wanted.

@ntoledo319 ntoledo319 closed this Oct 7, 2026
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