Skip to content

Rebuild the open tab a pack overwrites - #1080

Merged
saworbit merged 2 commits into
mainfrom
fix/pack-branch-open-tab
Sep 30, 2026
Merged

saworbit merged 2 commits into
mainfrom
fix/pack-branch-open-tab

Conversation

@saworbit

Copy link
Copy Markdown
Owner

Fixes #1072

Problem

scene_pack_branch with overwrite: true saves inside the editor with ResourceSaver.save. A tab that had the target open kept its old tree, and the next editor_save_scene wrote it back over the pack. The pack said saved: true and the save said saved.

What changed

  • scene_pack_branch now runs the same editor copy refresh as the file writers after a pack that saved. The cached copy is reloaded and an open tab is rebuilt from the packed file. The answer carries editor_copy_reloaded and, when a tab was rebuilt, editor_scene_reloaded.
  • overwrite: true is the consent to lose the tab's unsaved changes, the same call viewport_create_test_lab and scene_create make. So the pack never refuses over an open tab, and there is no new argument.
  • On 4.5 and 4.6 a rebuilt tab left of a current last tab stayed the edited scene, and later scene calls acted on it. This hit the [Editor sync] Reload an open scene tab when a file writer rewrites its scene聽#1068 writers too. The bridge now answers edited_scene_moved_from, and the server opens that scene again with scene.open once the tabs are done.
  • Along the way: scene_create over a scene no tab holds no longer asks for a reload. On 4.7 that printed Can't reload scene ..., as it's not opened. The new harness case caught it.
  • Along the way: the harness allow entry for the deliberately broken fixture script also matches Failed parse script, the wording 4.5.1 prints when a GDScript language server client connects and the editor re-parses every script.

Engine facts this rests on

Read from editor/editor_node.cpp at 4.5.1, 4.6.2 and 4.7.2, and measured with a live editor on each:

  • 4.5 and 4.6 end reload_scene with scene_tabs->set_current_tab(current_tab). The tab bar already sits at that index when the rebuilt tab was left of a current last tab, so nothing switches back. 4.7 rewrote the recovery and keeps the current tab.
  • open_scene_from_path and reload_scene_from_path return early while is_changing_scene() is set, which lasts until the deferred _set_main_scene_state at the end of the frame. So the switch back has to be a later request.
  • 4.7's reload_scene fails with an error for a path no tab holds. 4.5 and 4.6 clear the current scene's undo history instead.

Tests

  • Native: a pack rebuilds the target's tab after the pack and never before it, with discard_unsaved. A refused pack asks nothing. A rebuild that moves the edited scene is switched back once, to the scene the caller was on. A switch back the editor refuses is named with the way out. A rebuild that keeps the current scene asks nothing more.
  • Live harness, Invoke-PackBranchTabBlock in tests/scene_tab_reload.ps1: the steps from the issue. It packs over a scene open in another tab, checks the edited scene did not move, opens and saves the target, and reads the file. A second session closes the target and overwrites it with scene_create. All three lines pass locally. Before the switch back, 4.5.1 failed on the edited scene check.

Filed from this

scene_pack_branch saves inside the editor, so a tab holding the target kept
its old tree and the next editor_save_scene put it back over the pack. The
pack now goes through the same editor copy refresh as the file writers, with
overwrite: true as the consent to lose the tab's changes.

On 4.5 and 4.6 a rebuilt tab left of a current last tab stays the edited
scene, because reload_scene ends with a set_current_tab that does nothing
when the bar is already there. The bridge now names the scene it moved from,
and the server opens it again on a later frame. This covers the #1068
writers too.

scene_create over a scene no tab holds no longer asks for a reload. That
printed "Can't reload scene" on 4.7 and cleared the current scene's undo
history on 4.5 and 4.6.

The harness allow entry for the deliberately broken fixture script also
matches the wording a GDScript language server client triggers on connect.
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests Test suites and the contracts they assert addon The Godot addon and the in-engine GDExtension mcp-protocol The MCP wire surface: tools, schemas, annotations labels Sep 30, 2026
@saworbit
saworbit merged commit b8ab7e3 into main Sep 30, 2026
28 checks passed
@saworbit
saworbit deleted the fix/pack-branch-open-tab branch September 30, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addon The Godot addon and the in-engine GDExtension documentation Improvements or additions to documentation mcp-protocol The MCP wire surface: tools, schemas, annotations tests Test suites and the contracts they assert

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Editor sync] Rebuild an open scene tab when scene_pack_branch overwrites its scene

1 participant