Repository navigation
fix: name why a requested screenshot was dropped - #45052
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each code has a named harm: a model that asked for a screenshot and got none retried in a loop. The only extra surface is that the generic code is written in eight places when one would do. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: a model that asks for a screenshot and gets none is told why, so it stops retrying. FIX.
[FIRST-PRINCIPLES-REVIEWED] 8dee21d Description read[DESCRIPTION-READ] e21aeeef77a483c0b0a8fa23f1405971a27cf2be00569c3a5a1c8f28bc5fdae7 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The change adds one defaulted field and three notes, and it fixes the root cause: "no image" was only an empty Notes
[DESIGN-REVIEWED] 8dee21d Description read[DESCRIPTION-READ] d5faf2df662ef64d8cccf669a7b32f053f7791facd7b74c7b33b1b3f5e7bfb23 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
On Windows, a computer_get_state call that asks for a screenshot and gets none says nothing about why. The blank-frame gate in _capture_window_bitmap drops a PrintWindow frame that drew no distinct pixels (a swapchain window such as WindowsTerminal), a minimized window is refused up front, and a failed GDI call, encode or spool returns the snapshot unchanged; render._render_image_note then answers "" for a requested, non-secure, untruncated snapshot with no image. The model gets the tree, no screenshot and no reason, which is the retry loop the secure and truncated notes exist to prevent. The macOS empty-encode and failed-persist exits, the driver-runtime backend's missing or unconvertible PNG, and the service spool failure have the same shape. The exits that know why now stamp an OMITTED_* code on a new Snapshot.image_omitted field, and service.snapshot fills in the generic code at the seam every backend passes when a requested, permitted capture arrives with no image and no code. The renderer maps the code to BLANK_FRAME_NOTE, MINIMIZED_WINDOW_NOTE or CAPTURE_FAILED_NOTE after the tree under the truncated note's rules: only when an image was requested, only when none is attached, and after the secure and truncated notes, which keep precedence. The field carries a code, not text, because the note is appended after redaction and must stay package-owned; an unknown code gets the generic failure note. _capture_window_bitmap raises BlankFrame at the existing gate so the caller can tell a dropped frame from a failed call. The detection, the capture, the gates and the tool's other output are unchanged, and there is still no BitBlt fallback. Fixes kirodotdev#44242
cc31eb9 to
8dee21d
Compare
Code change approver recommendation: A person should decideWhy: the decider estimates a 10% chance that this change introduces a defect, within the 15% limit for approving on its own, but it changes 450 lines, more than the 400 it may approve on its own. When a requested screenshot comes back empty, the snapshot now carries a code saying why (blank frame, minimized, capture failed), and render.py turns it into a note the renderer writes itself. I checked:
Tier: 2, held for a person: 450 changed lines, more than the 400 it approves without a deep review. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 15% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed the reworked head 8dee21df15. Approving.
What I checked in the source diff:
Snapshot.image_omittedcarries a closed code (blank_frame,minimized,capture_failed), andrender._render_image_notemaps it to a note the module owns, after redaction. An unknown code falls back to the generic failure note, so no backend text reaches the model.- The secure and truncated refusals keep precedence, and a note shows only when an image was requested.
- Windows:
BlankFrameis raised only from_capture_window_bitmapafter theSelectObjectrestore, and is caught before the generalexcept Exception. Minimized, failed native call, empty encode and failed persist each stamp their own code. - macOS: empty encode and failed persist now stamp
capture_failed; the up-front unknown-window refusal is unchanged. service.snapshotfills the generic code only for a requested, permitted capture with no image and no code, so withheld frames stay unannounced as before. The spool failure also stamps it.
Verification: the Before/After test run in the description (12 failed on main, 188 passed on the head) plus CI's Windows lanes. This is a capture-path fix with the Windows calls faked, which I accept for this change. Captain held it for a person on size (450 lines), not on a defect.
AI-assisted, sent by Bolin Review bot
Problem / Motivation
Goal: A
computer_get_statecall that asks for a screenshot and gets none tells the model why, instead of returning the tree with no image and no explanation.On Windows, three exits of the capture return the snapshot unchanged: the blank-frame gate in
_capture_window_bitmapdrops aPrintWindowframe that drew no distinct pixels (a swapchain window such as WindowsTerminal), a minimized window is refused up front, and a failed GDI call, encode or spool degrades to the tree.render._render_image_notethen answers""for a requested, non-secure, untruncated snapshot with no image. The model sees the accessibility tree, noScreenshot:line and no note, so it has no reason to stop retrying the capture. The product's own docstrings and tests say every screenshot refusal names its reason;SECURE_WINDOW_NOTEandTRUNCATED_WINDOW_NOTEdo, these three branches did not. The macOS empty-encode and failed-persist exits and the service spool failure have the same silent shape.Why it matters
A model that asked for pixels and silently got none retries
computer_get_statein a loop, burning turns on a window that will never yield a frame (WindowsTerminal and other swapchain surfaces, a minimized window). The operator's log carries a DEBUG line the model never reads. The reporter measured the silent return in 3 of 3 runs on Windows 11 with the shipped 0.13.1 modules.Not a goal
BitBltfallback (ruled out by the spec and pinned by a test: it reads the screen, not the window).gate.pyand governance are untouched).window_id <= 0refusal, which is decided before any capture and is a separate class.What changed (motivation → approach → change)
Symptom: a requested capture ran, attached nothing, and the result said nothing. Root cause: the capture functions encoded "no image" only as an empty
image_path, which the renderer cannot tell apart from "no image was wanted", so it stayed silent for every case the two existing flags (has_secure,truncated) did not cover.Change:
types.py: a newSnapshot.image_omitted: strfield carrying one of three closed codes (OMITTED_BLANK_FRAME,OMITTED_MINIMIZED,OMITTED_CAPTURE_FAILED) and the three notes they map to (BLANK_FRAME_NOTE,MINIMIZED_WINDOW_NOTE,CAPTURE_FAILED_NOTE) inIMAGE_OMITTED_NOTES. The field carries a code, never the text, because the note is appended after the redaction pass and must stay package-owned.capture_windows.py:_capture_window_bitmapraisesBlankFrameat the existing gate (a failed GDI call still returnsNone), so the caller can tell the two apart;capture_snapshot_imagestamps the matching code on the minimized, blank-frame, failed-capture, failed-encode and failed-persist exits. The detection and the capture are unchanged.capture_macos.pyandservice.py: the empty-encode, failed-persist and spool-failure exits stampOMITTED_CAPTURE_FAILED(same class, found by the review panel).service.py:service.snapshotfills inOMITTED_CAPTURE_FAILEDat the seam every backend passes when a requested, permitted capture arrives with no image and no code, so a backend that stamps nothing (the driver-runtime backend's missing or unconvertible PNG) cannot produce the silent shape. A backend's own code is kept; a withheld frame (secure, truncated, no window) and a refresh walk withwant_image=Falseget no stamp.linux_driver.py: the module docstring's tree-only plan now says what a tree-only driver renders.render.py:_render_image_notemaps the code to its note afterSECURE_WINDOW_NOTEandTRUNCATED_WINDOW_NOTE(which keep precedence), only when the walk requested an image, and only when no image is attached. An unknown code gets the generic failure note, never its own text and never silence. The note is plain text after the tree with no path and no pixel data.docs/system-specs/modules/computer-use.md: the suppression-note section and the minimized-window paragraph describe the new behaviour.Shared
render.py: the macOS and Linux render paths are unchanged for every existing input (the new branch fires only when a code is stamped). The same dropped-image case applies on macOS (empty encode, failed persist), to the driver-runtime backend (the default Linux backend, selectable on Windows: a missing or unconvertible PNG) and to the shared spool, so those get the code too, the driver-runtime one through the service seam.Backwards compatibility
Compatible:
Snapshotgains one defaulted field; every existing constructor call,dataclasses.replaceand the fake backend keep working, and a snapshot with no stamp renders exactly as before._capture_window_bitmapnow raisesBlankFrameinstead of returningNoneon a uniform frame; its only caller iscapture_snapshot_imagein the same module, updated here.Removes nothing: the change adds a field and three notes; no path, key, function or output line is hidden, renamed or removed.
Tests
test_computer_use_snapshot.py::TestADroppedCaptureSaysWhy(new): each of the three codes renders its note at the end of the tree when an image was requested; no note whenwant_image=False; secure and truncated notes keep precedence; a present image wins over a stale code; a clean walk stays silent; an unknown code renders the generic failure note and never its own text; the notes carry no path and no pixel data.TestScreenshotSpoolNamesAreUnique::test_a_spool_failure_still_degrades_to_a_tree_only_resultalso asserts the stamp.test_computer_use_capture_windows.py::TestCaptureSnapshotImageEndToEnd: the minimized, blank-frame, failed-capture, empty-encode, failed-persist, raising-capture and raising-encode exits each return the snapshot with the expected code and every other field unchanged (field-by-field); a full capture stamps nothing.TestCaptureWindowBitmap: a blank frame raisesBlankFrameand still never falls back toBitBlt.test_computer_use_capture.py: the macOS empty-encode, native-failure and failed-persist exits stampOMITTED_CAPTURE_FAILEDwith every other field unchanged.test_computer_use_floors.py::TestCaptureFloor: a backend that attaches nothing without a reason gets the generic code at the service seam; a backend's own code is kept; no stamp for an unwanted image or a withheld frame (secure, truncated, no window); an attached image carries no code.Proof: not provable -- other: the per-hunk run reverts two docstring-only hunks (capture_macos.py:125, capture_windows.py:792) that no test can observe and reports them uncaught; every code hunk reverted turned the 18 recorded tests red
Manual verification
N/A — unit coverage sufficient: the change is a stamped field and a rendered line, both driven end to end through the real
dispatch_toolpath by the existing truncated-note test and through faked Windows capture calls by the new ones. No live desktop or gateway run was done.Real-machine verification
Machine: own computer (Linux x86_64, 16 vCPU); the Windows platform run relies on CI's Windows lane.
Before (main d5c0263):
python -m pytest -n0 test/test_computer_use_snapshot.py test/test_computer_use_capture_windows.pywith the new tests applied -> 12 failed, 176 passed (the three codes render nothing; every drop exit returns the snapshot unchanged).After (head 8dee21d): same command -> 188 passed; the eight computer-use test files (
test_computer_use_floors.py,_capture.py,_snapshot_macos.py,_cua_backend.py,test_mcp_computer_actions.pyadded) -> 534 passed.Cleanup: own computer.
This is a Windows-logic fix verified by test on Linux with the Windows capture calls faked; the platform run is CI's Windows lane. No live
computer_get_statewas driven.Review (multi-model interrogate)
Round 1 (first push): three reviewers on different model families reviewed the full diff; one re-check of the revised hunks followed.
capture_snapshot_imageinto one translation point (the issue forbids changing the capture; each exit is a distinct condition with its own test); imports inside test functions (the file's existing convention); announcing the macOSwindow_id <= 0refusal (outside the goal, listed under Not a goal).Round 2 (rebase onto main after #45124): two reviewers on different model families reviewed the full diff (a third refused the prompt size twice); one re-check of the revised hunks followed.
service.snapshotstamps the generic code at the seam, with tests for the stamp, a kept backend code, and no stamp for an unwanted or withheld frame. The_capture_window_bitmapdocstring still called a blank frame a failed capture (1) → reworded.BLANK_FRAME_NOTEstill named a GPU/swapchain cause the gate cannot measure (1) → the note states only the blank frame. Re-check: the seam comment and the spec overclaimed "no backend can produce the silent shape" (the no-window refusal stays unannounced) → narrowed; thelinux_driver.pydocstring's tree-only plan → updated; withheld-frame test parametrized over secure, truncated and no-window; an attached image asserts no code.Literal/enum (dataclasses.replacetakes**changes: Any, so the writer is unchecked either way; the renderer's fallback is the guard and is pinned by a test); wordingCAPTURE_FAILED_NOTEto mention saving (the issue's acceptance criterion names "Screenshot capture failed"); a shared_droppedhelper across two test files (per-file helpers are the files' convention).Related Issues
Fixes #44242
Sibling sweep
Swept:
git grep -nE "return snap$|image_path=\"\"|image_jpeg=b\"\"" -- src/kiro_crew/computer_use/Sibling: src/kiro_crew/computer_use/capture_windows.py -- changed here
Sibling: src/kiro_crew/computer_use/capture_macos.py -- changed here
Sibling: src/kiro_crew/computer_use/service.py -- changed here
Sibling: src/kiro_crew/computer_use/driver_runtime/backend.py -- not affected -- its silent exits are covered by the service seam stamp in service.py, so the file needs no edit
Sibling: src/kiro_crew/computer_use/floors.py -- not affected -- its strip is the secure/truncated/no-window refusal, which
renderalready announces for the first two; the no-window case is a pre-capture refusal outside this goalPattern harvest
Rule candidate: review-prompt
Pattern: a degraded return that drops an attachment the caller asked for must also carry the reason, in a code the renderer maps, not in free text
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.