Skip to content

fix: name why a requested screenshot was dropped - #45052

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
winnythedev:fix/44242-dropped-screenshot-note
Dec 1, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
winnythedev:fix/44242-dropped-screenshot-note

Conversation

@winnythedev

@winnythedev winnythedev commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A computer_get_state call 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_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 degrades to the tree. render._render_image_note then answers "" for a requested, non-secure, untruncated snapshot with no image. The model sees the accessibility tree, no Screenshot: 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_NOTE and TRUNCATED_WINDOW_NOTE do, 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_state in 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

  • Any BitBlt fallback (ruled out by the spec and pinned by a test: it reads the screen, not the window).
  • Changing the blank-frame detection, the capture itself, or any refusal or gate (gate.py and governance are untouched).
  • Changing what the tool returns besides the appended note text.
  • Announcing a drop on a refresh walk that did not request an image.
  • Announcing the macOS window_id <= 0 refusal, 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 new Snapshot.image_omitted: str field 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) in IMAGE_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_bitmap raises BlankFrame at the existing gate (a failed GDI call still returns None), so the caller can tell the two apart; capture_snapshot_image stamps 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.py and service.py: the empty-encode, failed-persist and spool-failure exits stamp OMITTED_CAPTURE_FAILED (same class, found by the review panel).
  • service.py: service.snapshot fills in OMITTED_CAPTURE_FAILED at 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 with want_image=False get no stamp.
  • linux_driver.py: the module docstring's tree-only plan now says what a tree-only driver renders.
  • render.py: _render_image_note maps the code to its note after SECURE_WINDOW_NOTE and TRUNCATED_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: Snapshot gains one defaulted field; every existing constructor call, dataclasses.replace and the fake backend keep working, and a snapshot with no stamp renders exactly as before. _capture_window_bitmap now raises BlankFrame instead of returning None on a uniform frame; its only caller is capture_snapshot_image in 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 when want_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_result also 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 raises BlankFrame and still never falls back to BitBlt.
  • test_computer_use_capture.py: the macOS empty-encode, native-failure and failed-persist exits stamp OMITTED_CAPTURE_FAILED with 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.
  • Red first: with the production hunks absent, 12 of these tests fail (3 render cases, 7 Windows exits, 2 blank-frame gate cases), and the 3 seam tests fail without the service stamp; 534 pass with the fix across the eight computer-use test files.

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_tool path 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.py with 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.py added) -> 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_state was 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.

  • Found and acted on: the new field carried model-facing prose that the renderer appended verbatim after redaction (3 reviewers) → the field now carries a closed code and the renderer owns the text, with an unknown-code fallback test. The class was not fully covered: the macOS empty-encode and failed-persist exits and the service spool failure had the same silent shape (2 reviewers) → stamped, with tests. The blank-frame note asserted a cause the gate cannot prove (2 reviewers) → it now states what was measured and names the swapchain shape as the usual producer. A docstring claimed the renderer announces the unknown-window refusal (1 reviewer) → reworded. Re-check nits: the spec said "every platform" where Linux has no capture path → reworded; the macOS tests lost the identity check → replaced by a field-by-field comparison.
  • Dismissed: restructuring capture_snapshot_image into 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 macOS window_id <= 0 refusal (outside the goal, listed under Not a goal).
  • No security finding at any severity.

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.

  • Found and acted on: the driver-runtime backend (the default Linux backend, selectable on Windows) still returned a requested, permitted capture with no image and no code when the driver sent no PNG or the conversion raised (2 reviewers, also an upstream lane note) → service.snapshot stamps 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_bitmap docstring still called a blank frame a failed capture (1) → reworded. BLANK_FRAME_NOTE still 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; the linux_driver.py docstring's tree-only plan → updated; withheld-frame test parametrized over secure, truncated and no-window; an attached image asserts no code.
  • Dismissed: typing the code as a Literal/enum (dataclasses.replace takes **changes: Any, so the writer is unchecked either way; the renderer's fallback is the guard and is pinned by a test); wording CAPTURE_FAILED_NOTE to mention saving (the issue's acceptance criterion names "Screenshot capture failed"); a shared _dropped helper across two test files (per-file helpers are the files' convention).
  • No security finding at any severity.

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 render already announces for the first two; the no-window case is a pre-capture refusal outside this goal

Pattern 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

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@winnythedev
winnythedev requested review from a team and KiroCrewCaptain as code owners November 30, 2026 18:48
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 8dee21df1559cdb2b25610ad4e8e8bae2fd3f65f touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 8dee21df1559cdb2b25610ad4e8e8bae2fd3f65f via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 4 — oversized: service.snapshot already stamps OMITTED_CAPTURE_FAILED on every requested, permitted capture that comes back with no image and no code. It runs after _persist_image, and every caller of capture_snapshot_image goes through it (macos_driver.py:299, windows_driver.py:374). So the 7 explicit replace(..., image_omitted=OMITTED_CAPTURE_FAILED) writes are second writers whose zero option changes nothing the model sees: 2 in capture_macos.py, 4 in capture_windows.py, 1 in the _persist_image spool. Subtraction: delete those 7 stamps and keep the seam stamp. Only OMITTED_BLANK_FRAME and OMITTED_MINIMIZED need a backend writer.

What this change ships

Inventory (6 items) — 5 justified

Intent: a model that asks for a screenshot and gets none is told why, so it stops retrying. FIX.

  1. A blank PrintWindow frame on Windows now ends the result with a "blank frame" note — justified
  2. A minimized window now ends the result with a "window is minimized" note — justified
  3. A generic "Screenshot capture failed" note now appears for a failed capture, encode or spool, or for an unknown code — justified
  4. Backends and the spool stamp the generic code themselves, and the service seam stamps it too — oversized: seven writes the seam already covers
  5. A new Snapshot.image_omitted field and a new BlankFrame exception — justified
  6. The computer-use spec and the docstrings describe the new notes — justified

[FIRST-PRINCIPLES-REVIEWED] 8dee21d

Description read

[DESCRIPTION-READ] e21aeeef77a483c0b0a8fa23f1405971a27cf2be00569c3a5a1c8f28bc5fdae7

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 8dee21df1559cdb2b25610ad4e8e8bae2fd3f65f via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 image_path, so the renderer could not tell it apart from "no image wanted".

Notes

  • The fallback in service.snapshot stamps OMITTED_CAPTURE_FAILED on every permitted request that comes back with no image. A tree-only backend (the planned Linux driver, or the driver-runtime backend with no PNG) will therefore tell the model "Screenshot capture failed" on every call. That is a fault message for what is really an unsupported capability. A distinct "no screenshot on this backend" code would be more honest, and it is cheap to add later.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 8dee21df1559cdb2b25610ad4e8e8bae2fd3f65f via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8dee21d

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 8dee21df1559cdb2b25610ad4e8e8bae2fd3f65f via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8dee21d

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 30, 2026
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
@winnythedev
winnythedev force-pushed the fix/44242-dropped-screenshot-note branch from cc31eb9 to 8dee21d Compare December 1, 2026 00:20
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Dec 1, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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:

  • The service seam (service.py:210) adds the generic code only for a requested, permitted capture with no image and no code. Withheld frames (secure, truncated, no window) and refresh walks with want_image=False are left alone.
  • The secure and truncated notes still take precedence in the renderer.
  • Windows: the blank-frame check raises BlankFrame, which is caught before the general except Exception. Its only caller is in the same module.
  • macOS: the up-front refusal leaves the snapshot unchanged; the empty-encode and failed-persist exits set a code.
  • Driver-runtime is covered by the seam; the spool failure sets a code.
  • tools._render_snapshot rebuilds with dataclasses.replace, so the field carries through. A policy-stripped image gets no false note.
    Tests cover each exit, the renderer, the unknown-code fallback, precedence and the seam. All CI checks completed green, including the Windows test lanes.

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 8dee21df15 · 450 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the reworked head 8dee21df15. Approving.

What I checked in the source diff:

  • Snapshot.image_omitted carries a closed code (blank_frame, minimized, capture_failed), and render._render_image_note maps 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: BlankFrame is raised only from _capture_window_bitmap after the SelectObject restore, and is caught before the general except 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.snapshot fills 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

@bolichen97
bolichen97 merged commit aed6214 into kirodotdev:main Dec 1, 2026
112 of 115 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Dec 1, 2026
@winnythedev
winnythedev deleted the fix/44242-dropped-screenshot-note branch December 1, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Computer Use: a screenshot the blank-frame gate drops returns no image and no reason

3 participants