Skip to content

feat(windows): capture selected native windows - #2199

Open
SoGeRiEn wants to merge 4 commits into
morluto:mainfrom
SoGeRiEn:feat/windows-target-window-capture
Open

SoGeRiEn wants to merge 4 commits into
morluto:mainfrom
SoGeRiEn:feat/windows-target-window-capture

Conversation

@SoGeRiEn

Copy link
Copy Markdown

Closes #2183.

Scope

Add capture_windows_window_screenshot, a Windows x64, screenshot-only native capability for one already-open PE application target.

  • Requires an exact PID and canonical lowercase HWND rather than title, foreground-window, desktop, or region selection.
  • Binds the HWND to the PID before and after capture, checks process start identity and image path, and verifies the selected on-disk PE SHA-256 before and after capture.
  • Uses a bounded WM_PRINT client-area render only. No desktop BitBlt fallback, window enumeration, title search, input, UI Automation, target launch, elevation, config persistence, or caller-chosen output path.
  • Zero-initializes the DIB, flushes GDI, forces opaque alpha, excludes child HWND rendering, and uses a fixed-capacity 3 MiB PNG stream so an incomplete paint cannot leak process memory or overflow the default duplicated MCP response budget.
  • Declares WM_PRINT authority truthfully: it can execute the selected target paint handler and therefore can affect target UI, filesystem, or network state.

The macOS observe_native_ui contract is unchanged. This is intentionally a distinct narrower operation because it has no accessibility-tree or action authority.

Contract and delivery

Adds CLI/MCP parity, Evidence schemas, Windows x64 capability discovery, PE-application availability gating, exact output validation, effect metadata, docs, and the packaged Windows addon dispatch/build inputs.

Validation run from a clean clone

  • npm ci
  • npm run check:fast
  • npm run test:focused -- seven affected domain/adapter/service/CLI/MCP/delivery test files: 11 passed
  • npm run docs:check
  • npm run verify:test-discovery: 922 files discovered exactly once
  • git diff --check
  • File-by-file credential review and secret-pattern scan: no credentials, profiles, artifacts, private endpoints, or personal infrastructure included.

Not yet verified

This is a draft because I do not have an interactive Windows x64 desktop or MinGW-w64 on the contribution host. npm run build:windows-native correctly refuses to run because x86_64-w64-mingw32-g++ is absent; I did not install build tools automatically. The required real acceptance remains a packaged Windows x64 source-owned GUI fixture covering native addon, CLI, and stdio MCP, including destroyed-window/refusal behavior. The documentation calls out this gap explicitly.

No external MCP implementation, user profile, runtime state, configuration, or screenshot artifact is included.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[High impact] The reviewed code appears safe to merge with non-blocking fixes for the provider catalog and browser-transition cancellation.

Findings

  1. P2 Catalog names the wrong provider ▶
  2. P2 Cancelled comparisons still save records ▶
Fix with agent prompt
### Issue 1
src/contracts/native/nativeToolContracts.ts:84-88
Adding `capture_windows_window_screenshot` to `NATIVE_TOOL_CONTRACTS` also assigns it to `native-macos` in the generated catalog. `providerCatalog` still gives that provider the entire list and has no entry for `native-windows-ui`, which actually owns capture.

This is a non-blocking documentation error: readers get the wrong provider and cannot find the real one. Split the catalog entries using each provider's own operation declaration.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 2
src/server/registerUiStateTransitionTool.ts:29-34
For large page Evidence, a cancellation queued during parsing or comparison cannot run before this handler saves the sources and transition. The service checks `signal.aborted` synchronously, and the shared handler's Promise waits do not give stdio a turn to read cancellation.

This is non-blocking, but cancelling can still leave unwanted records in the session. Use `runDerivedOperation` and save records after its final cancellation check.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds selected-window PNG capture for Windows x64 and a browser Evidence tool for before/after UI states.

  • Windows callers can capture a PNG from one exact application window.
  • Browser observations can be compared without claiming what caused a change.
  • TypeScript skips timestamped files during project checks and builds.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI or MCP] --> B[PE application and exact PID/HWND]
  B --> C[Check executable identity and SHA-256]
  C --> D[Bounded WM_PRINT]
  D --> E[Encode bounded PNG]
  E --> F[Check executable again]
  F --> G[Evidence]
  H[Before and after browser Evidence] --> I[Derive UI state pair]
  I --> J[Save sources]
  J --> G
