editor_screenshot: address Copilot review on #456#457
Merged
Conversation
Three fixes from the Copilot review on the merged PR: 1. viewport_screenshot_precheck now walks the scene tree for Node3D content instead of only checking the root type. The common "plain Node root with Node3D descendants" and "Node2D root embedding a Node3D preview" patterns now pass the precheck (the 3D viewport can render those scenes). Truly empty 2D scenes still reject. New tests cover deep DFS, Node2D + Node3D descendant, plain Node + Node3D descendant, and the rejection cases. 2. Tool docstring no longer claims error.data includes a `hint` key (it doesn't — the hint text lives in error.message after #456's review fix). Schema-aware clients won't look for a nonexistent field. 3. Tool docstring no longer implies that source="cinematic" requires a Camera3D marked `current`. The handler falls back to the first Camera3D found in DFS; NODE_NOT_FOUND only fires when the scene has no Camera3D at all.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Follow-up to #456 addressing the three Copilot review findings.
Fixes
1.
viewport_screenshot_precheckno longer false-rejects on root-type aloneThe previous check
if scene_root is Node3D: return {}rejected any scene whose root wasn't aNode3D, but it's perfectly valid (and common) for a scene to have a plainNodeorNode2Droot withNode3Ddescendants — the 3D viewport can still render those. New behavior: DFS the scene tree for anyNode3Dcontent, short-circuit on the first hit; reject only when the scene has noNode3Danywhere.The hint copy also updated to say "no Node3D descendants" / "no Node3D content anywhere in the tree" instead of implying the root type itself is the problem.
2. Docstring
error.datashape now matches reality#456's review fix droppedhintfromerror.data(the hint text lives inerror.message), but the tool docstring still listedhintas adatakey. Updated toerror.data = {editor_state: "viewport_not_3d", scene_root_type}with a note that the actionable hint is inerror.message. Prevents schema-aware clients from looking for a nonexistent field.3. Docstring
"cinematic"no longer impliescurrentis requiredThe old wording said
NODE_NOT_FOUND if none is marked current. The actual handler (_find_current_camera_3d) prefers a Camera3D markedcurrentbut falls back to the first Camera3D found in DFS —NODE_NOT_FOUNDonly fires when the scene has zero Camera3Ds. Reworded:Tests
5 new GDScript cases on top of the existing precheck suite:
test_viewport_precheck_passes_for_plain_node_root_with_3d_descendant— the main false-reject scenario from finding Add Phase 2 scene + node write tools (Batches 5-6) #3test_viewport_precheck_passes_for_node2d_root_with_3d_descendant— Node2D wrapper around a 3D previewtest_viewport_precheck_rejects_node2d_root_with_only_2d_descendants— confirms the original 2D-scene problem still rejectstest_viewport_precheck_walks_deep_descendants— DFS reaches nested Node3D content, not just direct children..._with_no_3d_descendantsand kept as the negative casePre-commit
ruff check src/ tests/— cleanpytest -q— 1081 passed, 4 skipped (9 more than editor_screenshot: stop returning INTERNAL_ERROR on 2D/empty viewports #456 baseline from the new precheck DFS coverage in the existing tests + Python relay tests still intact)Risk
Minimal — the precheck only loosens (fewer false rejects), never tightens. Worst case: a scene with a Node3D node that happens to be unrenderable (e.g. all
visible=false) would now pass the precheck and hit the downstream empty-image guard, which now also returnsEDITOR_NOT_READYwith structured data per #456. So even that edge case fails gracefully.