Skip to content

fix(vscode): preserve imports and editor saves across file renames - #289

Closed
gurjara450 wants to merge 1 commit into
flydelabs:mainfrom
gurjara450:fix/112-import-rename-sync
Closed

gurjara450 wants to merge 1 commit into
flydelabs:mainfrom
gurjara450:fix/112-import-rename-sync

Conversation

@gurjara450

Copy link
Copy Markdown

Keep Flyde imports valid when files move in VS Code

Fixes #112

/claim #112

Renaming or moving an imported flow previously left its consumers pointing at the old path. An already-open visual editor could also save an old snapshot after the rename and restore that broken reference. For example, moving ChildFlow.flyde into components/ now updates the parent import to ./components/ChildFlow.flyde, resolves the child in the open editor, and keeps the repaired path through the next visual edit.

The extension participates in workspace.onWillRenameFiles and returns a WorkspaceEdit before VS Code moves the files. It discovers flow documents across workspace roots and includes open flow buffers, then rewrites file references using each importer's original absolute path and the entire rename batch. This handles moved importers, independently moved dependencies, and folder descendants without matching similarly named sibling folders.

The loader helper replaces only YAML scalar ranges. Comments, whitespace, quoting and unrelated values survive. It covers modern file sources, nested inline flows and legacy import keys; malformed or unsafe documents are logged and skipped independently. The rename participant reads current buffers and does not save them, so existing unsaved edits remain dirty.

Visual saves now carry a document version, run in sequence, and reject stale snapshots. External updates cancel pending saves and refresh the resolved editor state. If pre-move resolution produces temporary Error placeholders, the editor retries after a rename matching the unresolved import or the importer itself. Pending resolution survives visual saves because their serialized messages omit resolver metadata. Unrelated renames do not refresh the editor.

Validation

  • Root pnpm test passed with 207 tests: core 135, loader 40, editor 1, nodes 1, VS Code extension host 26, and visual tests 4.
  • The extension-host regression test verifies the repaired buffer path, the displayed ChildFlow node, absence of an Error placeholder after the move, and persistence through another visual edit and save without reopening the parent.
  • Other extension-host tests cover a dirty consumer and unchanged disk contents, a moved importer, a combined importer/dependency batch, and a folder move with prefix siblings and a malformed neighboring document.
  • Synchronization tests cover canceled debounce timers, discarded queued snapshots, late acknowledgements, stale-version rejection, failed edit recovery and disposal.
  • Loader tests cover modern/legacy nested references, batch mapping, folder boundaries, absolute and Windows path rewriting, preserved YAML formatting and safe quoting of renamed filenames.
  • Loader and VS Code builds passed. The full eight-package build passed before the final editor/test-support adjustments.
  • The final editor-state retention adjustment compiled successfully, and all 26 extension-host tests passed again.

Scope and evidence limits

This change handles local file renames delivered through VS Code's rename API. It does not observe arbitrary moves made outside VS Code. Unsafe YAML aliases, multiline references and conflicting rename batches are skipped with a log message rather than partially rewritten. Windows coverage here is path-helper coverage; no Windows GUI session was exercised. The recorded test results establish the stated automated checks. A separate 24-second demo uses three actual native editor screenshots: a prior visual save, a native Explorer dependency rename, and another visual save in the same open webview. Read-only saved YAML confirms the repaired source persists. These are static captured states, not a continuous screen recording.

Demo

import-renames-demo.mp4

Copilot AI balanced review requested due to automatic review settings October 3, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gurjara450 gurjara450 closed this Oct 4, 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

2 participants