Loading

Reviews (16) · Last reviewed commit: "fix(browser): retain UI transition sourc..." · Reviewed by Greptile

Comment thread native/windows/src/window_capture.cc Resolved
Comment thread native/windows/src/addon.cc Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
@morluto
morluto marked this pull request as ready for review October 13, 2026 11:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-16T15:39:34.678026Z 1cdc72f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68e9e7c0b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread scripts/build-windows-native.mjs Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread native/windows/src/window_capture.cc Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74a6e3208c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread native/windows/src/window_capture.cc Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Fixed in 11d35d0. WM_PRINT and WIC encoding now run as native async work following the existing owned process-input worker pattern. The worker owns and unwinds all Win32/GDI/COM resources and returns plain captured data; N-API object creation occurs only in the JavaScript completion callback. A shared cancellation owner safely survives either callback lifetime: queued work is cancelled, running paint waits at its existing five-second deadline, and the provider awaits settlement before dropping cancellation registration. Encoder/stream resources are released before moving retained PNG bytes. Source inspection of the native execute/completion/cancel paths and adapter consumers, plus git diff --check, passed. Tests/builds/real Windows verification were not run at explicit user request. This supersedes the earlier open-status reply; no related code cleanup remains.

  1. thread 1

Fixed in bc6387d. Before WM_PRINT, the native async worker opens and pins the active target and selected process-image files with read-only, non-write/delete-sharing handles. It requires matching full 128-bit file IDs/volume identity, confirms the target still matches its admitted dev/inode identity, and hashes the pinned target bytes against the active session SHA-256. Only then can the selected paint handler run; process/window checks remain after capture. The file handles stay owned through rendering/encoding, and snapshot/capture hashing share one BCrypt state owner. Source inspection and git diff --check passed. Tests/builds/native Windows verification were not run at explicit user request. Node stat identity mapping was checked against the pinned libuv source: https://github.com/libuv/libuv/blob/v1.52.1/src/win/fs.c#L1775. No related code cleanup remains.

  1. thread 1

Fixed in 74a6e32. STG_E_MEDIUMFULL now returns AnalysisResourceConstraintError for the measured retained PNG capacity, with the shared maximum PNG byte limit and remediation to reduce max_dimension. Win32 allocation and HRESULT allocation failures separately return memory resource errors; they do not claim the PNG capacity was the measured cause. Source inspection and git diff --check passed. Tests/builds/native Windows verification were not run at explicit user request. No related code cleanup remains.

Comment thread src/windows/NativeWindowsUiProvider.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42b15d1ef9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread native/windows/src/window_capture.cc Resolved
Comment thread native/windows/src/window_capture.cc Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Fixed in b303ffa and 42b15d1. The root cause was encoding semantic authorization refusals only as generic Win32 codes, which the provider then reinterpreted as HWND/output failures. The native boundary now emits an explicit artifact-change tag for changed admitted file identity or digest; N-API preserves the tag and the provider maps it to AnalysisArtifactChangedError before generic Win32 classification. The admitted target identity check also precedes process-image comparison so replacement is classified at its producing boundary. Source inspection followed the native producer, N-API error serialization, provider Result mapping, and affected callers. git diff --check passed. Relevant regressions were added/updated but were not run, per the explicit request to skip tests and checks; native Windows execution remains unverified. No directly related cleanup remains.

  1. thread 1

Fixed in b303ffa. The pre-paint guard proved only numeric PID ownership and the later check used a rounded display timestamp. Native capture now retains the full FILETIME creation token, reopens the selected PID immediately before WM_PRINT, checks the exact token, source executable path and process liveness, and keeps that revalidated process handle through rendering/encoding. The same owner helper performs the final identity validation; milliseconds are used only for displayed evidence. Source inspection followed the native producer, N-API error serialization, provider Result mapping, and affected callers. git diff --check passed. Relevant regressions were added/updated but were not run, per the explicit request to skip tests and checks; native Windows execution remains unverified. No directly related cleanup remains.

  1. thread 1

