Imported glb appears twice when the scene is run via command palette

Godot Version

4.6.2

Question

I’m making an editor tool that I want to run through the command palette. When I run the scene via F6 everything works as expect and it looks like this:

However, when I launch it via the command palette the character scene shows up twice. One of them acts as expect and plays the animation. The other always runs the Idle animation.

The character is an imported GLB that I dragged into my scene and marked as ‘Editable Children’ so that I could add a bone attachment and animation tree. I have not changed the hierarchy of the imported GLB scene nor changed any of its node names. This is the scene tree:

To launch the tool from the command palette I have an EditorScript that creates a new window, instantiates the PackedScene, and adds the packed scene as a child of the window. I don’t think this script is relevant, but just in case here it is:

@tool
class_name WeaponProfileEditor extends EditorScript

var _window : Window
var _editor := preload("uid://dacagvr232tuw") # weapon_profile_builder.tscn

# Called when the script is executed (using File -> Run in Script Editor).
func _run() -> void:
	_window = Window.new()
	EditorInterface.popup_dialog(_window, Rect2(Vector2.ZERO, Vector2(1920, 1080)))
	_window.close_requested.connect(func() -> void: _window.queue_free())
	var editor := _editor.instantiate()
	_window.add_child(editor)

Everything other than the duplicated GLB is functioning as expected. I’m not sure if this is a bug in Godot, or if I’m missing something.

I threw a quick test scene together that is just the glb and a camera. When I launch it through the command palette I get the same result. It even happens if the glb isn’t marked as ‘Editable Children’ I’m leaning toward this being a bug in the engine.

Ok, so it would seem that the command palette runs scripts as part of whatever scene is currently selected in the editor. That is why I was seeing a duplicate 3d model. This is what it looks like if I run my tool via command palette while my test level scene tab is selected in the editor.

So, maybe the thing to do it not use the command palette and figure out how to add a tab or something to editor to run my tool in.

Updating in case this helps someone in the future.

I ultimately ended up hiding the current editor scene root when I start the plugin and then restore it when I close the plugin window.

var scene_root : Node
func _show() -> void:
	scene_root = get_editor_interface().get_edited_scene_root()
	if scene_root:
		scene_root.visible = false
	if _window:
		get_tree()
		_window.popup_centered()


func _hide() -> void:
	if scene_root:
		scene_root.visible = true
	_window.hide()