Rebuild an open scene tab when a writer rewrites its scene - #1071
Merged
Merged
Conversation
project_rename_references and project_apply_changes reloaded only the editor's cached copies. An open tab is a node tree built from the file, so it kept the old scene and the next editor_save_scene wrote it back over the file (#1068). The bridge now rebuilds the tab with reload_scene_from_path, one tab a request because a second reload in the same frame does nothing on 4.5 and 4.6, and checks the root was replaced. Before writing, both tools ask the new editor.openScenes read and refuse a rewritten scene whose tab has unsaved changes, or any open one before 4.7, unless discard_unsaved is passed. The previews make the same check. viewport_create_test_lab rebuilds an open lab tab on overwrite. The rename's refusal of a new_name already in use now names the field.
The first description put the full listing 380 bytes over its budget. The refusal already explains the argument where an agent reads it, so the schema says only what true allows. Contract snapshots regenerated.
The rename writes files in scan order, which is alphabetical on NTFS and not on APFS or ext4, so the test failed on macOS and the sanitizer job.
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1068
Problem
project_rename_referencesandproject_apply_changesrewrite.tscnfiles. The refresh from #1047 reloads what the editor's resource cache holds, and an open tab is not in it. The tab is a node tree the editor built from the file, so it kept the old scene, and the nexteditor_save_scenewrote that back over the file. The writer said success andeditor_copies_reloaded: [].What changed
resource.refreshCachednow also rebuilds the tab of a path open in the editor, withEditorInterface.reload_scene_from_path, and says so per path. It checks the reload took by the tab's root: a reload that happened replaced it.editor.openScenes, answers the open tabs and the unsaved reporteditor.getStatealready carries.409 unsaved_changes. Before Godot 4.7 the engine cannot say, so any open one refuses with409 dirty_state_unavailable. Both name the scenes and carrydiscard_unsaved: trueinretry_with. Nothing is written. The confirmation previews make the same check, so they refuse what the call would.discard_unsavedis a new boolean on both tools. It is the caller accepting the loss of the tab's unsaved changes, the same wordscene_closeuses.editor_scenes_reloaded. A tab left stale is named ineditor_copy_errorswith the reason and the way out.viewport_create_test_labrebuilds an open lab tab on overwrite, the wayscene_createalready reloads the scene it overwrites.new_namealready in use named no fix. The new harness block was the first to reach it, and the remedy check failed on it. It now namesnew_nameas the field.discard_unsaveddescription is one short sentence. The first draft put the full listing 380 bytes over thetools/listbudget, and the refusal already explains the argument where an agent reads it.Engine facts this rests on
Measured with a throwaway editor plugin on 4.5.1, 4.6.2 and 4.7.2:
reload_scene_from_pathis synchronous. It returns with a new root holding the new file, keeps whichever tab was current, and drops the tab's unsaved changes and undo history. On 4.7 the scene leavesget_unsaved_scenes.get_open_sceneslists.Tests
discard_unsaved. Apply refuses the same way before its check runs. A tab that could not be rebuilt is named. The check asks only when it can matter.tests/scene_tab_reload.ps1: the steps from the issue. A scene with a connection is opened and edited, the rename refuses, the scene is saved, and the rename runs (withdiscard_unsavedbefore 4.7). Then an edit and a save. The file keeps the new method name and the edit, on all three lines.