Commit d57e05e
authored
editor_screenshot: stop returning INTERNAL_ERROR on 2D/empty viewports (#456)
* editor_screenshot: stop returning INTERNAL_ERROR on 2D/empty viewports
Telemetry showed editor_screenshot returning INTERNAL_ERROR on 63
unique installs / 152 hits in 24h, persisting across every plugin
version 2.5.0 -> 2.5.6. The per-uuid distribution is broad and shallow
(25 uuids hit once, 32 hit 2-4 times, only 1 looped 11x), so LLMs try
the default source once, get an unhelpful "Failed to capture image
from viewport" with no signal that the failure is caller-side, and
give up.
Two changes ship together:
1. Pre-check the edited scene root before pulling the 3D viewport
texture. When source="viewport" and the root is Node2D, Control,
plain Node, or null (no scene open), return EDITOR_NOT_READY with
`error.data = {editor_state: "viewport_not_3d", scene_root_type,
hint}` carrying an actionable hint (open a 3D scene, switch to
source="cinematic" if a Camera3D exists, or call
scene_get_hierarchy first). The 3D viewport's texture is empty for
2D-rooted scenes, and the previous empty-image guard returned
INTERNAL_ERROR — same shape we use for genuine server bugs, with
no caller-actionable signal.
2. Reclassify the three remaining empty-image returns that AREN'T
caller-side debugger-bridge wiring failures:
- "Failed to capture image from viewport" (main path)
- "Framed viewport rendered an empty image" (view_target path)
- "Coverage sweep rendered no images"
- "Cinematic render produced an empty image"
These are precondition failures (headless mode, viewport not drawn
yet, scene-camera misframed) and now return EDITOR_NOT_READY +
`error.data = {editor_state: "viewport_empty", source, hint}`. The
two debugger-bridge wiring errors for source="game" stay
INTERNAL_ERROR — those are genuine server-side failures.
Tool docstring updated to surface the 2D/no-scene constraint and
Camera3D requirement up front.
Tests: 6 new GDScript test cases for viewport_screenshot_precheck
covering Node3D root (passes), Node2D / Control / plain Node / null
roots (all return the structured EDITOR_NOT_READY), and Node3D
subclass (passes). 2 new Python handler tests verify the
viewport_not_3d and viewport_empty error.data shapes propagate
through GodotCommandError to the MCP client.
* editor_screenshot: address review feedback on #456
- Fix #XXX placeholder -> #456 in test header.
- Drop redundant `hint` key from `error.data` in both viewport_not_3d
and viewport_empty error helpers. The hint copy already lives in
`error.message`, and GodotCommandError's string form appends every
`data` key -- keeping the hint in both surfaced the same paragraph
twice to the LLM. Tests now assert on `error.message` for the hint
content.
- Make `_empty_image_error` static for consistency with the other
error-builder helpers; none reference self.1 parent 7b83c97 commit d57e05e
4 files changed
Lines changed: 232 additions & 6 deletions
File tree
- plugin/addons/godot_ai/handlers
- src/godot_ai/tools
- test_project/tests
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
282 | 292 | | |
283 | 293 | | |
284 | 294 | | |
| |||
385 | 395 | | |
386 | 396 | | |
387 | 397 | | |
388 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
389 | 402 | | |
390 | 403 | | |
391 | 404 | | |
| |||
423 | 436 | | |
424 | 437 | | |
425 | 438 | | |
426 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
427 | 443 | | |
428 | 444 | | |
429 | 445 | | |
| |||
445 | 461 | | |
446 | 462 | | |
447 | 463 | | |
448 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
449 | 468 | | |
450 | 469 | | |
451 | 470 | | |
| |||
507 | 526 | | |
508 | 527 | | |
509 | 528 | | |
510 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
511 | 533 | | |
512 | 534 | | |
513 | 535 | | |
514 | 536 | | |
515 | 537 | | |
516 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
517 | 604 | | |
518 | 605 | | |
519 | 606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
132 | 139 | | |
133 | | - | |
| 140 | + | |
| 141 | + | |
134 | 142 | | |
135 | | - | |
| 143 | + | |
| 144 | + | |
136 | 145 | | |
137 | 146 | | |
138 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
131 | 196 | | |
132 | 197 | | |
133 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3369 | 3369 | | |
3370 | 3370 | | |
3371 | 3371 | | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
3372 | 3437 | | |
3373 | 3438 | | |
3374 | 3439 | | |
| |||
0 commit comments