Fixed in b303ffa. Cancellation was checked before asynchronous reads but not after the final read settled. The executable-hashing owner now checks after each awaited handle.read and after the loop; the screenshot workflow also checks immediately after the final concurrent identity reads and before constructing successful Evidence. A regression aborts during those final identity reads and expects the tagged cancellation result. Source inspection followed the native producer, N-API error serialization, provider Result mapping, and affected callers. git diff --check passed. Relevant regressions were added/updated but were not run, per the explicit request to skip tests and checks; native Windows execution remains unverified. No directly related cleanup remains.

  1. thread 1

Fixed in b303ffa. ERROR_ACCESS_DENIED conflated deliberate ownership refusals with file-open denial. Native failures now carry distinct window-owner/process-identity tags, which survive N-API and map to AnalysisInputError for the actual HWND/PID. Filesystem EACCES mapping requires a native requested file path and preserves that path. The post-capture identity fallback uses the same request-scoped input classification instead of disabling the capability. Regression cases cover semantic tags independently of their Win32 code. Source inspection followed the native producer, N-API error serialization, provider Result mapping, and affected callers. git diff --check passed. Relevant regressions were added/updated but were not run, per the explicit request to skip tests and checks; native Windows execution remains unverified. No directly related cleanup remains.

@morluto morluto added enhancement New feature or request area: runtime Process capture and runtime observation area: cli CLI adapter and one-shot commands area: server Server layer and tool wiring P2: medium Medium priority issue labels Oct 13, 2026
morluto added a commit to SoGeRiEn/rea that referenced this pull request Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2568af4cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread native/windows/src/window_capture.cc Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread, review thread

Fixed publicly in b2568af. The generic Win32 fallback retained only filesystem access semantics, so code 5 without a source file path became unreadable_output. Pathless code-5 refusals now retain a process/window access subject (the selected PID/HWND) in AnalysisAccessDeniedError. The shared CLI/MCP projection emits access_denied with boundary process-window and process/window permission remediation; file-open denials still preserve their actual path and filesystem-read boundary. Existing identity tags remain input errors rather than being folded into permission refusals. Provider regressions include absent and empty requestedPath without a failureKind; a shared projection regression rejects an invented filesystem path. Source inspection covered the producing boundary and affected consumers; prior live history is preserved and git diff --check passed. Tests, builds, lint, typechecks, provider workloads and CI reruns were not run at the explicit user request. No directly related source cleanup remains.

review thread

Fixed publicly in b2568af. OS/architecture availability did not establish support in the loaded artifact. Native inspection now reports an affirmative windowCapture marker; the loader preserves it as an optional capability so older compatible addons remain usable for their other controls. Capture inventory requires the observed marker, and the invocation boundary checks it again before dispatch, returning capability-unavailable with rebuild/install guidance for old artifacts. Loader/metadata regressions preserve old-artifact admission while refusing to advertise capture. Native Windows execution remains unverified. Source inspection covered the producing boundary and affected consumers; prior live history is preserved and git diff --check passed. Tests, builds, lint, typechecks, provider workloads and CI reruns were not run at the explicit user request. No directly related source cleanup remains.

review thread

Fixed publicly in b2568af. The shared executable opener did not distinguish the already-admitted active target from the observed process image. Target-side open failures with ERROR_FILE_NOT_FOUND/ERROR_PATH_NOT_FOUND now carry ArtifactChanged from the producer; process-image opens retain their distinct native failure path. Existing tagged provider mapping therefore returns artifact_changed without guessing from downstream text or a generic missing-path code. Regressions include artifact-change tags with both Win32 disappearance codes. Native Windows execution remains unverified. Source inspection covered the producing boundary and affected consumers; prior live history is preserved and git diff --check passed. Tests, builds, lint, typechecks, provider workloads and CI reruns were not run at the explicit user request. No directly related source cleanup remains.

review thread

