fix(explorer): keep an open file's tab and unsaved edits on rename
Summary
Renaming a file in the explorer closed its editor tab with closeFile, which does not check for unsaved edits. A dirty buffer was thrown away and only the last saved content survived on disk. Renaming a folder left the tabs of the files under it pointing at paths that no longer exist.
A rename now moves each open file to its new path and keeps its buffer, dirty flag, cursor and scroll position. The workspace tab moves with it, in the same pane and position. Saving writes to the new path.
Related Issue
Closes #1290
Type of Change
- fix: bug fix
What Changed
renameOpenFilein the editor store re-keys an open file.renameEditorTabin the workspace store re-keys its tab.moveOpenEditorTabsinsrc/renderer/lib/editor-tab-rename.tsfinds every open file at or under the renamed path and moves it. It flushes the live editor buffer first.- The desktop explorer rename and the phone file browser rename both call it. The phone browser had the same bug, so both surfaces change together.
How It Was Tested
-
bun run typecheck: the node, web and testtscprojects pass. -
bun run test: ran the touched files with vitest (305 tests, 17 files pass), not the full suite. The newuse-explorer-entry-flows.rename.test.tsxfails on origin/dev (2 of 3 fail, the open file is gone) and passes with the fix. It covers a dirty file rename with save at the new path, a folder rename, and a failed rename. - Manual verification completed: not driven in a running app.
CI & Review Gate
- All CI checks pass (PR Validation, Rust Checks, Build Verification, Security Scans)
- Code review comments from CodeRabbit / Claude have been addressed or resolved
- No unresolved review findings remain
Checklist
- My PR title follows the conventional commit format used by this repo
- I linked the related issue or explained why none exists
- I added or updated tests when needed
- I verified the change does not introduce unrelated modifications
- I read AGENTS.md and followed the contributor guidelines
Summary by cubic
Renaming a file or folder in the explorer no longer discards unsaved edits or closes editor tabs. Open files at or under the renamed path move to the new path, keeping their buffer, dirty flag, cursor, and scroll position, and their tabs move with them in the same pane and position. Saving writes to the new path; on a failed rename, open files and tabs stay untouched. Desktop and phone file browsers use the same fix.
What Changed
moveOpenEditorTabsinsrc/renderer/lib/editor-tab-rename.tsflushes editor buffers, then re-keys every open file at or under the renamed path and its matching tab in place.- A renamed open file has its in-flight save reset to idle, so autosave saves it at the new path instead of carrying over a stale operation status.