Fixed publicly in b2568af. Each capture independently queued long paint/hash/encoding work on the shared libuv pool. Native admission now uses one atomic capture slot across clients/isolates, rejects overlap with ERROR_BUSY before scheduling, and retains the slot on the CaptureWork owner until completion/cancellation/failure cleanup. Provider mapping returns a capacity refusal with maximum_concurrent_captures:1; no unbounded queue or abandoned surface is introduced. A provider regression covers that tagged capacity result. This establishes the source admission bound; elapsed/CPU/peak-memory performance and real Windows concurrency were not measured. Source inspection covered the producing boundary and affected consumers; prior live history is preserved and git diff --check passed. Tests, builds, lint, typechecks, provider workloads and CI reruns were not run at the explicit user request. No directly related source cleanup remains.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0e2fb4974

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread native/windows/src/window_capture.cc Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Changes are present at public head c0e2fb4974db123047bc65f3623afd8cc26fa22f. Post-capture handle identity alone did not prove the selected path still named the captured bytes. The public fix performs stable-file-style final handle/path identity checks before accepting the screenshot. Reviewed the before/after capture flow; no Windows provider run or tests were performed.

review thread

Changes are present at public head c0e2fb4974db123047bc65f3623afd8cc26fa22f. Promise.all returned on the first failure while sibling hashing could still own I/O/handles. The public fix settles both identity reads before reporting failure, preventing abandoned work from overlapping retries. Reviewed ownership and both result paths; no tests/provider run.

review thread

Changes are present at public head c0e2fb4974db123047bc65f3623afd8cc26fa22f. The shared catch attributed process-image failures to the target path. The public fix keeps the two identity results separate so an error retains its actual path/process source. Source inspection only; no tests/provider run.

review thread

Changes are present at public head c0e2fb4974db123047bc65f3623afd8cc26fa22f. A retryable addon self-test failure was cached as permanent unavailability. The public fix preserves retryability through provider readiness/dispatch. Reviewed readiness and dispatch consumers; no tests/provider run.

review thread

Changes are present at public head c0e2fb4974db123047bc65f3623afd8cc26fa22f. The hard pixel ceiling was projected as generic memory allocation failure. The public fix uses a distinct source-pixel capacity classification and limit. Reviewed native error mapping/projection; no Windows capture execution.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47c8cfeb7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread native/windows/src/window_capture.cc Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread native/windows/src/window_capture.cc Resolved
Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
Comment thread native/windows/src/window_capture.cc Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

please address the comments @SoGeRiEn

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e70e79ac0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread native/windows/src/window_capture.cc Resolved
Comment thread native/windows/src/window_capture.cc Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@SoGeRiEn

Copy link
Copy Markdown
Author

Fixed in 1b95a6c.

Comment thread src/windows/NativeWindowsUiProvider.ts Resolved
@CassieFox23

CassieFox23 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Edit: new results on head 5e34f47 are in #2199 (comment).

TL;DR: On Linux, the new command is listed, checks its input, and refuses on a non-Windows host. All 101 tests in the PR's nine files pass on three Node versions. The real Windows capture did not run, because this box has no Windows desktop and no MinGW compiler.

I tested head 1b95a6c as pushed. For "before", I used main 4135c91 (#3815). A local merge check found 8 conflict spots in 6 files against that main. Main has since moved to b7dcf78.

Results

Check Node 22.23.1 Node 24.18.0 Node 26.11.1
PR test files, head (101 tests) pass pass pass
Typecheck, head not run pass not run
Command help, head not run listed listed
Command help, main not run not in the command list not in the command list
Valid input on Linux, head not run refused: needs Windows x64 refused: needs Windows x64
Bad window handle, head not run rejected, names the handle rejected, names the handle
PID 4294967296, head not run rejected, names the PID rejected, names the PID
MCP tool list, head and main not run head lists it, main does not not run
Windows native build, head not run exit 1, no MinGW not run

Bad handles were an uppercase one, one with no 0x, and 0x0. The capability list shows the tool as unavailable on this host. On main, the tool is not in the list at all.

Over stdio MCP on head, a call with no open app gets the usual "open a binary first" error. After that step, the same call gets the host refusal.

I also read the code at head. Greptile's open note is on lines 373-376 of the Windows provider file. The code does match that note. The early return skips the second identity result. I did not run it.

Not run

  • The real capture on Windows x64. That covers the addon, the paint call, the PNG, and the destroyed-window refusal.
  • The Windows native build, which needs MinGW.
  • Head merged onto current main.
  • The repo-wide checks and the other test folders.
  • Typecheck on Node 22 and 26.

Thanks, SoGeRiEn, for the work and the quick replies on each thread.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: 1b95a6c
  • Base: 97268f4
  • Other: main 4135c91; the fixture is a 512-byte x86-64 PE header built for this test
Commands
npm ci && npm run build && npm run test:prepare
npm run test:focused -- <the 9 test files>
npm run typecheck
npm run build:windows-native
node scripts/rea.mjs capture-windows-window-screenshot <fixture.exe> --pid 1234 --window-handle 0x1a2b
node scripts/rea.mjs capabilities --format json
node scripts/rea.mjs --mcp   (tools/list, open_binary, tools/call)

Each run sat under nice -n 19 and systemd-run --user --scope -p MemoryMax=6G, with a throwaway home folder. One test file has the word doctor in two "must not contain" checks. It never runs doctor.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@SoGeRiEn
SoGeRiEn force-pushed the feat/windows-target-window-capture branch from 1b95a6c to 37016d5 Compare October 15, 2026 05:58
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@SoGeRiEn

Copy link
Copy Markdown
Author

Rebased on current main and cleared the conflicts. Windows-native verification is still pending a Windows x64 host with MinGW.

Comment thread native/windows/src/window_capture.cc Resolved
@SoGeRiEn
SoGeRiEn force-pushed the feat/windows-target-window-capture branch from 37016d5 to 5e34f47 Compare October 15, 2026 12:37
Comment thread src/domain/uiStateTransition.ts Resolved
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: This is the Linux side only. The Windows capture still did not run, because this box has no Windows desktop and no MinGW compiler. On head 5e34f47, the Linux checks pass. The code I read on head 1b95a6c now keeps both identity results.

This follows my earlier result on head 1b95a6c. Head is now 5e34f47, rebased on main. Its merge-base with today's main is c769759. The author says the conflicts are cleared and the Windows check is still pending. Thanks, SoGeRiEn, for the rebase.

Check Node 22.23.1 Node 24.18.0 Node 26.11.1
PR test files, head (106 tests, was 101) pass pass pass
Typecheck, head not run pass not run
Command help, head not run listed listed
Valid input on Linux, head not run refused: needs Windows x64 refused: needs Windows x64
Bad window handle, head not run rejected, names the handle rejected, names the handle
PID 4294967296, head not run rejected, names the PID rejected, names the PID
Windows native build, head not run exit 1, no MinGW not run

Bad handles were an uppercase one, one with no 0x, and 0x0. The capability list shows the tool as unavailable on this host, with the code unsupported_host. Node 24 and Node 26 gave the same CLI output. A PID of 0 and a maximum dimension of 5000 are also rejected. A missing file gives target_unavailable.

Over stdio MCP on head, the call with no open app gets the usual "open a binary first" error. A handle in uppercase, and the PID 4294967296, are rejected with the reason. After open_binary on my 512-byte fixture, the same call gets the host refusal.

The code note from last time. A review note said an early return skipped the second identity result. I read the code at head, lines 369 to 409 of src/windows/NativeWindowsUiProvider.ts. The code now keeps the second failure too, when both identity checks fail. This is my reading only. I did not run that path.

Not run

  • The real capture on Windows x64. That covers the addon, the paint call, the PNG, and the destroyed-window refusal.
  • The Windows native build, which needs MinGW.
  • The new tests on main. The nine files are new in this PR.
  • The repo-wide checks and the other test folders.
  • Typecheck on Node 22 and 26.
  • Head merged onto today's main 9d6651e.

analysisErrorProjection.test.ts has the word doctor in two "must not contain" checks, on lines 201 and 778. It never runs doctor. I read both lines before I ran the file.

The box was shared with other test jobs. Timings are not benchmarks.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: 5e34f47
  • Base: c769759
  • Other: main 9d6651e
  • Other: the fixture is a 512-byte x86-64 PE header built for this test
Commands
npm ci && npm run build && npm run test:prepare
npm run test:focused -- src/application/CapabilityInventory.windowsWindowCapture.test.ts src/domain/analysisErrorProjection.test.ts src/domain/native/windowsWindowScreenshot.test.ts src/server/windowsWindowCaptureDelivery.test.ts src/windows/NativeWindowsUiProvider.test.ts src/windows/NativeWindowsUiProviderMetadata.test.ts src/windows/WindowsNativeLoader.test.ts tests/boundary/cli/windowsWindowScreenshotInputCli.test.ts tests/boundary/mcp/windowsWindowScreenshotMcp.test.ts
npm run typecheck
npm run build:windows-native
node scripts/rea.mjs capture-windows-window-screenshot <fixture.exe> --pid 1234 --window-handle 0x1a2b
node scripts/rea.mjs capabilities --format json
node scripts/rea.mjs mcp   # driven over stdio: tools/list, open_binary, tools/call

Each test run sat under systemd-run --user --scope -p MemoryMax=8G, with a throwaway home folder. The tree shares one node_modules from npm ci, since the lockfiles match.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@SoGeRiEn
SoGeRiEn force-pushed the feat/windows-target-window-capture branch from 5e34f47 to 1cdc72f Compare October 16, 2026 15:27
Comment on lines +84 to +88
native(
"capture_windows_window_screenshot",
"Capture one passive PNG of the exact existing HWND owned by the active PE application. The selected process image must match the active target before and after capture. No desktop, region, title-search, accessibility, input, target launch, or fallback capture is exposed.",
windowsWindowScreenshotInputSchema,
),

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.

P2 Catalog names the wrong provider

Adding capture_windows_window_screenshot to NATIVE_TOOL_CONTRACTS also assigns it to native-macos in the generated catalog. providerCatalog still gives that provider the entire list and has no entry for native-windows-ui, which actually owns capture.

This is a non-blocking documentation error: readers get the wrong provider and cannot find the real one. Split the catalog entries using each provider's own operation declaration.

Knowledge Base Used: Command-line interface

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/contracts/native/nativeToolContracts.ts
Line: 84-88

Comment:
**Catalog names the wrong provider**

Adding `capture_windows_window_screenshot` to `NATIVE_TOOL_CONTRACTS` also assigns it to `native-macos` in the generated catalog. `providerCatalog` still gives that provider the entire list and has no entry for `native-windows-ui`, which actually owns capture.

This is a non-blocking documentation error: readers get the wrong provider and cannot find the real one. Split the catalog entries using each provider's own operation declaration.

**Knowledge Base Used:** [Command-line interface](https://app.greptile.com/pre/-/custom-context/knowledge-base/morluto/rea/-/docs/command-line-interface.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +29 to +34
async (input, options) => {
const result = deriveUiStateTransitionWithSources(
input,
evidenceById,
options,
);

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.

P2 Cancelled comparisons still save records

For large page Evidence, a cancellation queued during parsing or comparison cannot run before this handler saves the sources and transition. The service checks signal.aborted synchronously, and the shared handler's Promise waits do not give stdio a turn to read cancellation.

This is non-blocking, but cancelling can still leave unwanted records in the session. Use runDerivedOperation and save records after its final cancellation check.

Knowledge Base Used: Session evidence and results

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/server/registerUiStateTransitionTool.ts
Line: 29-34

Comment:
**Cancelled comparisons still save records**

For large page Evidence, a cancellation queued during parsing or comparison cannot run before this handler saves the sources and transition. The service checks `signal.aborted` synchronously, and the shared handler's Promise waits do not give stdio a turn to read cancellation.

This is non-blocking, but cancelling can still leave unwanted records in the session. Use `runDerivedOperation` and save records after its final cancellation check.

**Knowledge Base Used:** [Session evidence and results](https://app.greptile.com/pre/-/custom-context/knowledge-base/morluto/rea/-/docs/session-evidence-and-results.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: runtime Process capture and runtime observation area: server Server layer and tool wiring enhancement New feature or request P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(windows): capture target-bound native window evidence

3 participants